Compare commits

...

5 Commits

Author SHA1 Message Date
jay e7ab2b417f remove duplicated trait 2026-06-14 11:50:01 -04:00
jay 707d8cdfca missing use statement 2026-06-14 11:41:27 -04:00
jay 8672ec72a4 implement Potter\Aware 2026-05-31 19:14:24 -04:00
jay 7d99358220 implement Potter\Aware 2026-05-31 18:54:02 -04:00
jay c9d2aa1170 implement Potter\Aware 2026-05-31 18:53:39 -04:00
6 changed files with 73 additions and 5 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
# Template # Template
Potter Framework Component Template Potter Framework Aware Implementation
+6 -4
View File
@@ -1,14 +1,16 @@
{ {
"name": "potter/template", "name": "potter/aware",
"description": "Potter Framework Component Template", "description": "Potter Framework Aware Implementation",
"type": "library", "type": "library",
"require": { "require": {
"php": "^8.5" "php": "^8.5",
"potter/cloneable": "^0.0.1",
"potter/container": "^0.0.1"
}, },
"license": "MIT", "license": "MIT",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Potter\\": "src/Potter/" "Potter\\Aware\\": "src/Potter/Aware/"
} }
}, },
"authors": [ "authors": [
+16
View File
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Potter\Aware;
use \Potter\Cloneable\CloneableTrait;
use \Potter\Container\Container;
abstract class AbstractAware extends Container
{
use CloneableTrait;
abstract public function with(string $key, mixed $value): static;
abstract public function without(string $key): static;
}
+10
View File
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Potter\Aware;
abstract class Aware extends AbstractAware
{
use AwareTrait;
}
+14
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;
}
+26
View File
@@ -0,0 +1,26 @@
<?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();
$clone->unset($key);
return $clone;
}
abstract public function clone(): static;
abstract protected function set(string $key, mixed $value): mixed;
abstract protected function unset(string $key): void;
}