1 | <?php namespace Stevenmaguire\Uber; |
||
3 | trait GetSetTrait |
||
4 | { |
||
5 | /** |
||
6 | * Attempts to magically handle getter and setter methods. |
||
7 | * |
||
8 | * @param string $method |
||
9 | * @param array $parameters |
||
10 | * |
||
11 | * @return mixed |
||
12 | * @throws Exception |
||
13 | */ |
||
14 | 52 | public function __call($method, $parameters) |
|
26 | |||
27 | /** |
||
28 | * Attempts to parse a method name and format its related property name. |
||
29 | * |
||
30 | * @param string $method |
||
31 | * |
||
32 | * @return string |
||
33 | */ |
||
34 | 52 | public function convertMethodToProperty($method) |
|
40 | |||
41 | /** |
||
42 | * Fetches a specific attribute of the current object. |
||
43 | * |
||
44 | * @param string $attribute |
||
45 | * |
||
46 | * @return mixed|null |
||
47 | */ |
||
48 | 18 | private function getAttribute($attribute) |
|
56 | |||
57 | /** |
||
58 | * Checks if given method name is a valid getter method. |
||
59 | * |
||
60 | * @param string $method |
||
61 | * |
||
62 | * @return boolean |
||
63 | */ |
||
64 | 52 | public function isGetMethod($method) |
|
68 | |||
69 | /** |
||
70 | * Checks if given method name is a valid setter method. |
||
71 | * |
||
72 | * @param string $method |
||
73 | * |
||
74 | * @return boolean |
||
75 | */ |
||
76 | 38 | public function isSetMethod($method) |
|
80 | |||
81 | /** |
||
82 | * Updates a specific attribute of the current object. |
||
83 | * |
||
84 | * @param string $attribute |
||
85 | * @param string|boolean|integer $value |
||
86 | * |
||
87 | * @return object |
||
88 | */ |
||
89 | 100 | private function updateAttribute($attribute, $value) |
|
97 | } |
||
98 |