generated from Potter/Template
init
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "potter/template",
|
"name": "potter/aware",
|
||||||
"description": "Potter Framework Component Template",
|
"description": "Potter Framework Aware Interface",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"homepage": "https://gitpotter.com/Potter/Template",
|
"homepage": "https://gitpotter.com/Potter/Aware",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -14,11 +14,13 @@
|
|||||||
],
|
],
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Potter\\Template\\": "src/Potter/Template/"
|
"Potter\\Aware\\": "src/Potter/Aware/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3"
|
"php": "^8.3",
|
||||||
|
"potter/cloneable": "^1.0",
|
||||||
|
"potter/container": "^1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/Potter/Aware/AwareInterface.php
Normal file
14
src/Potter/Aware/AwareInterface.php
Normal 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;
|
||||||
|
}
|
||||||
30
src/Potter/Aware/AwareTrait.php
Normal file
30
src/Potter/Aware/AwareTrait.php
Normal 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;
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Potter\Template;
|
|
||||||
|
|
||||||
interface TemplateInterface
|
|
||||||
{ }
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Potter\Template;
|
|
||||||
|
|
||||||
trait TemplateTrait
|
|
||||||
{ }
|
|
||||||
Reference in New Issue
Block a user