Compare commits
9 Commits
ff5aeeacef
...
0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| ae21edd5bb | |||
| a793b842b1 | |||
| e664b84072 | |||
| 6318a565ec | |||
| 4adc20284c | |||
| 7e2ee30244 | |||
| 622b69f82d | |||
| af5ca24364 | |||
| e0ac5c6e1f |
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Potter\\Environment\\": "src/Potter/Environment/"
|
"Potter\\": "src/Potter/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter;
|
||||||
|
|
||||||
|
use \Dotenv\Dotenv;
|
||||||
|
use \Potter\Container;
|
||||||
|
|
||||||
|
trait Environment
|
||||||
|
{
|
||||||
|
private static function addEnvironment(Container $container): void
|
||||||
|
{
|
||||||
|
$container->addShared(Dotenv::class, function () {
|
||||||
|
return Dotenv::createImmutable(getcwd()); });
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function addEnvironmentBehaviour(Container $container): void
|
||||||
|
{
|
||||||
|
self::addEnvironment($container);
|
||||||
|
$environment = self::getEnvironment($container);
|
||||||
|
$environment->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getEnvironment(Container $container): Dotenv
|
||||||
|
{
|
||||||
|
return $container->get(Dotenv::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Potter\Environment;
|
|
||||||
|
|
||||||
final class Environment
|
|
||||||
extends \Dotenv\Dotenv
|
|
||||||
{ }
|
|
||||||
Reference in New Issue
Block a user