Total Complexity | 7 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | trait DynamicPropertiesTrait |
||
10 | { |
||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $properties = []; |
||
15 | |||
16 | /** |
||
17 | * @param $name |
||
18 | * @return mixed |
||
19 | */ |
||
20 | public function &__get($name) |
||
21 | { |
||
22 | if (!$this->__isset($name)) { |
||
23 | $this->properties[$name] = null; |
||
24 | } |
||
25 | return $this->properties[$name]; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param $name |
||
30 | * @param $value |
||
31 | */ |
||
32 | public function __set($name, $value) |
||
33 | { |
||
34 | $this->properties[$name] = $value; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param $key |
||
39 | * @return bool |
||
40 | */ |
||
41 | public function __isset($key) |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Get an attribute from the container. |
||
48 | * |
||
49 | * @param string $key |
||
50 | * @param mixed $default |
||
51 | * @return mixed |
||
52 | */ |
||
53 | public function get($key, $default = null) |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @param $name |
||
64 | */ |
||
65 | public function __unset($name) |
||
68 | } |
||
69 | } |
||
70 |