StartCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 53
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A configure() 0 7 1
A execute() 0 15 2
1
<?php
2
3
namespace Dock\Cli;
4
5
use Dock\Docker\Compose\Project;
6
use Dock\Project\ProjectException;
7
use Dock\Project\ProjectManager;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\ArrayInput;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class StartCommand extends Command
14
{
15
    /**
16
     * @var ProjectManager
17
     */
18
    private $projectManager;
19
    /**
20
     * @var Project
21
     */
22
    private $project;
23
24
    /**
25
     * @param ProjectManager $projectManager
26
     * @param Project        $project
27
     */
28
    public function __construct(ProjectManager $projectManager, Project $project)
29
    {
30
        parent::__construct();
31
32
        $this->projectManager = $projectManager;
33
        $this->project = $project;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    protected function configure()
40
    {
41
        $this
42
            ->setName('start')
43
            ->setDescription('Start the project')
44
        ;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        try {
53
            $this->projectManager->start($this->project);
54
        } catch (ProjectException $e) {
55
            $output->writeln('<error>'.$e->getMessage().'</error>');
56
57
            return 1;
58
        }
59
60
        return $this->getApplication()->run(
61
            new ArrayInput(['command' => 'ps']),
62
            $output
63
        );
64
    }
65
}
66