Completed
Push — master ( 95a54c...7178fa )
by Samuel
10:58
created

RestartCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 7 1
A execute() 0 8 2
1
<?php
2
3
namespace Dock\Cli\Docker;
4
5
use Dock\Docker\Machine\Machine;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class RestartCommand extends Command
11
{
12
    /**
13
     * @var Machine
14
     */
15
    private $machine;
16
17
    /**
18
     * @param Machine $machine
19
     */
20
    public function __construct(Machine $machine)
21
    {
22
        parent::__construct();
23
24
        $this->machine = $machine;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function configure()
31
    {
32
        $this
33
            ->setName('docker:restart')
34
            ->setDescription('Restart Docker')
35
        ;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected function execute(InputInterface $input, OutputInterface $output)
42
    {
43
        if ($this->machine->isRunning()) {
44
            $this->machine->stop();
45
        }
46
47
        $this->machine->start();
48
    }
49
}
50