First Commit
This commit is contained in:
commit
923d6ca242
35 changed files with 4933 additions and 0 deletions
38
src/php/ContainerHandler.php
Normal file
38
src/php/ContainerHandler.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GamesShop;
|
||||
|
||||
use League\Container\Container;
|
||||
use League\Container\ReflectionContainer;
|
||||
|
||||
final class ContainerHandler
|
||||
{
|
||||
private static Container|null $instance = null;
|
||||
|
||||
public static function getInstance(): Container
|
||||
{
|
||||
if (self::$instance === null) {
|
||||
self::createInstance();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template RequestedType
|
||||
*
|
||||
* @param class-string<RequestedType>|string $id
|
||||
*
|
||||
* @return RequestedType|mixed
|
||||
*/
|
||||
public static function get(string $id) {
|
||||
return self::getInstance()->get($id);
|
||||
}
|
||||
|
||||
private static function createInstance()
|
||||
{
|
||||
self::$instance = new Container();
|
||||
self::$instance->delegate(new ReflectionContainer(true));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue