1 | <?php |
||
18 | abstract class AbstractEntity |
||
19 | { |
||
20 | /** |
||
21 | * The model's attributes. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $attributes = []; |
||
26 | |||
27 | /** |
||
28 | * @param \stdClass|array|null $parameters |
||
29 | */ |
||
30 | public function __construct($parameters = null) |
||
42 | |||
43 | /** |
||
44 | * @param array $parameters |
||
45 | */ |
||
46 | public function build(array $parameters) |
||
56 | |||
57 | /** |
||
58 | * @return array |
||
59 | */ |
||
60 | public function toArray() |
||
77 | |||
78 | /** |
||
79 | * @param string|null $date DateTime string |
||
80 | * |
||
81 | * @return string|null DateTime in ISO8601 format |
||
82 | */ |
||
83 | protected static function convertDateTime($date) |
||
94 | |||
95 | /** |
||
96 | * @param string $str Snake case string |
||
97 | * |
||
98 | * @return string Camel case string |
||
99 | */ |
||
100 | protected static function convertToCamelCase($str) |
||
108 | |||
109 | /** |
||
110 | * @param $str Camel case string |
||
111 | * |
||
112 | * @return string Snake case string |
||
113 | */ |
||
114 | protected static function convertToSnakeCase($str) |
||
118 | |||
119 | /** |
||
120 | * Dynamically retrieve attributes on the model. |
||
121 | * |
||
122 | * @param string $key |
||
123 | * @return mixed |
||
124 | */ |
||
125 | public function __get($key) |
||
129 | |||
130 | /** |
||
131 | * Dynamically set attributes on the model. |
||
132 | * |
||
133 | * @param string $key |
||
134 | * @param mixed $value |
||
135 | * @return void |
||
136 | */ |
||
137 | public function __set($key, $value) |
||
141 | } |
||
142 |
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: