Initial commit
This commit is contained in:
33
src/Tree/ObjectNode.php
Normal file
33
src/Tree/ObjectNode.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user