From 9719965abb3af90c666aaa2c7e072098f9a07024 Mon Sep 17 00:00:00 2001 From: Jay Potter Date: Sat, 25 Oct 2025 15:36:45 -0400 Subject: [PATCH] Create TemplateEngineAwareTrait --- .../Engine/Aware/TemplateEngineAwareTrait.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/Potter/Template/Engine/Aware/TemplateEngineAwareTrait.php diff --git a/src/Potter/Template/Engine/Aware/TemplateEngineAwareTrait.php b/src/Potter/Template/Engine/Aware/TemplateEngineAwareTrait.php new file mode 100644 index 0000000..83472cb --- /dev/null +++ b/src/Potter/Template/Engine/Aware/TemplateEngineAwareTrait.php @@ -0,0 +1,55 @@ +get(self::TEMPLATE_ENGINE); + } + + abstract public function has(string $key): bool; + + final public function hasTemplateEngine(): bool + { + return $this->has(self::TEMPLATE_ENGINE); + } + + abstract protected function set(string $key, mixed $value): mixed; + + final public function setTemplateEngine(TemplateEngineInterface $templateEngine): TemplateEngineInterface + { + return $this->set(self::TEMPLATE_ENGINE, $templateEngine); + } + + abstract protected function unset(string $key): void; + + final public function unsetTemplateEngine(): void + { + $this->unset(self::TEMPLATE_ENGINE); + } + + abstract public function with(string $key, mixed $value): AwareInterface; + + final public function withTemplateEngine(TemplateEngineInterface $templateEngine): TemplateEngineAwareInterface + { + return $this->with(self::TEMPLATE_ENGINE, $templateEngine); + } + + abstract public function without(string $key): AwareInterface; + + final public function withoutTemplateEngine(): TemplateEngineAwareInterface + { + return $this->without(self::TEMPLATE_ENGINE); + } +}