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

UserAddCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 13
c 1
b 0
f 0
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A execute() 0 5 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