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

DeleteTask::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
crap 2
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