Passed
Push — master ( 21a5dc...1ca6d2 )
by Nate
40s
created

DefaultDeserializationExclusionData::getPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Gson\Internal;
10
11
use Tebru\Gson\Exclusion\DeserializationExclusionData;
12
use Tebru\Gson\JsonReadable;
13
use Tebru\Gson\ReaderContext;
14
15
/**
16
 * Class DefaultDeserializationExclusionData
17
 *
18
 * @author Nate Brunette <[email protected]>
19
 */
20
class DefaultDeserializationExclusionData implements DeserializationExclusionData
21
{
22
    /**
23
     * @var object
24
     */
25
    private $objectToReadInto;
26
27
    /**
28
     * @var JsonReadable
29
     */
30
    private $reader;
31
32
    /**
33
     * Constructor
34
     *
35
     * @param object $objectToReadInto
36
     * @param JsonReadable $reader
37
     */
38 2
    public function __construct($objectToReadInto, JsonReadable $reader)
39
    {
40 2
        $this->objectToReadInto = $objectToReadInto;
41 2
        $this->reader = $reader;
42 2
    }
43
44
    /**
45
     * Get the json data after json_decode()
46
     *
47
     * @return mixed
48
     */
49 1
    public function getPayload()
50
    {
51 1
        return $this->reader->getPayload();
52
    }
53
54
    /**
55
     * Returns the initial object if it was provided to Gson::fromJson() or null
56
     *
57
     * @return object|null
58
     */
59 1
    public function getObjectToReadInto()
60
    {
61 1
        return $this->objectToReadInto;
62
    }
63
64
    /**
65
     * Get the reader context
66
     *
67
     * @return ReaderContext
68
     */
69 1
    public function getContext(): ReaderContext
70
    {
71 1
        return $this->reader->getContext();
72
    }
73
74
    /**
75
     * Get the current path formatted as json xpath
76
     *
77
     * @return string
78
     */
79 2
    public function getPath(): string
80
    {
81 2
        return $this->reader->getPath();
82
    }
83
}
84