Total Complexity | 4 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
23 | class NullTypeAdapter extends TypeAdapter implements TypeAdapterFactory |
||
24 | { |
||
25 | /** |
||
26 | * Accepts the current type and a [@see TypeAdapterProvider] in case another type adapter needs |
||
27 | * to be fetched during creation. Should return a new instance of the TypeAdapter. Will return |
||
28 | * null if the type adapter is not supported for the provided type. |
||
29 | * |
||
30 | * @param TypeToken $type |
||
31 | * @param TypeAdapterProvider $typeAdapterProvider |
||
32 | * @return TypeAdapter|null |
||
33 | */ |
||
34 | 2 | public function create(TypeToken $type, TypeAdapterProvider $typeAdapterProvider): ?TypeAdapter |
|
35 | { |
||
36 | 2 | return $type->phpType === TypeToken::NULL ? $this : null; |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * Read the next value, convert it to its type and return it |
||
41 | * |
||
42 | * @param null $value |
||
1 ignored issue
–
show
|
|||
43 | * @param ReaderContext $context |
||
44 | * @return null |
||
45 | */ |
||
46 | 1 | public function read($value, ReaderContext $context) |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Write the value to the writer for the type |
||
53 | * |
||
54 | * @param int|null $value |
||
55 | * @param WriterContext $context |
||
56 | * @return void|null |
||
57 | */ |
||
58 | 1 | public function write($value, WriterContext $context) |
|
61 | } |
||
62 | } |
||
63 |