Files
jsonedit/src/Tree/ObjectNode.php

34 lines
640 B
PHP
Raw Normal View History

2024-10-01 18:46:03 +02:00
<?php
namespace NoccyLabs\JEdit\Tree;
class ObjectNode extends Node implements CollapsibleNode
{
use CollapsibleNodeTrait;
public function __construct(public array $properties)
{
}
public function set(string $key, Node $value)
{
$this->properties[$key] = $value;
}
public function unset(string $key)
{
unset($this->properties[$key]);
}
public function __clone()
{
$properties = array_combine(
array_keys($this->properties),
array_map(fn($v) => clone $v, $this->properties)
);
return new ObjectNode($properties);
}
}