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

RestartCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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