Compare commits
15 Commits
7ead9be8e0
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ae21edd5bb | |||
| a793b842b1 | |||
| e664b84072 | |||
| 6318a565ec | |||
| 4adc20284c | |||
| 7e2ee30244 | |||
| 622b69f82d | |||
| af5ca24364 | |||
| e0ac5c6e1f | |||
| 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\\": "src/Potter/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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,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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user