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

EditTask::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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