Total Complexity | 5 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | trait HasAttributes |
||
6 | { |
||
7 | protected $attributes = []; |
||
8 | |||
9 | public function __set($name, $value): void |
||
10 | { |
||
11 | $this->attributes[$name] = $value; |
||
12 | } |
||
13 | |||
14 | public function __get($name) |
||
15 | { |
||
16 | if (!array_key_exists($name, $this->attributes)) { |
||
17 | return null; |
||
18 | } |
||
19 | |||
20 | return $this->attributes[$name]; |
||
21 | } |
||
22 | |||
23 | public function __isset($name): bool |
||
24 | { |
||
25 | return isset($this->attributes[$name]); |
||
26 | } |
||
27 | |||
28 | public function __unset($name) |
||
31 | } |
||
32 | } |
||
33 |