Total Complexity | 9 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 86.96% |
Changes | 0 |
1 | <?php |
||
5 | trait PropertyTrait |
||
6 | { |
||
7 | /** |
||
8 | * @param $name |
||
9 | * |
||
10 | * @return mixed |
||
11 | */ |
||
12 | 14 | public function getProperty($name) |
|
13 | { |
||
14 | 14 | $methodName = 'get'.$this->strToStudlyCase($name); |
|
15 | 14 | if (method_exists($this, $methodName)) { |
|
16 | return $this->{$methodName}(); |
||
17 | } |
||
18 | |||
19 | 14 | if (property_exists($this, $name)) { |
|
20 | 14 | return $this->{$name}; |
|
21 | } |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @param $name |
||
26 | * @param $value |
||
27 | */ |
||
28 | 19 | protected function setProperty($name, $value) |
|
41 | } |
||
42 | } |
||
43 | |||
44 | 14 | public function __get($name) |
|
45 | { |
||
46 | 14 | return $this->getProperty($name); |
|
47 | } |
||
48 | |||
49 | 19 | public function __set($name, $value) |
|
52 | 9 | } |
|
53 | |||
54 | /** |
||
55 | * @param $key |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | 27 | protected function strToStudlyCase($key) |
|
64 |