Completed
Pull Request — master (#44)
by Nate
04:08 queued 02:15
created

NullTypeAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 23
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 3 1
A read() 0 3 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Gson;
10
11
/**
12
 * Class NullTypeAdapter
13
 *
14
 * @author Nate Brunette <[email protected]>
15
 */
16
class NullTypeAdapter extends TypeAdapter
17
{
18
    /**
19
     * Read the next value, convert it to its type and return it
20
     *
21
     * @param JsonReadable $reader
22
     * @return void|null
23
     */
24
    public function read(JsonReadable $reader): void
25
    {
26
        $reader->nextNull();
27
    }
28 1
29
    /**
30 1
     * Write the value to the writer for the type
31 1
     *
32
     * @param JsonWritable $writer
33
     * @param mixed $value
34
     * @return void
35
     */
36
    public function write(JsonWritable $writer, $value): void
37
    {
38
        $writer->writeNull();
39
    }
40
}
41