| Conditions | 7 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public static function build($params): array |
||
| 18 | { |
||
| 19 | return collect($params) |
||
|
|
|||
| 20 | ->reject(function ($value) { |
||
| 21 | return blank($value); |
||
| 22 | })->transform(function ($value) { |
||
| 23 | if (is_object($value)) { |
||
| 24 | return $value->toArray(); |
||
| 25 | } |
||
| 26 | |||
| 27 | if (is_array($value)) { |
||
| 28 | return static::build($value); |
||
| 29 | } |
||
| 30 | |||
| 31 | if (is_numeric($value)) { |
||
| 32 | return $value + 0; |
||
| 33 | } |
||
| 34 | |||
| 35 | if (is_bool($value)) { |
||
| 36 | return (int) $value; |
||
| 37 | } |
||
| 38 | |||
| 39 | if (is_string($value) && mb_detect_encoding($value, 'auto') !== 'UTF-8') { |
||
| 40 | return mb_convert_encoding($value, 'UTF-8'); |
||
| 41 | } |
||
| 42 | |||
| 43 | return $value; |
||
| 44 | })->toArray(); |
||
| 45 | } |
||
| 47 |