Compare commits
4 Commits
e0ba49d7c7
...
83dfd7ed72
| Author | SHA1 | Date | |
|---|---|---|---|
| 83dfd7ed72 | |||
| 6454fa61fc | |||
| 6fe0bfc36d | |||
| 46b092f7df |
@@ -6,5 +6,7 @@ namespace Potter\Aware;
|
||||
|
||||
abstract class AbstractAware implements AwareInterface
|
||||
{
|
||||
|
||||
abstract public function get(string $key): mixed;
|
||||
abstract public function has(string $key): bool;
|
||||
abstract protected function set(string $key, mixed $value): mixed;
|
||||
}
|
||||
|
||||
@@ -6,5 +6,6 @@ namespace Potter\Aware;
|
||||
|
||||
interface AwareInterface
|
||||
{
|
||||
|
||||
public function get(string $key): mixed;
|
||||
public function has(string $key): bool;
|
||||
}
|
||||
|
||||
@@ -6,5 +6,20 @@ namespace Potter\Aware;
|
||||
|
||||
trait AwareTrait
|
||||
{
|
||||
|
||||
private array $aware = [];
|
||||
|
||||
final public function get(string $key): mixed
|
||||
{
|
||||
return $this->aware[$key];
|
||||
}
|
||||
|
||||
final public function has(string $key): bool
|
||||
{
|
||||
return array_key_exists($key, $this->aware);
|
||||
}
|
||||
|
||||
final protected function set(string $key, mixed $value): mixed
|
||||
{
|
||||
return $this->aware[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user