| @@ 145-151 (lines=7) @@ | ||
| 142 | */ |
|
| 143 | public function castFields($fields = null, array $data = []): array |
|
| 144 | { |
|
| 145 | if (!empty($fields)) { |
|
| 146 | if (is_string($fields)) { |
|
| 147 | $fields = preg_split("/[\s,]+/", strtolower($fields)); |
|
| 148 | } else if (!is_array($fields)) { |
|
| 149 | $fields = []; |
|
| 150 | } |
|
| 151 | } |
|
| 152 | ||
| 153 | if (empty($data) || !is_array($data)) { |
|
| 154 | $data = $this->cast(); |
|
| @@ 184-190 (lines=7) @@ | ||
| 181 | */ |
|
| 182 | public function exportArray($fields = null, array $data = []): array |
|
| 183 | { |
|
| 184 | if (!empty($fields)) { |
|
| 185 | if (is_string($fields)) { |
|
| 186 | $fields = preg_split("/[\s,]+/", strtolower($fields)); |
|
| 187 | } else if (!is_array($fields)) { |
|
| 188 | $fields = []; |
|
| 189 | } |
|
| 190 | } |
|
| 191 | ||
| 192 | if (empty($data) || !is_array($data)) { |
|
| 193 | $data = $this->cast(); |
|