Compare commits

...

4 Commits

Author SHA1 Message Date
83dfd7ed72 Add set() Method 2025-10-25 11:32:29 -04:00
6454fa61fc Fix has() Method 2025-10-25 11:31:46 -04:00
6fe0bfc36d Add has() Method 2025-10-25 11:30:19 -04:00
46b092f7df Add get() Method 2025-10-25 11:29:22 -04:00
3 changed files with 21 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -6,5 +6,6 @@ namespace Potter\Aware;
interface AwareInterface
{
public function get(string $key): mixed;
public function has(string $key): bool;
}

View File

@@ -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;
}
}