Completed
Push — v0.7 ( 7c9b41...5c4e91 )
by Nate
02:30
created

DefaultReaderContext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 56
ccs 5
cts 5
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUsesExistingObject() 0 5 1
A usesExistingObject() 0 3 1
A setPayload() 0 5 1
A getPayload() 0 3 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
final class DefaultReaderContext extends DefaultContext 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
     * The initial json_decode'd payload
30
     *
31
     * @var mixed
32
     */
33 5
    private $payload;
34
35 5
    /**
36
     * If we're reading into an existing object
37
     *
38
     * @return bool
39
     */
40
    public function usesExistingObject(): bool
41
    {
42
        return $this->usesExistingObject;
43
    }
44 4
45
    /**
46 4
     * When deserializing into an existing object
47
     *
48 4
     * @param bool $usesExistingObject
49
     * @return ReaderContext
50
     */
51
    public function setUsesExistingObject(bool $usesExistingObject): ReaderContext
52
    {
53
        $this->usesExistingObject = $usesExistingObject;
54
55
        return $this;
56
    }
57
58
    /**
59
     * @return mixed
60
     */
61
    public function getPayload()
62
    {
63
        return $this->payload;
64
    }
65
66
    /**
67
     * @param mixed $payload
68
     * @return DefaultReaderContext
69
     */
70
    public function setPayload($payload): DefaultReaderContext
71
    {
72
        $this->payload = $payload;
73
74
        return $this;
75
    }
76
}
77