Passed
Push — main ( 48955e...53f2e5 )
by Daniel
04:08
created

CatalogDeletionCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 23
ccs 15
cts 15
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A execute() 0 3 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 Ahc\Cli\IO\Interactor;
9
use Psr\Container\ContainerInterface;
10
use Uxmp\Core\Component\Catalog\Manage\CatalogDeleterInterface;
11
12
/**
13
 * Provides a CLI command for catalog deletion
14
 */
15
final class CatalogDeletionCommand extends Command
16
{
17 1
    public function __construct(
18
        private readonly ContainerInterface $dic
19
    ) {
20 1
        parent::__construct(
21 1
            'catalog:delete',
22 1
            'Deletes the catalog'
23 1
        );
24
25 1
        $this
26 1
            ->argument(
27 1
                '<catalogId>',
28 1
                'Id of the catalog'
29 1
            )
30 1
            ->usage(
31 1
                '<bold>  $0 cd 666</end> <comment></end> ## Delete the catalog with id `666`<eol/>'
32 1
            );
33
    }
34
35 1
    public function execute(?int $catalogId): void
36
    {
37 1
        $this->dic->get(CatalogDeleterInterface::class)->delete(new Interactor(), catalogId: (int) $catalogId);
38
    }
39
}
40