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

getObjectToSerialize()   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\SerializationExclusionData;
12
13
/**
14
 * Class DefaultSerializationExclusionData
15
 *
16
 * @author Nate Brunette <[email protected]>
17
 */
18
class DefaultSerializationExclusionData implements SerializationExclusionData
19
{
20
21
    /**
22
     * @var object
23
     */
24
    private $objectToSerialize;
25
26
    /**
27
     * @var callable
28
     */
29
    private $path;
30
31
    /**
32
     * Constructor
33
     *
34
     * @param object $objectToSerialize
35
     * @param callable $path
36
     */
37
    public function __construct($objectToSerialize, callable $path)
38
    {
39
        $this->objectToSerialize = $objectToSerialize;
40
        $this->path = $path;
41
    }
42
43
    /**
44
     * Get the object currently being serialized
45
     *
46
     * @return object
47
     */
48
    public function getObjectToSerialize()
49
    {
50
        return $this->objectToSerialize;
51
    }
52
53
    /**
54
     * Get the current path formatted as json xpath
55
     *
56
     * @return string
57
     */
58
    public function getPath(): string
59
    {
60
        $path = $this->path;
61
62
        return $path();
63
    }
64
}
65