Total Complexity | 4 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
16 | class IntegerTypeAdapter extends TypeAdapter |
||
17 | { |
||
18 | /** |
||
19 | * Read the next value, convert it to its type and return it |
||
20 | * |
||
21 | * @param JsonReadable $reader |
||
22 | * @return int|null |
||
23 | */ |
||
24 | public function read(JsonReadable $reader): ?int |
||
25 | { |
||
26 | if ($reader->peek() === JsonToken::NULL) { |
||
27 | $reader->nextNull(); |
||
28 | return null; |
||
29 | 2 | } |
|
30 | |||
31 | 2 | return $reader->nextInteger(); |
|
32 | 1 | } |
|
33 | 1 | ||
34 | /** |
||
35 | * Write the value to the writer for the type |
||
36 | 1 | * |
|
37 | * @param JsonWritable $writer |
||
38 | * @param int|null $value |
||
39 | * @return void |
||
40 | */ |
||
41 | public function write(JsonWritable $writer, $value): void |
||
50 | } |
||
51 | } |
||
52 |