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

DnsDock   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 22 1
A __construct() 0 9 1
1
<?php
2
3
namespace Dock\Doctor;
4
5
use Dock\IO\ProcessRunner;
6
use Dock\Installer\InstallerTask;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class DnsDock extends Task
10
{
11
    /**
12
     * @var InstallerTask
13
     */
14
    private $dnsDockInstaller;
15
16
    /**
17
     * @var InstallerTask
18
     */
19
    private $dockerRouting;
20
21
    /**
22
     * @param ProcessRunner $processRunner
23
     * @param InstallerTask $dnsDockInstaller
24
     * @param InstallerTask $dockerRouting
25
     */
26
    public function __construct(
27
        ProcessRunner $processRunner,
28
        InstallerTask $dnsDockInstaller,
29
        InstallerTask $dockerRouting)
30
    {
31
        $this->processRunner = $processRunner;
32
        $this->dnsDockInstaller = $dnsDockInstaller;
33
        $this->dockerRouting = $dockerRouting;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function run(OutputInterface $output, $dryRun)
40
    {
41
        $this->handle(
42
            $output,
43
            'test 0 -lt `docker ps -q --filter=name=dnsdock | wc -l`',
44
            'Dnsdock container is running',
45
            'It seems dnsdock is not running.',
46
            'Install and start dnsdock by running: `dock-cli docker:install`',
47
            $this->dnsDockInstaller,
48
            $dryRun
49
        );
50
51
        $this->handle(
52
            $output,
53
            'ping -c1 dnsdock.docker',
54
            'Can ping dnsdock container using its domain name',
55
            'It seems your DNS is not set up properly.',
56
            'Add 172.17.42.1 as one of your DNS servers. `dock-cli docker:install` will try to do that',
57
            $this->dockerRouting,
58
            $dryRun
59
        );
60
    }
61
}
62