| Conditions | 5 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | * |
||
| 39 | * @throws Error |
||
| 40 | */ |
||
| 41 | 8 | public function serialize($value) |
|
| 42 | { |
||
| 43 | 8 | $float = is_numeric($value) || is_bool($value) ? floatval($value) : null; |
|
| 44 | |||
| 45 | 8 | if ($float === null || ! is_finite($float)) { |
|
| 46 | 5 | throw new Error( |
|
| 47 | 'Float cannot represent non numeric value: ' . |
||
| 48 | 5 | Utils::printSafe($value) |
|
| 49 | ); |
||
| 50 | } |
||
| 51 | |||
| 52 | 3 | return $float; |
|
| 53 | } |
||
| 54 | |||
| 94 |