Completed
Push — master ( 58c980...3e9401 )
by David
13s queued 11s
created

AddInterface::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 1
1
<?php
2
3
4
namespace TheCodingMachine\TDBM\Utils\Annotation;
5
6
/**
7
 * @Annotation
8
 * @Attributes({
9
 *   @Attribute("name", type = "string"),
10
 * })
11
 */
12
final class AddInterface
13
{
14
    /**
15
     * The PHP interface that is implemented by the Bean.
16
     *
17
     * @var string
18
     */
19
    private $name;
20
21
    /**
22
     * @param array<string, mixed> $values
23
     *
24
     * @throws \BadMethodCallException
25
     */
26
    public function __construct(array $values)
27
    {
28
        if (!isset($values['value']) && !isset($values['name'])) {
29
            throw new \BadMethodCallException('The @AddInterface annotation must be passed an interface to implement. For instance: \'@AddInterface("Foo\\BarInterface")\'');
30
        }
31
        $this->name = $values['value'] ?? $values['name'];
32
    }
33
34
    public function getName(): string
35
    {
36
        return $this->name;
37
    }
38
}
39