This commit is contained in:
2026-03-21 10:11:35 -04:00
parent 24a5a7d4e5
commit 3780e3cddb
5 changed files with 51 additions and 21 deletions

View File

@@ -1,9 +1,9 @@
{
"name": "potter/template",
"description": "Potter Framework Component Template",
"name": "potter/aware",
"description": "Potter Framework Aware Interface",
"version": "1.0.0",
"type": "library",
"homepage": "https://gitpotter.com/Potter/Template",
"homepage": "https://gitpotter.com/Potter/Aware",
"license": "MIT",
"authors": [
{
@@ -14,11 +14,13 @@
],
"autoload": {
"psr-4": {
"Potter\\Template\\": "src/Potter/Template/"
"Potter\\Aware\\": "src/Potter/Aware/"
}
},
"minimum-stability": "stable",
"require": {
"php": "^8.3"
"php": "^8.3",
"potter/cloneable": "^1.0",
"potter/container": "^1.0"
}
}

View File

@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Potter\Aware;
use \Potter\Cloneable\CloneableInterface;
use \Potter\Container\ContainerInterface;
interface AwareInterface extends CloneableInterface, ContainerInterface
{
public function with(string $key, mixed $value): static;
public function without(string $key): static;
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Potter\Aware;
trait AwareTrait
{
final public function with(string $key, mixed $value): static
{
$clone = $this->clone();
$clone->set($key, $value);
return $clone;
}
final public function without(string $key): static
{
$clone = $this->clone();
if (!$clone->has($key)) {
return $clone;
}
$clone->unset($key);
return $clone;
}
abstract public function clone(): static;
abstract public function has(string $key): bool;
abstract protected function set(string $key, mixed $value): mixed;
abstract protected function unset(string $key): null;
}

View File

@@ -1,8 +0,0 @@
<?php
declare(strict_types=1);
namespace Potter\Template;
interface TemplateInterface
{ }

View File

@@ -1,8 +0,0 @@
<?php
declare(strict_types=1);
namespace Potter\Template;
trait TemplateTrait
{ }