| @@ 246-252 (lines=7) @@ | ||
| 243 | */ |
|
| 244 | public function castFields($fields = null, array $data = []): array |
|
| 245 | { |
|
| 246 | if (!empty($fields)) { |
|
| 247 | if (is_string($fields)) { |
|
| 248 | $fields = preg_split("/[\s,]+/", strtolower($fields)); |
|
| 249 | } else if (!is_array($fields)) { |
|
| 250 | $fields = []; |
|
| 251 | } |
|
| 252 | } |
|
| 253 | ||
| 254 | if (empty($data) || !is_array($data)) { |
|
| 255 | $data = $this->cast(); |
|
| @@ 285-291 (lines=7) @@ | ||
| 282 | */ |
|
| 283 | public function exportArray($fields = null, array $data = []): array |
|
| 284 | { |
|
| 285 | if (!empty($fields)) { |
|
| 286 | if (is_string($fields)) { |
|
| 287 | $fields = preg_split("/[\s,]+/", strtolower($fields)); |
|
| 288 | } else if (!is_array($fields)) { |
|
| 289 | $fields = []; |
|
| 290 | } |
|
| 291 | } |
|
| 292 | ||
| 293 | if (empty($data) || !is_array($data)) { |
|
| 294 | $data = $this->cast(); |
|