| Conditions | 8 |
| Paths | 8 |
| Total Lines | 36 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 8 |
| Changes | 5 | ||
| Bugs | 1 | Features | 2 |
| 1 | <?php |
||
| 30 | 8 | public function map($value) |
|
| 31 | { |
||
| 32 | 8 | if ($value === 'true') { |
|
| 33 | 1 | return true; |
|
| 34 | } |
||
| 35 | |||
| 36 | 8 | if ($value === 'false') { |
|
| 37 | 1 | return false; |
|
| 38 | } |
||
| 39 | |||
| 40 | 7 | if ($value === 'null') { |
|
| 41 | 1 | return; |
|
| 42 | } |
||
| 43 | |||
| 44 | // Map integers |
||
| 45 | 6 | if (preg_match('/^(\d+)$/', $value, $matches)) { |
|
| 46 | 1 | return (int) $matches[1]; |
|
| 47 | } |
||
| 48 | |||
| 49 | // Map floats |
||
| 50 | 5 | if (preg_match('/^(\d+\.\d+)$/', $value, $matches)) { |
|
| 51 | 1 | return (float) $matches[1]; |
|
| 52 | } |
||
| 53 | |||
| 54 | // Map strings |
||
| 55 | 4 | if (preg_match('/^"(.*)"$/', $value, $matches)) { |
|
| 56 | 2 | return $matches[1]; |
|
| 57 | } |
||
| 58 | |||
| 59 | // Map parser error |
||
| 60 | 2 | if (preg_match('/^parse error: (.*)$/', $value, $matches)) { |
|
| 61 | 1 | throw new DataTypeMapperException($matches[1]); |
|
| 62 | } |
||
| 63 | |||
| 64 | 1 | return $value; |
|
| 65 | } |
||
| 66 | } |
||
| 67 |