Completed
Pull Request — master (#5)
by Nate
03:06
created

DefaultExclusionData   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 70
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A isSerialize() 0 4 1
A getData() 0 4 1
A getDeserializePayload() 0 4 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