AbstractNode   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 61
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
serializeEmpty() 0 1 ?
serialize() 0 1 ?
A __construct() 0 3 1
A __clone() 0 4 1
A setParent() 0 8 2
A getParent() 0 4 1
A isAllowSerializeEmpty() 0 4 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 21
    protected function __construct()
20
    {
21 21
    }
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 21
    public function setParent(AbstractParentNode $parent)
34
    {
35 21
        if (null !== $this->parent) {
36 1
            throw new \InvalidArgumentException('Node already got a parent!');
37
        }
38
39 21
        $this->parent = $parent;
40 21
    }
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 5
    public function isAllowSerializeEmpty(): bool
54
    {
55 5
        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