Passed
Branch master (f07ed3)
by Nate
02:39
created

DefaultReaderContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A usesExistingObject() 0 3 1
A setUsesExistingObject() 0 5 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