Completed
Push — v0.7 ( 21297d...0d3226 )
by Nate
02:43
created

WriterContext::setSerializeNull()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
declare(strict_types=1);
7
8
namespace Tebru\Gson\Context;
9
10
/**
11
 * Class JsonReaderContext
12
 *
13
 * Runtime context that can be used during reading
14
 *
15
 * @author Nate Brunette <[email protected]>
16
 */
17
class WriterContext extends Context
18
{
19
    /**
20
     * If nulls should be serialized
21
     *
22
     * @var bool
23
     */
24
    private $serializeNull = false;
25
26
    /**
27
     * If we should serialize null
28
     *
29
     * @return bool
30
     */
31 1
    public function serializeNull(): bool
32
    {
33 1
        return $this->serializeNull;
34
    }
35
36
    /**
37
     * Set if nulls should be serialized
38
     *
39
     * @param bool $serializeNull
40
     * @return Context
41
     */
42 1
    public function setSerializeNull(bool $serializeNull): Context
43
    {
44 1
        $this->serializeNull = $serializeNull;
45
46 1
        return $this;
47
    }
48
}
49