Passed
Branch master (aecce8)
by Brice
05:03
created

DeleteTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 30
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 11 1
1
<?php
2
3
namespace JobQueue\Application\Console;
4
5
use JobQueue\Application\Utils\CommandTrait;
6
use JobQueue\Domain\Task\Status;
7
use JobQueue\Infrastructure\ServiceContainer;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
final class DeleteTask extends Command
14
{
15
    use CommandTrait;
16
17
    public function configure()
18
    {
19
        $this
20
            ->setName('delete')
21
            ->setDescription('Delete a task')
22
            ->addArgument('identifier', InputArgument::REQUIRED, 'Task UUID identifier')
23
        ;
24
    }
25
26
    /**
27
     *
28
     * @param InputInterface $input
29
     * @param OutputInterface $output
30
     * @return int
31
     */
32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        $identifier = $input->getArgument('identifier');
35
36
        ServiceContainer::getInstance()
37
            ->queue
38
            ->delete($identifier);
39
40
        $this->formatInfoSection(sprintf('Task %s deleted', $identifier), $output);
41
42
        return 0;
43
    }
44
}
45