Total Complexity | 17 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 3 | ||
Bugs | 1 | Features | 2 |
1 | <?php |
||
18 | class Type implements TypeInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var int|string |
||
22 | */ |
||
23 | protected $id; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $name; |
||
29 | |||
30 | 47 | public function __construct($id, $name = null) |
|
31 | { |
||
32 | 47 | $this->id = $id; |
|
33 | 47 | $this->name = $name; |
|
34 | 47 | } |
|
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | 7 | public function getId() |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 29 | public function getName(): ?string |
|
50 | } |
||
51 | |||
52 | 2 | public function hasName(): bool |
|
55 | } |
||
56 | |||
57 | 2 | public function getUniqueId() |
|
60 | } |
||
61 | |||
62 | 2 | public function equals(TypeInterface $other): bool |
|
63 | { |
||
64 | 2 | return $this->id === $other->getId() && |
|
65 | 2 | $this->name === $other->getName(); |
|
66 | } |
||
67 | |||
68 | 22 | public function matches(TypeInterface $other): bool |
|
69 | { |
||
70 | 22 | return $this->id === self::ANY || $other->getId() === self::ANY |
|
71 | 18 | ? $this->checkMatches($this->name, $other->getName()) |
|
72 | 22 | : $this->checkMatches($this->id, $other->getId()); |
|
73 | } |
||
74 | |||
75 | 22 | protected function checkMatches($lhs, $rhs) |
|
82 | } |
||
83 | |||
84 | 1 | public function jsonSerialize(): array |
|
87 | } |
||
88 | } |
||
89 |