1 | <?php |
||
12 | abstract class AbstractObject |
||
13 | { |
||
14 | /** |
||
15 | * @var ClientInterface |
||
16 | */ |
||
17 | protected $client; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $apiName; |
||
23 | |||
24 | /** |
||
25 | * @var ApiInterface |
||
26 | */ |
||
27 | protected $api; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $fields; |
||
33 | |||
34 | /** |
||
35 | * Default load params, should be overwritten |
||
36 | * in child classes |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $loadParams = array('fields' => 'all'); |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $id; |
||
46 | |||
47 | /** |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $data; |
||
51 | |||
52 | /** |
||
53 | * Constructor. |
||
54 | * |
||
55 | * @param ClientInterface $client the Trello client |
||
56 | * @param string $id the id of the object |
||
57 | */ |
||
58 | public function __construct(ClientInterface $client, $id = null) |
||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | public function getId() |
||
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | public function refresh() |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | public function save() |
||
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | */ |
||
114 | public function remove() |
||
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | */ |
||
133 | public function getData() |
||
137 | |||
138 | /** |
||
139 | * {@inheritdoc} |
||
140 | */ |
||
141 | public function setData(array $data) |
||
147 | |||
148 | /** |
||
149 | * Update the object through API |
||
150 | * |
||
151 | * @return AbstractObject |
||
152 | */ |
||
153 | protected function update() |
||
161 | |||
162 | /** |
||
163 | * Create the object through API |
||
164 | * |
||
165 | * @return AbstractObject |
||
166 | */ |
||
167 | protected function create() |
||
176 | |||
177 | /** |
||
178 | * Called before saving (creating or updating) an entity |
||
179 | */ |
||
180 | protected function preSave() |
||
183 | |||
184 | /** |
||
185 | * Called after saving (creating or updating) an entity |
||
186 | */ |
||
187 | protected function postSave() |
||
190 | |||
191 | /** |
||
192 | * Called before creating an entity |
||
193 | */ |
||
194 | protected function preCreate() |
||
197 | |||
198 | /** |
||
199 | * Called after creating an entity |
||
200 | */ |
||
201 | protected function postCreate() |
||
204 | |||
205 | /** |
||
206 | * Called before updating an entity |
||
207 | */ |
||
208 | protected function preUpdate() |
||
211 | |||
212 | /** |
||
213 | * Called after updating an entity |
||
214 | */ |
||
215 | protected function postUpdate() |
||
218 | |||
219 | /** |
||
220 | * Called before refreshing an entity |
||
221 | */ |
||
222 | protected function preRefresh() |
||
225 | |||
226 | /** |
||
227 | * Called after refreshing an entity |
||
228 | */ |
||
229 | protected function postRefresh() |
||
232 | |||
233 | /** |
||
234 | * Called before removing an entity |
||
235 | */ |
||
236 | protected function preRemove() |
||
239 | |||
240 | /** |
||
241 | * Called after removing an entity |
||
242 | */ |
||
243 | protected function postRemove() |
||
246 | } |
||
247 |
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: