Completed
Push — master ( 3c122c...a9556d )
by Dominik
02:23
created

AbstractNode::__clone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Saxulum\ElasticSearchQueryBuilder\Node;
6
7
abstract class AbstractNode
8
{
9
    /**
10
     * @var AbstractParentNode
11
     */
12
    protected $parent;
13
14
    /**
15
     * @var bool
16
     */
17
    protected $allowSerializeEmpty;
18
19 20
    protected function __construct()
20
    {
21 20
    }
22
23 1
    public function __clone()
24
    {
25 1
        $this->parent = null;
26 1
    }
27
28
    /**
29
     * @param AbstractParentNode $parent
30
     *
31
     * @throws \InvalidArgumentException
32
     */
33 20
    public function setParent(AbstractParentNode $parent)
34
    {
35 20
        if (null !== $this->parent) {
36 1
            throw new \InvalidArgumentException('Node already got a parent!');
37
        }
38
39 20
        $this->parent = $parent;
40 20
    }
41
42
    /**
43
     * @return AbstractParentNode|null
44
     */
45 1
    public function getParent()
46
    {
47 1
        return $this->parent;
48
    }
49
50
    /**
51
     * @return bool
52
     */
53 4
    public function isAllowSerializeEmpty(): bool
54
    {
55 4
        return $this->allowSerializeEmpty;
56
    }
57
58
    /**
59
     * @return \stdClass|array|null
60
     */
61
    abstract public function serializeEmpty();
62
63
    /**
64
     * @return \stdClass|array|string|float|int|bool|null
65
     */
66
    abstract public function serialize();
67
}
68