Passed
Push — master ( f4b60f...a7ff9b )
by Brice
05:36
created

EditTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 45.45%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 29
ccs 5
cts 11
cp 0.4545
rs 10
c 0
b 0
f 0

2 Methods

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