From e4ddff98f1821a97c8832ca47ad9b67c95ff5e00 Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Wed, 17 Apr 2024 16:18:27 +0200 Subject: [PATCH] Enable ArrayAccess --- app/Classes/MetadataManager.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/Classes/MetadataManager.php b/app/Classes/MetadataManager.php index a1e5041..df7d28f 100644 --- a/app/Classes/MetadataManager.php +++ b/app/Classes/MetadataManager.php @@ -2,9 +2,10 @@ namespace App\Classes; +use ArrayAccess; use Illuminate\Filesystem\FilesystemAdapter; -class MetadataManager +class MetadataManager implements ArrayAccess { /** * Original metadata content @@ -65,4 +66,32 @@ public function save(): bool return true; } + + public function offsetExists(mixed $offset): bool + { + return isset($this->content[$offset]); + } + + public function &offsetGet(mixed $offset): mixed + { + if (!isset($this->content[$offset])) { + $this->content[$offset] = null; + } + + return $this->content[$offset]; + } + + public function offsetSet(mixed $offset, mixed $value): void + { + if (is_null($offset)) { + $this->content[] = $value; + } else { + $this->content[$offset] = $value; + } + } + + public function offsetUnset(mixed $offset): void + { + unset($this->content[$offset]); + } }