Passed
Pull Request — master (#26)
by Nate
07:26
created

DefaultReaderContext::setUsesExistingObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
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\Internal;
9
10
use Tebru\Gson\ReaderContext;
11
12
/**
13
 * Class JsonReaderContext
14
 *
15
 * Runtime context that can be used during reading
16
 *
17
 * @author Nate Brunette <[email protected]>
18
 */
19
class DefaultReaderContext implements ReaderContext
20
{
21
    /**
22
     * True if we're reading into an existing object
23
     *
24
     * @var bool
25
     */
26
    private $usesExistingObject = false;
27
28
    /**
29
     * If we're reading into an existing object
30
     *
31
     * @return bool
32
     */
33 5
    public function usesExistingObject(): bool
34
    {
35 5
        return $this->usesExistingObject;
36
    }
37
38
    /**
39
     * When deserializing into an existing object
40
     *
41
     * @param bool $usesExistingObject
42
     * @return ReaderContext
43
     */
44 4
    public function setUsesExistingObject(bool $usesExistingObject): ReaderContext
45
    {
46 4
        $this->usesExistingObject = $usesExistingObject;
47
48 4
        return $this;
49
    }
50
}
51