Total Complexity | 10 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | abstract class AbstractBlock extends Node |
||
27 | { |
||
28 | /** |
||
29 | * Used for storage of arbitrary data. |
||
30 | * |
||
31 | * @var array<string, mixed> |
||
32 | */ |
||
33 | public $data = []; |
||
34 | |||
35 | /** @var int|null */ |
||
36 | protected $startLine; |
||
37 | |||
38 | /** @var int|null */ |
||
39 | protected $endLine; |
||
40 | |||
41 | protected function setParent(?Node $node = null): void |
||
42 | { |
||
43 | if ($node && ! $node instanceof self) { |
||
44 | throw new \InvalidArgumentException('Parent of block must also be block (cannot be inline)'); |
||
45 | } |
||
46 | |||
47 | parent::setParent($node); |
||
48 | } |
||
49 | |||
50 | public function setStartLine(?int $startLine): void |
||
51 | { |
||
52 | $this->startLine = $startLine; |
||
53 | if ($this->endLine === null) { |
||
54 | $this->endLine = $startLine; |
||
55 | } |
||
56 | } |
||
57 | |||
58 | public function getStartLine(): ?int |
||
61 | } |
||
62 | |||
63 | public function setEndLine(?int $endLine): void |
||
64 | { |
||
65 | $this->endLine = $endLine; |
||
66 | } |
||
67 | |||
68 | public function getEndLine(): ?int |
||
69 | { |
||
70 | return $this->endLine; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @param mixed $default |
||
75 | * |
||
76 | * @return mixed |
||
77 | */ |
||
78 | public function getData(string $key, $default = null) |
||
83 | } |
||
84 | } |
||
85 |