Completed
Push — master ( 0eb5d9...ce204c )
by David
14s
created

FailWith::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace TheCodingMachine\GraphQL\Controllers\Annotations;
5
6
use function array_key_exists;
7
8
/**
9
 * @Annotation
10
 * @Target({"METHOD"})
11
 */
12
class FailWith
13
{
14
    /**
15
     * The default value to use if the right is not enforced.
16
     *
17
     * @var mixed
18
     */
19
    private $value;
20
21
    /**
22
     * @param array<string, mixed> $values
23
     *
24
     * @throws \BadMethodCallException
25
     */
26
    public function __construct(array $values)
27
    {
28
        if (!array_key_exists('value', $values)) {
29
            throw new \BadMethodCallException('The @FailWith annotation must be passed a defaultValue. For instance: "@FailWith(null)"');
30
        }
31
        $this->value = $values['value'];
32
    }
33
34
    /**
35
     * Returns the default value to use if the right is not enforced.
36
     *
37
     * @return mixed
38
     */
39
    public function getValue()
40
    {
41
        return $this->value;
42
    }
43
}
44