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