Right   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A __construct() 0 6 3
1
<?php
2
declare(strict_types=1);
3
4
namespace TheCodingMachine\GraphQL\Controllers\Annotations;
5
6
/**
7
 * @Annotation
8
 * @Target({"ANNOTATION", "METHOD"})
9
 * @Attributes({
10
 *   @Attribute("name", type = "string"),
11
 * })
12
 */
13
class Right
14
{
15
    /**
16
     * @var string
17
     */
18
    private $name;
19
20
    /**
21
     * @param array<string, mixed> $values
22
     *
23
     * @throws \BadMethodCallException
24
     */
25
    public function __construct(array $values)
26
    {
27
        if (!isset($values['value']) && !isset($values['name'])) {
28
            throw new \BadMethodCallException('The @Right annotation must be passed a right name. For instance: "@Right(\'my_right\')"');
29
        }
30
        $this->name = $values['value'] ?? $values['name'];
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getName(): string
37
    {
38
        return $this->name;
39
    }
40
}
41