add Behaviour
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter\Environment;
|
||||||
|
|
||||||
|
use \Potter\Container;
|
||||||
|
|
||||||
|
trait Behaviour
|
||||||
|
{
|
||||||
|
private static function addEnvironment(Container $container): void
|
||||||
|
{
|
||||||
|
$container->addShared(Environment::class, function () {
|
||||||
|
return Environment::createImmutable(getcwd());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function addEnvironmentBehaviour(Container $container): void
|
||||||
|
{
|
||||||
|
static::addEnvironment($container);
|
||||||
|
self::getEnvironment($container)->required(['APPLICATION_NAME']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getEnvironment(Container $container): Environment
|
||||||
|
{
|
||||||
|
return $container->get(Environment::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function hasEnvironment(Container $container): bool
|
||||||
|
{
|
||||||
|
return $container->has(Environment::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user