Conditions | 6 |
Paths | 4 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
22 | 8 | private function getScalar($key) { |
|
23 | 8 | if (is_null($key)) |
|
24 | 1 | throw new InvalidTypeException('Can not use null for a key'); |
|
25 | |||
26 | 7 | if (is_object($key) && !method_exists($key, '__toString')) |
|
27 | 1 | throw new InvalidTypeException('Object keys must implement __toString'); |
|
28 | |||
29 | 6 | if (is_numeric($key) || is_string($key)) |
|
30 | 5 | return $key; |
|
31 | |||
32 | 1 | return (string) $key; |
|
33 | } |
||
34 | } |