36 lines
648 B
PHP
36 lines
648 B
PHP
<?php
|
|
|
|
namespace NoccyLabs\JsonEdit\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(): void
|
|
{
|
|
$this->items = array_map(fn($v) => clone $v, $this->items);
|
|
}
|
|
|
|
public function jsonSerialize(): mixed
|
|
{
|
|
return array_values($this->items);
|
|
}
|
|
|
|
}
|
|
|