diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..86da81e1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +* text=auto eol=lf + +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php + +/.github export-ignore +/tests export-ignore +CHANGELOG.md export-ignore +phpstan.neon export-ignore +phpstan-baseline.neon export-ignore +phpunit.xml.dist export-ignore +rector.php export-ignore +sonar-project.properties export-ignore diff --git a/src/functions.php b/src/functions.php index 0f25cf0d..5cdac918 100644 --- a/src/functions.php +++ b/src/functions.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Phenix\App; +use Phenix\Facades\Config; use Phenix\Facades\Log; use Phenix\Facades\Translator; use Phenix\Http\Response; @@ -40,6 +41,13 @@ function env(string $key, Closure|null $default = null): array|string|float|int| } } +if (! function_exists('config')) { + function config(string $key, mixed $default = null): mixed + { + return Config::get($key, $default); + } +} + if (! function_exists('value')) { function value($value, ...$args) { diff --git a/tests/Unit/Runtime/ConfigTest.php b/tests/Unit/Runtime/ConfigTest.php index 11cd9d32..446d5657 100644 --- a/tests/Unit/Runtime/ConfigTest.php +++ b/tests/Unit/Runtime/ConfigTest.php @@ -18,3 +18,9 @@ expect($config->get('app.name'))->toBe('PHPhenix'); }); + +it('retrieve configurations from global config helper function', function (): void { + config('app.name', 'DefaultApp'); + + expect(config('app.name'))->toBe('Phenix'); +});