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

DefaultReaderContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 32
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

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