1 | <?php |
||
15 | trait MutatorsTrait |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * Returns the value of an object property. |
||
20 | * |
||
21 | * Do not call this method directly as it is a PHP magic method that |
||
22 | * will be implicitly called when executing `$value = $object->property;`. |
||
23 | * @param string $name the property name |
||
24 | * @return mixed the property value |
||
25 | * @throws UnknownPropertyException if the property is not defined |
||
26 | * @throws InvalidCallException if the property is write-only |
||
27 | * @see __set() |
||
28 | */ |
||
29 | public function __get($name) |
||
40 | |||
41 | /** |
||
42 | * Sets value of an object property. |
||
43 | * |
||
44 | * Do not call this method directly as it is a PHP magic method that |
||
45 | * will be implicitly called when executing `$object->property = $value;`. |
||
46 | * @param string $name the property name or the event name |
||
47 | * @param mixed $value the property value |
||
48 | * @throws UnknownPropertyException if the property is not defined |
||
49 | * @throws InvalidCallException if the property is read-only |
||
50 | * @see __get() |
||
51 | */ |
||
52 | public function __set($name, $value) |
||
63 | |||
64 | /** |
||
65 | * Checks if a property is set, i.e. defined and not null. |
||
66 | * |
||
67 | * Do not call this method directly as it is a PHP magic method that |
||
68 | * will be implicitly called when executing `isset($object->property)`. |
||
69 | * |
||
70 | * Note that if the property is not defined, false will be returned. |
||
71 | * @param string $name the property name or the event name |
||
72 | * @return boolean whether the named property is set (not null). |
||
73 | * @see http://php.net/manual/en/function.isset.php |
||
74 | */ |
||
75 | public function __isset($name) |
||
84 | |||
85 | /** |
||
86 | * Sets an object property to null. |
||
87 | * |
||
88 | * Do not call this method directly as it is a PHP magic method that |
||
89 | * will be implicitly called when executing `unset($object->property)`. |
||
90 | * |
||
91 | * Note that if the property is not defined, this method will do nothing. |
||
92 | * If the property is read-only, it will throw an exception. |
||
93 | * @param string $name the property name |
||
94 | * @throws InvalidCallException if the property is read only. |
||
95 | * @see http://php.net/manual/en/function.unset.php |
||
96 | */ |
||
97 | public function __unset($name) |
||
106 | |||
107 | /** |
||
108 | * Calls the named method which is not a class method. |
||
109 | * |
||
110 | * Do not call this method directly as it is a PHP magic method that |
||
111 | * will be implicitly called when an unknown method is being invoked. |
||
112 | * @param string $name the method name |
||
113 | * @param array $params method parameters |
||
114 | * @throws UnknownMethodException when calling unknown method |
||
115 | * @return mixed the method return value |
||
116 | */ |
||
117 | public function __call($name, $params) |
||
121 | |||
122 | /** |
||
123 | * Returns a value indicating whether a property is defined. |
||
124 | * A property is defined if: |
||
125 | * |
||
126 | * - the class has a getter or setter method associated with the specified name |
||
127 | * (in this case, property name is case-insensitive); |
||
128 | * - the class has a member variable with the specified name (when `$checkVars` is true); |
||
129 | * |
||
130 | * @param string $name the property name |
||
131 | * @param boolean $checkVars whether to treat member variables as properties |
||
132 | * @return boolean whether the property is defined |
||
133 | * @see canGetProperty() |
||
134 | * @see canSetProperty() |
||
135 | */ |
||
136 | public function hasProperty($name, $checkVars = true) |
||
140 | |||
141 | /** |
||
142 | * Returns a value indicating whether a property can be read. |
||
143 | * A property is readable if: |
||
144 | * |
||
145 | * - the class has a getter method associated with the specified name |
||
146 | * (in this case, property name is case-insensitive); |
||
147 | * - the class has a member variable with the specified name (when `$checkVars` is true); |
||
148 | * |
||
149 | * @param string $name the property name |
||
150 | * @param boolean $checkVars whether to treat member variables as properties |
||
151 | * @return boolean whether the property can be read |
||
152 | * @see canSetProperty() |
||
153 | */ |
||
154 | public function canGetProperty($name, $checkVars = true) |
||
158 | |||
159 | /** |
||
160 | * Returns a value indicating whether a property can be set. |
||
161 | * A property is writable if: |
||
162 | * |
||
163 | * - the class has a setter method associated with the specified name |
||
164 | * (in this case, property name is case-insensitive); |
||
165 | * - the class has a member variable with the specified name (when `$checkVars` is true); |
||
166 | * |
||
167 | * @param string $name the property name |
||
168 | * @param boolean $checkVars whether to treat member variables as properties |
||
169 | * @return boolean whether the property can be written |
||
170 | * @see canGetProperty() |
||
171 | */ |
||
172 | public function canSetProperty($name, $checkVars = true) |
||
176 | |||
177 | /** |
||
178 | * Returns a value indicating whether a method is defined. |
||
179 | * |
||
180 | * The default implementation is a call to php function `method_exists()`. |
||
181 | * You may override this method when you implemented the php magic method `__call()`. |
||
182 | * @param string $name the method name |
||
183 | * @return boolean whether the method is defined |
||
184 | */ |
||
185 | public function hasMethod($name) |
||
189 | } |
||
190 |