| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 2 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 38 | 4 | public static function toArray($value) |
|
| 39 | { |
||
| 40 | 4 | if (is_array($value)) { |
|
| 41 | 1 | return $value; |
|
| 42 | } |
||
| 43 | |||
| 44 | 3 | if ($value === null) { |
|
| 45 | 1 | return []; |
|
| 46 | } |
||
| 47 | |||
| 48 | 2 | if (!$value instanceof Traversable) { |
|
| 49 | 1 | throw new Exception\InvalidArgumentException( |
|
| 50 | 'An invalid value was provided, should either be an null, array or Traversable' |
||
| 51 | 1 | ); |
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | return iterator_to_array($value); |
|
| 55 | } |
||
| 56 | } |
||
| 57 |