Completed
Push — master ( 9dfc82...fbb6e1 )
by Dominik
02:13
created

AbstractNode::isAllowDefault()   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
ccs 2
cts 2
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 $allowDefault;
18
19
    /**
20
     * @param AbstractParentNode $parent
21
     *
22
     * @throws \InvalidArgumentException
23
     */
24 16
    public function setParent(AbstractParentNode $parent)
25
    {
26 16
        if (null !== $this->parent) {
27 2
            throw new \InvalidArgumentException('Node already got a parent!');
28
        }
29
30 16
        $this->parent = $parent;
31 16
    }
32
33
    /**
34
     * @return AbstractParentNode|null
35
     */
36 7
    public function getParent()
37
    {
38 7
        return $this->parent;
39
    }
40
41
    /**
42
     * @return bool
43
     */
44 4
    public function isAllowDefault(): bool
45
    {
46 4
        return $this->allowDefault;
47
    }
48
49
    /**
50
     * @return \stdClass|array|null
51
     */
52
    abstract public function getDefault();
53
54
    /**
55
     * @return \stdClass|array|string|float|int|bool|null
56
     */
57
    abstract public function serialize();
58
}
59