| Total Complexity | 12 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class Convertor |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Can be cast to array |
||
| 17 | */ |
||
| 18 | 14 | public static function isArrayable(mixed $data): bool |
|
| 19 | { |
||
| 20 | 14 | return is_iterable($data) || $data instanceof Arrayable || $data instanceof stdClass; |
|
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Cast anything to array |
||
| 25 | * |
||
| 26 | * @param positive-int|null $limit |
||
|
|
|||
| 27 | * |
||
| 28 | * @return array<int|string,mixed> |
||
| 29 | * |
||
| 30 | * @throws \RuntimeException |
||
| 31 | */ |
||
| 32 | 14 | public static function toArray(mixed $data, ?int $limit = null): array |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return ($depth is 1 ? array<mixed> : mixed) |
||
| 39 | */ |
||
| 40 | 14 | private static function toArrayWithDepth(mixed $data, int $limit, int $depth): mixed |
|
| 70 | } |
||
| 71 | } |
||
| 72 |