From ffdb577f7e856445526ab3abc02e490cbbe952bb Mon Sep 17 00:00:00 2001 From: jay Date: Sun, 31 May 2026 18:08:48 -0400 Subject: [PATCH] implement ContainerInterface --- README.md | 2 +- composer.json | 2 +- src/Potter/Container/AbstractContainer.php | 13 ++++++++++ src/Potter/Container/Container.php | 10 ++++++++ src/Potter/Container/ContainerTrait.php | 30 ++++++++++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/Potter/Container/AbstractContainer.php create mode 100644 src/Potter/Container/Container.php create mode 100644 src/Potter/Container/ContainerTrait.php diff --git a/README.md b/README.md index e0abf18..3a72248 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Container -Potter Framework Container Interface \ No newline at end of file +Potter Framework Container Implementation \ No newline at end of file diff --git a/composer.json b/composer.json index 8eec0cb..0b95887 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "potter/container", - "description": "Potter Framework Container Interface", + "description": "Potter Framework Container Implementation", "type": "library", "require": { "php": "^8.5", diff --git a/src/Potter/Container/AbstractContainer.php b/src/Potter/Container/AbstractContainer.php new file mode 100644 index 0000000..803aefc --- /dev/null +++ b/src/Potter/Container/AbstractContainer.php @@ -0,0 +1,13 @@ +container[$key]; + } + + final public function has(string $key): bool + { + return array_key_exists($key, $this->container); + } + + final protected function set(string $key, mixed $value): mixed + { + return $this->container[$key] = $value; + } + + final protected function unset(string $key): void + { + unset($this->container[$key]); + } +}