Completed
Pull Request — master (#44)
by Nate
05:11 queued 02:28
created

NullTypeAdapter::read()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\TypeAdapter;
10
11
use Tebru\Gson\JsonReadable;
12
use Tebru\Gson\JsonWritable;
13
use Tebru\Gson\TypeAdapter;
14
15
/**
16
 * Class NullTypeAdapter
17
 *
18
 * @author Nate Brunette <[email protected]>
19
 */
20
class NullTypeAdapter extends TypeAdapter
21
{
22
    /**
23
     * Read the next value, convert it to its type and return it
24
     *
25
     * @param JsonReadable $reader
26
     * @return void|null
27
     */
28 1
    public function read(JsonReadable $reader): void
29
    {
30 1
        $reader->nextNull();
31 1
    }
32
33
    /**
34
     * Write the value to the writer for the type
35
     *
36
     * @param JsonWritable $writer
37
     * @param mixed $value
38
     * @return void
39
     */
40 1
    public function write(JsonWritable $writer, $value): void
41
    {
42 1
        $writer->writeNull();
43 1
    }
44
}
45