Completed
Push — split-exclusion-strategies ( e073a8 )
by Nate
03:36
created

DefaultDeserializationExclusionData::getPayload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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\ReaderContext;
13
14
/**
15
 * Class DefaultDeserializationExclusionData
16
 *
17
 * @author Nate Brunette <[email protected]>
18
 */
19
class DefaultDeserializationExclusionData implements DeserializationExclusionData
20
{
21
    /**
22
     * @var mixed
23
     */
24
    private $payload;
25
26
    /**
27
     * @var object
28
     */
29
    private $objectToReadInto;
30
31
    /**
32
     * @var ReaderContext
33
     */
34
    private $context;
35
36
    /**
37
     * @var callable
38
     */
39
    private $path;
40
41
    /**
42
     * Constructor
43
     *
44
     * @param mixed $payload
45
     * @param object $objectToReadInto
46
     * @param ReaderContext $context
47
     * @param callable $path
48
     */
49
    public function __construct($payload, $objectToReadInto, ReaderContext $context, callable $path)
50
    {
51
        $this->payload = $payload;
52
        $this->objectToReadInto = $objectToReadInto;
53
        $this->context = $context;
54
        $this->path = $path;
55
    }
56
57
    /**
58
     * Get the json data after json_decode()
59
     *
60
     * @return mixed
61
     */
62
    public function getPayload()
63
    {
64
        return $this->payload;
65
    }
66
67
    /**
68
     * Returns the initial object if it was provided to Gson::fromJson() or null
69
     *
70
     * @return object|null
71
     */
72
    public function getObjectToReadInto()
73
    {
74
        return $this->objectToReadInto;
75
    }
76
77
    /**
78
     * Get the reader context
79
     *
80
     * @return ReaderContext
81
     */
82
    public function getContext(): ReaderContext
83
    {
84
        return $this->context;
85
    }
86
87
    /**
88
     * Get the current path formatted as json xpath
89
     *
90
     * @return string
91
     */
92
    public function getPath(): string
93
    {
94
        $path = $this->path;
95
96
        return $path();
97
    }
98
}
99