Compare commits
6 Commits
7ead9be8e0
...
ff5aeeacef
| Author | SHA1 | Date | |
|---|---|---|---|
| ff5aeeacef | |||
| e34c7f6769 | |||
| e41b8d6ff5 | |||
| 65690c75c8 | |||
| a882152935 | |||
| 232ad6b0d0 |
@@ -0,0 +1,3 @@
|
|||||||
|
composer.lock
|
||||||
|
/nbproject/
|
||||||
|
/vendor/
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "potter/environment",
|
||||||
|
"type": "library",
|
||||||
|
"license": "MIT",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Potter\\Environment\\": "src/Potter/Environment/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jay Potter",
|
||||||
|
"email": "j@ypotter.ca"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"require": {
|
||||||
|
"graham-campbell/result-type": ">=1.1.4",
|
||||||
|
"phpoption/phpoption": ">=1.9.5",
|
||||||
|
"potter/container": ">=0.0.1",
|
||||||
|
"symfony/polyfill-ctype": ">=1.37.0",
|
||||||
|
"symfony/polyfill-mbstring": ">=1.38.2",
|
||||||
|
"symfony/polyfill-php80": ">=1.37.0",
|
||||||
|
"vlucas/phpdotenv": ">=5.6.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter\Environment;
|
||||||
|
|
||||||
|
final class Environment
|
||||||
|
extends \Dotenv\Dotenv
|
||||||
|
{ }
|
||||||
Reference in New Issue
Block a user