Skip to content

Commit

Permalink
Merge pull request #87 from sdkakcy/main
Browse files Browse the repository at this point in the history
Arrange `ContributorCommand` to get correct role value
  • Loading branch information
MohmmedAshraf authored Mar 9, 2024
2 parents debaa3f + 67eff42 commit 025c4ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Console/Commands/ContributorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
$input->setArgument('role', select(
label: 'What role should the contributor have?',
options: [
RoleEnum::owner->value => RoleEnum::owner->label(),
RoleEnum::translator->value => RoleEnum::translator->label(),
RoleEnum::owner->label() => RoleEnum::owner->label(),
RoleEnum::translator->label() => RoleEnum::translator->label(),
],
default: 'Owner',
default: RoleEnum::owner->label(),
hint: 'The role may be changed at any time.'
));
}
Expand Down Expand Up @@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
fn () => Contributor::create([
'name' => $name,
'email' => $email,
'role' => RoleEnum::fromLabel($role) ?? RoleEnum::owner->value,
'role' => RoleEnum::fromLabel($role),
'password' => Hash::make($password),
]),
'Creating contributor...'
Expand Down
5 changes: 3 additions & 2 deletions src/Enums/RoleEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public function label(): string
public static function fromLabel($label): self
{
return match ($label) {
'Owner' => self::owner,
'Translator' => self::translator,
'Owner', 'owner' => self::owner,
'Translator', 'translator' => self::translator,
default => self::owner,
};
}

Expand Down

0 comments on commit 025c4ca

Please sign in to comment.