Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\JEdit\Tree;
|
||||
|
||||
class ArrayNode extends Node implements CollapsibleNode
|
||||
{
|
||||
use CollapsibleNodeTrait;
|
||||
|
||||
public function __construct(public array $items)
|
||||
{
|
||||
}
|
||||
|
||||
public function append(Node $value)
|
||||
{
|
||||
$this->items[] = $value;
|
||||
}
|
||||
|
||||
public function removeIndex(int $index)
|
||||
{
|
||||
unset($this->items[$index]);
|
||||
$this->items = array_values($this->items);
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$items = array_map(fn($v) => clone $v, $this->items);
|
||||
return new ArrayNode($items);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user