Conditions | 7 |
Paths | 7 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 7.049 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
37 | 15 | public static function parseValue($string) |
|
38 | { |
||
39 | switch ($string) { |
||
40 | 15 | case '': return null; |
|
41 | 15 | case 'null': return null; |
|
42 | 14 | case 'true': return true; |
|
43 | 12 | case 'false': return false; |
|
44 | } |
||
45 | |||
46 | 11 | if ($string === (string) ($int = (int) $string)) { |
|
47 | 2 | return $int; |
|
48 | } |
||
49 | |||
50 | // Check for " or ' delimiters |
||
51 | // https://3v4l.org/5u0AU |
||
52 | 9 | if (preg_match('/^(["\']).*\1$/m', $string)) { |
|
53 | return substr($string, 1, -1); |
||
54 | } |
||
55 | |||
56 | 9 | return $string; |
|
57 | } |
||
58 | |||
82 |