TaskCompleteCommand   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A configure() 0 11 2
A execute() 0 17 3
1
<?php
2
3
namespace Cli\CliBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Exception\InvalidArgumentException;
7
use Symfony\Component\Console\Exception\LogicException;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use Todo\Application\Task\Command;
13
use Todo\Application\Task\Exception\TaskCannotBeSavedException;
14
use Todo\Domain\Exception\TaskNameIsAlreadyExistedException;
15
use Todo\Domain\Exception\TaskNameIsEmptyException;
16
use Todo\Domain\Exception\TaskNotFoundException;
17
18
/**
19
 * Class TaskCompleteCommand
20
 *
21
 * @category None
22
 * @package  Cli\CliBundle\Command
23
 * @author   Martin Pham <[email protected]>
24
 * @license  None http://
25
 * @link     None
26
 */
27
class TaskCompleteCommand extends ContainerAwareCommand
28
{
29
    /**
30
     * TaskCommand
31
     *
32
     * @var Command
33
     */
34
    protected $taskCommand;
35
36
    /**
37
     * TaskListCommand constructor
38
     *
39
     * @param Command $taskCommand Task Command
40
     *
41
     * @throws LogicException
42
     */
43
    public function __construct(Command $taskCommand)
44
    {
45
        $this->taskCommand = $taskCommand;
46
47
        try {
48
            parent::__construct();
49
        } catch (LogicException $e) {
0 ignored issues
show
Bug introduced by
The class Symfony\Component\Console\Exception\LogicException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
50
            throw $e;
51
        }
52
    }
53
54
    /**
55
     * Configure
56
     *
57
     * @return void
58
     * @throws InvalidArgumentException
59
     */
60
    protected function configure()
61
    {
62
        try {
63
            $this
64
                ->setName('task:complete')
65
                ->setDescription('...')
66
                ->addArgument('id', InputArgument::REQUIRED, 'Task ID');
67
        } catch (InvalidArgumentException $e) {
0 ignored issues
show
Bug introduced by
The class Symfony\Component\Consol...nvalidArgumentException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
68
            // no catch exception
69
        }
70
    }
71
72
    /**
73
     * Execute
74
     *
75
     * @param InputInterface  $input
76
     * @param OutputInterface $output
77
     *
78
     * @return void
79
     * @throws TaskNotFoundException
80
     * @throws TaskCannotBeSavedException
81
     * @throws InvalidArgumentException
82
     */
83
    protected function execute(InputInterface $input, OutputInterface $output)
84
    {
85
        try {
86
            $taskId = $input->getArgument('id');
87
        } catch (InvalidArgumentException $e) {
0 ignored issues
show
Bug introduced by
The class Symfony\Component\Consol...nvalidArgumentException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
88
            throw $e;
89
        }
90
91
        try {
92
            $this->taskCommand->completeTask($taskId);
93
94
            $output->writeln('Task marked completed');
95
        } catch (TaskNotFoundException | TaskCannotBeSavedException $e) {
96
            throw $e;
97
        }
98
99
    }
100
101
}
102