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

DefaultReaderContext::getPayload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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