1 | <?php |
||
16 | trait Property |
||
17 | { |
||
18 | /** |
||
19 | * Returns camel cased property's getter or setter method name. Checks method for existence. |
||
20 | * |
||
21 | * @param string $prefix Prefix of the method e.g. "set" or "get" |
||
22 | * @param string $name Method's name |
||
23 | * |
||
24 | * @return null|string |
||
25 | */ |
||
26 | protected function getSetGetMethodName($prefix, $name) |
||
36 | |||
37 | /** |
||
38 | * Sets properties of the class from array. |
||
39 | * |
||
40 | * @param array $data An associative array with property => value data |
||
41 | */ |
||
42 | protected function setProperties(array $data) |
||
48 | |||
49 | /** |
||
50 | * Sets property of the class. |
||
51 | * |
||
52 | * @param string $name Property name |
||
53 | * @param null|mixed $value Value of the property |
||
54 | */ |
||
55 | protected function setProperty($name, $value = null) |
||
69 | |||
70 | /** |
||
71 | * Returns properties as string. Used for building get query string if GET method was set. |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | public function getPropertiesAsString() |
||
81 | |||
82 | /** |
||
83 | * Returns an array with properties. Array with supported properties should be defined |
||
84 | * in the class. |
||
85 | * |
||
86 | * @param bool $validate Flag whether validation for required properties should be applied |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | public function getPropertiesArray($validate = true) |
||
125 | |||
126 | /** |
||
127 | * Validates properties and checks which are required |
||
128 | * |
||
129 | * @param array $properties An associative array of the properties |
||
130 | * |
||
131 | * @throws Critical |
||
132 | */ |
||
133 | protected function validateProperties($properties) |
||
141 | |||
142 | /** |
||
143 | * Returns object's properties encoded as JSON string |
||
144 | * |
||
145 | * @param bool $validate Flag whether validation for required properties should be applied |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | public function asJson($validate = true) |
||
155 | } |
||
156 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: