Conditions | 7 |
Paths | 6 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
32 | 123 | public function serialize($value) |
|
33 | { |
||
34 | 123 | if ($value === true) { |
|
35 | 2 | return 'true'; |
|
36 | } |
||
37 | 123 | if ($value === false) { |
|
38 | 2 | return 'false'; |
|
39 | } |
||
40 | 123 | if ($value === null) { |
|
41 | 1 | return 'null'; |
|
42 | } |
||
43 | 123 | if (is_object($value) && method_exists($value, '__toString')) { |
|
44 | 1 | return (string) $value; |
|
45 | } |
||
46 | 123 | if (!is_scalar($value)) { |
|
47 | 3 | throw new Error("String cannot represent non scalar value: " . Utils::printSafe($value)); |
|
48 | } |
||
49 | 120 | return $this->coerceString($value); |
|
50 | } |
||
89 |