From 249cc2f9e78743319de6c3040a216a6c2fbdc4db Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 12 Nov 2023 09:56:42 +0100 Subject: [PATCH] Extract helper method --- .../Foundation/Internal/LoadConfiguration.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/framework/src/Foundation/Internal/LoadConfiguration.php b/packages/framework/src/Foundation/Internal/LoadConfiguration.php index 0e7aa8eb502..5060e292871 100644 --- a/packages/framework/src/Foundation/Internal/LoadConfiguration.php +++ b/packages/framework/src/Foundation/Internal/LoadConfiguration.php @@ -83,15 +83,8 @@ private function loadRuntimeConfiguration(Application $app, RepositoryContract $ { if ($app->runningInConsole()) { if ($this->getArgv() !== null) { - // Check if the `--pretty-urls` CLI argument is set, and if so, set the config value accordingly. - if (in_array('--pretty-urls', $this->getArgv(), true)) { - $repository->set('hyde.pretty_urls', true); - } - - // Check if the `--no-api` CLI argument is set, and if so, set the config value accordingly. - if (in_array('--no-api', $this->getArgv(), true)) { - $repository->set('hyde.api_calls', false); - } + $this->mergeCommandLineArguments($repository, '--pretty-urls', 'hyde.pretty_urls'); + $this->mergeCommandLineArguments($repository, '--no-api', 'hyde.api_calls'); } $this->mergeRealtimeCompilerEnvironment($repository, 'HYDE_SERVER_DASHBOARD', 'hyde.server.dashboard.enabled'); @@ -99,6 +92,13 @@ private function loadRuntimeConfiguration(Application $app, RepositoryContract $ } } + private function mergeCommandLineArguments(RepositoryContract $repository, string $argumentName, string $configKey): void + { + if (in_array($argumentName, $this->getArgv(), true)) { + $repository->set($configKey, true); + } + } + private function mergeRealtimeCompilerEnvironment(RepositoryContract $repository, string $environmentKey, string $configKey): void { if ($this->getEnv($environmentKey) !== false) {