Skip to content

Commit 6dba024

Browse files
committed
refactor(configureable): rename 'config' option to 'configuration'
- Renamed 'config' option to 'configuration' in the Configureable trait and related test cases. - Updated option description to clarify its purpose for passing configuration key-value pairs. - Adjusted all references and assertions to align with the new naming convention. - Simplified lambda expressions for improved readability.
1 parent b5677f4 commit 6dba024

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Commands/Concerns/Configureable.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ public function getDefinition(): InputDefinition
3030
{
3131
return tap(parent::getDefinition(), static function (InputDefinition $inputDefinition): void {
3232
$inputDefinition->addOption(new InputOption(
33-
'config',
34-
// 'c',
33+
'configuration',
3534
null,
3635
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
37-
'Configure able (e.g. `--config=app.name=guanguans` or `--config app.name=guanguans` or `-c app.name=guanguans`)',
36+
'Used to dynamically pass one or more configuration key-value pairs(e.g. `--configuration=app.name=guanguans` or `--configuration app.name=guanguans`).',
3837
));
3938
});
4039
}
@@ -43,17 +42,18 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
4342
{
4443
parent::initialize($input, $output);
4544

46-
collect($this->option('config'))
45+
collect($this->option('configuration'))
4746
// ->dump()
48-
->mapWithKeys(static function (string $config): array {
49-
\assert(str_contains($config, '='), "The configureable option [$config] must be formatted as key=value.");
47+
->mapWithKeys(static function (string $configuration): array {
48+
\assert(
49+
str_contains($configuration, '='),
50+
"The configureable option [$configuration] must be formatted as key=value."
51+
);
5052

51-
[$key, $value] = explode('=', $config, 2);
53+
[$key, $value] = explode('=', $configuration, 2);
5254

5355
return [$key => $value];
5456
})
55-
->tap(static function (Collection $config): void {
56-
config($config->all());
57-
});
57+
->tap(static fn (Collection $configuration) => config($configuration->all()));
5858
}
5959
}

tests/Commands/TestCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
artisan(TestCommand::class, [
5454
'--channel' => $channel = 'bark',
5555
'--job-connection' => 'sync',
56-
'--config' => "app.name={$this->faker()->name()}",
56+
'--configuration' => "app.name={$this->faker()->name()}",
5757
'--verbose' => true,
5858
]);
5959
} catch (RuntimeException $runtimeException) {

0 commit comments

Comments
 (0)