This commit is contained in:
2023-10-02 23:10:49 +03:00
commit c6cb488379
255 changed files with 18731 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace Lucent;
use ArrayAccess;
use JsonSerializable;
/**
* @implements ArrayAccess<string,mixed>
*/
class ArrayContainer implements ArrayAccess, JsonSerializable
{
public function __construct(public array $data)
{
}
public function get(string $key, mixed $default = null): mixed
{
return $this->data[$key] ?? $default;
}
public function offsetSet($offset, $value): void
{
if (is_null($offset)) {
$this->data[] = $value;
} else {
$this->data[$offset] = $value;
}
}
public function offsetExists($offset): bool
{
return isset($this->data[$offset]);
}
public function offsetUnset($offset): void
{
unset($this->data[$offset]);
}
public function offsetGet($offset): mixed
{
return $this->data[$offset] ?? null;
}
public function jsonSerialize(): array
{
return $this->data;
}
public function toArray(): array
{
return $this->data;
}
}