Compare commits

..

3 Commits

Author SHA1 Message Date
6f05915e06 get() Method Throws NotFoundException 2025-10-25 13:03:01 -04:00
865f50ad9b Create NotFoundException 2025-10-25 12:48:52 -04:00
e91a72117a Require potter/throwable 2025-10-25 12:46:45 -04:00
3 changed files with 20 additions and 2 deletions

View File

@@ -3,7 +3,9 @@
"type": "library", "type": "library",
"require": { "require": {
"php": "^8.4", "php": "^8.4",
"potter/cloneable": "dev-main" "potter/cloneable": "dev-main",
"potter/throwable": "dev-main",
"psr/container": "^2.0@dev"
}, },
"license": "MIT", "license": "MIT",
"autoload": { "autoload": {

View File

@@ -14,7 +14,10 @@ trait AwareTrait
final public function get(string $key): mixed final public function get(string $key): mixed
{ {
return $this->aware[$key]; if ($this->has($key)) {
return $this->aware[$key];
}
throw new NotFoundException;
} }
final public function has(string $key): bool final public function has(string $key): bool

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Potter\Aware;
use \Psr\Container\NotFoundExceptionInterface;
use \Potter\Throwable\Throwable;
final class NotFoundException extends Throwable implements NotFoundExceptionInterface
{
}