Total Complexity | 8 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
17 | class TraitModel extends InterfaceModel implements TraitModelInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var AttributeModel[] $attributes Class attributes. |
||
21 | */ |
||
22 | private $attributes = []; |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public function addAttribute(AttributeModelInterface $attribute): void |
||
28 | { |
||
29 | $this->attributes[] = $attribute; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function hasAttribute(string $name): bool |
||
36 | { |
||
37 | foreach ($this->attributes as $attribute) { |
||
38 | if ($attribute->getName() === $name) { |
||
39 | return true; |
||
40 | } |
||
41 | } |
||
42 | return false; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | public function getAttribute(string $name): ?AttributeModelInterface |
||
49 | { |
||
50 | foreach ($this->attributes as $attribute) { |
||
51 | if ($attribute->getName() === $name) { |
||
52 | return $attribute; |
||
53 | } |
||
54 | } |
||
55 | return null; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function getAttributes(): array |
||
64 | } |
||
65 | } |