Passed
Pull Request — master (#5)
by Nate
03:04
created

DefaultExclusionData::getDeserializePayload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
namespace Tebru\Gson\Internal;
8
9
use Tebru\Gson\ExclusionData;
10
11
/**
12
 * Class DefaultExclusionData
13
 *
14
 * @author Nate Brunette <[email protected]>
15
 */
16
final class DefaultExclusionData implements ExclusionData
17
{
18
    /**
19
     * If the data is available during serialization or deserialization
20
     *
21
     * @var bool
22
     */
23
    private $serialize;
24
25
    /**
26
     * The object to be serialized or deserialized into
27
     *
28
     * @var object
29
     */
30
    private $data;
31
32
    /**
33
     * The original payload available during deserialization
34
     *
35
     * @var mixed|null
36
     */
37
    private $payload;
38
39
    /**
40
     * Constructor
41
     *
42
     * @param bool $serialize
43
     * @param object $data
44
     * @param mixed|null $payload
45
     */
46 4
    public function __construct(bool $serialize, $data, $payload = null)
47
    {
48 4
        $this->serialize = $serialize;
49 4
        $this->data = $data;
50 4
        $this->payload = $payload;
51 4
    }
52
53
    /**
54
     * Returns true if the data is available during serialization
55
     *
56
     * @return bool
57
     */
58 2
    public function isSerialize(): bool
59
    {
60 2
        return $this->serialize;
61
    }
62
63
    /**
64
     * This will either contain a hydrated object during serialization or the instantiated
65
     * object during deserialization.  During deserialization, this object will likely be
66
     * empty unless a hydrated object was provided.
67
     *
68
     * @return object
69
     */
70 1
    public function getData()
71
    {
72 1
        return $this->data;
73
    }
74
75
    /**
76
     * During deserialization, this will return the provided json after json_decode. During
77
     * serialization, this will return null
78
     *
79
     * @return mixed|null
80
     */
81 1
    public function getDeserializePayload()
82
    {
83 1
        return $this->payload;
84
    }
85
}
86