| @@ 277-283 (lines=7) @@ | ||
| 274 | */ |
|
| 275 | public function castFields($fields = null, array $data = []): array |
|
| 276 | { |
|
| 277 | if (!empty($fields)) { |
|
| 278 | if (is_string($fields)) { |
|
| 279 | $fields = preg_split("/[\s,]+/", strtolower($fields)); |
|
| 280 | } else if (!is_array($fields)) { |
|
| 281 | $fields = []; |
|
| 282 | } |
|
| 283 | } |
|
| 284 | ||
| 285 | if (empty($data) || !is_array($data)) { |
|
| 286 | $data = $this->cast(); |
|
| @@ 316-322 (lines=7) @@ | ||
| 313 | */ |
|
| 314 | public function exportArray($fields = null, array $data = []): array |
|
| 315 | { |
|
| 316 | if (!empty($fields)) { |
|
| 317 | if (is_string($fields)) { |
|
| 318 | $fields = preg_split("/[\s,]+/", strtolower($fields)); |
|
| 319 | } else if (!is_array($fields)) { |
|
| 320 | $fields = []; |
|
| 321 | } |
|
| 322 | } |
|
| 323 | ||
| 324 | if (empty($data) || !is_array($data)) { |
|
| 325 | $data = $this->cast(); |
|