Passed
Push — main ( 1b96d5...5ce243 )
by Daniel
04:01
created

UserAddCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Component\Cli;
6
7
use Ahc\Cli\Input\Command;
8
use Psr\Container\ContainerInterface;
9
use Uxmp\Core\Component\Cli\Wizard\UserCreationWizardInterface;
10
11
final class UserAddCommand extends Command
12
{
13 1
    public function __construct(
14
        private ContainerInterface $dic
15
    ) {
16 1
        parent::__construct(
17
            'user:add',
18
            'Adds an user'
19
        );
20
21
        $this
22 1
            ->argument(
23
                '<username>',
24
                'User name'
25
            )
26 1
            ->usage(
27
                '<bold>  $0 ua some-username</end> <comment></end> ## Adds user with name `some-username`<eol/>'
28
            );
29
    }
30
31 1
    public function execute(?string $username): void
32
    {
33 1
        $this->dic->get(UserCreationWizardInterface::class)->create(
34 1
            $this->app()?->io(),
35 1
            (string) $username
36
        );
37
    }
38
}
39