initialize

This commit is contained in:
2026-03-21 09:53:59 -04:00
parent 2877529080
commit 1f685e7674
5 changed files with 43 additions and 4 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
composer.lock
composer.phar
/nbproject/private/
/nbproject/
/vendor/

View File

@@ -1,3 +1,3 @@
# Potter Framework PSR-11 Container Implementation
# Potter Framework Container Interface
Hello World

View File

@@ -1,6 +1,6 @@
{
"name": "potter/container",
"description": "Potter Framework PSR-11 Container Implementation",
"description": "Potter Framework Container Interface",
"version": "1.0.0",
"type": "library",
"homepage": "https://gitpotter.com/Potter/Container",
@@ -19,6 +19,7 @@
},
"minimum-stability": "stable",
"require": {
"php": "^8.3"
"php": "^8.3",
"psr/container": "^2.0"
}
}

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Potter\Container;
use \Psr\Container\ContainerInterface as PsrContainerInterface;
interface ContainerInterface extends PsrContainerInterface
{
public function get(string $key): mixed;
public function has(string $key): bool;
}

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Potter\Container;
trait ContainerTrait
{
private array $storage = [];
final public function get(string $key): mixed
{
return $this->storage[$key];
}
final public function has(string $key): bool
{
return array_key_exists($key, $this->storage) && !is_null($this->storage[$key]);
}
final protected function set(string $key, mixed $value): mixed
{
return $this->storage[$key] = $value;
}
}