From f4cb86e38880a5c9e97d784f183d87fcb7fe3488 Mon Sep 17 00:00:00 2001 From: jay Date: Fri, 12 Jun 2026 15:23:36 -0400 Subject: [PATCH] initialize --- composer.json | 3 +- src/Potter/Resource/AbstractResource.php | 17 ++++++++ src/Potter/Resource/Resource.php | 10 +++++ src/Potter/Resource/ResourceInterface.php | 15 ++++++++ src/Potter/Resource/ResourceTrait.php | 47 +++++++++++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/Potter/Resource/AbstractResource.php create mode 100644 src/Potter/Resource/Resource.php create mode 100644 src/Potter/Resource/ResourceInterface.php create mode 100644 src/Potter/Resource/ResourceTrait.php diff --git a/composer.json b/composer.json index b945f04..d7ebc08 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,8 @@ "description": "Potter Framework Resource Interface", "type": "library", "require": { - "php": "^8.5" + "php": "^8.5", + "potter/aware": "^0.0.1" }, "license": "MIT", "autoload": { diff --git a/src/Potter/Resource/AbstractResource.php b/src/Potter/Resource/AbstractResource.php new file mode 100644 index 0000000..83b8386 --- /dev/null +++ b/src/Potter/Resource/AbstractResource.php @@ -0,0 +1,17 @@ +get(self::RESOURCE); + } + + final public function hasResource(): bool + { + return $this->has(self::RESOURCE); + } + + final protected function setResource($resource) + { + return $this->set(self::RESOURCE, $resource); + } + + final protected function unsetResource(): void + { + $this->unset(self::RESOURCE); + } + + final public function withResource($resource): static + { + return $this->with(self::RESOURCE, $resource); + } + + final public function withoutResource(): static + { + return $this->without(self::RESOURCE); + } + + abstract public function get(string $key): mixed; + abstract public function has(string $key): bool; + abstract protected function set(string $key, mixed $value): mixed; + abstract protected function unset(string $key): void; + abstract public function with(string $key, mixed $value): static; + abstract public function without(string $key): static; +}