From 866ca9a8874226e067e807cb57d538d2bee1f6df Mon Sep 17 00:00:00 2001 From: barbosa89 Date: Sat, 27 Sep 2025 16:49:20 -0500 Subject: [PATCH 1/2] feat: add environment detection methods for local and production --- phpunit.xml.dist | 2 +- src/App.php | 10 ++++++++++ tests/Unit/AppTest.php | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/Unit/AppTest.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 71ce9fb1..2e9b87c4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -27,6 +27,6 @@ - + \ No newline at end of file diff --git a/src/App.php b/src/App.php index 95ded4c7..50b34b1a 100644 --- a/src/App.php +++ b/src/App.php @@ -117,6 +117,16 @@ public static function path(): string return self::$path; } + public static function isLocal(): bool + { + return Config::get('app.env') === 'local'; + } + + public static function isProduction(): bool + { + return Config::get('app.env') === 'production'; + } + public function swap(string $key, object $concrete): void { self::$container->extend($key)->setConcrete($concrete); diff --git a/tests/Unit/AppTest.php b/tests/Unit/AppTest.php new file mode 100644 index 00000000..0b6f4d82 --- /dev/null +++ b/tests/Unit/AppTest.php @@ -0,0 +1,10 @@ +toBeTrue(); + expect(App::isProduction())->toBeFalse(); +}); From c40b57116756656b2d8a04f6d8def65272caabf0 Mon Sep 17 00:00:00 2001 From: barbosa89 Date: Sat, 27 Sep 2025 16:50:27 -0500 Subject: [PATCH 2/2] fix: add missing newline at end of phpunit.xml.dist --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2e9b87c4..13098828 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -29,4 +29,4 @@ - \ No newline at end of file +