Total Complexity | 8 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
18 | trait AttributesTrait { |
||
19 | |||
20 | /** |
||
21 | * Override this property with your own annotation. |
||
22 | * |
||
23 | * The property must remain `null` when not in use. |
||
24 | * |
||
25 | * @eav EAV_TABLE |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $attributes; |
||
29 | |||
30 | /** |
||
31 | * @return array |
||
32 | */ |
||
33 | public function getAttributes (): array { |
||
34 | return $this->attributes ?: []; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param mixed $attr |
||
39 | * @return bool |
||
40 | */ |
||
41 | public function offsetExists ($attr): bool { |
||
42 | return $this->attributes and array_key_exists($attr, $this->attributes); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param mixed $attr |
||
47 | * @return null|mixed |
||
48 | */ |
||
49 | public function offsetGet ($attr) { |
||
50 | return $this->attributes[$attr] ?? null; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @param mixed $attr |
||
55 | * @param mixed $value |
||
56 | */ |
||
57 | public function offsetSet ($attr, $value): void { |
||
58 | $this->attributes[$attr] = $value; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param mixed $attr |
||
63 | */ |
||
64 | public function offsetUnset ($attr): void { |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param array $attributes |
||
70 | * @return $this |
||
71 | */ |
||
72 | public function setAttributes (array $attributes) { |
||
75 | } |
||
76 | } |