Passed
Push — master ( db1fd3...5522e6 )
by Maarten de
03:44 queued 01:33
created

AbstractConnective::offsetSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cloudstek\SCIM\FilterParser\AST;
6
7
/**
8
 * Abstract connective.
9
 */
10
abstract class AbstractConnective extends AbstractNode implements Connective
11
{
12
    /** @var Node[] */
13
    protected array $nodes;
14
15
    /**
16
     * Logical conjunction (AND).
17
     *
18
     * @param Node[]    $nodes
19
     * @param Node|null $parent
20
     */
21
    public function __construct(array $nodes, ?Node $parent = null)
22
    {
23
        parent::__construct($parent);
24
25
        $this->nodes = $nodes;
26
27
        foreach ($this->nodes as $node) {
28
            $node->setParent($this);
29
        }
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function getNodes(): array
36
    {
37
        return $this->nodes;
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43
    public function offsetExists($offset)
44
    {
45
        return isset($this->nodes[$offset]);
46
    }
47
48
    /**
49
     * @inheritDoc
50
     */
51
    public function offsetGet($offset)
52
    {
53
        return $this->nodes[$offset];
54
    }
55
56
    /**
57
     * @inheritDoc
58
     */
59
    public function offsetSet($offset, $value)
60
    {
61
        throw new \LogicException('Conjunction is read-only.');
62
    }
63
64
    /**
65
     * @inheritDoc
66
     */
67
    public function offsetUnset($offset)
68
    {
69
        throw new \LogicException('Conjunction is read-only.');
70
    }
71
72
    /**
73
     * @inheritDoc
74
     */
75
    public function count()
76
    {
77
        return count($this->nodes);
78
    }
79
80
    /**
81
     * @inheritDoc
82
     */
83
    public function getIterator()
84
    {
85
        return new \ArrayIterator($this->nodes);
86
    }
87
}
88