Code Duplication    Length = 12-12 lines in 3 locations

src/Checker/Gateway.php 1 location

@@ 48-59 (lines=12) @@
45
     * @throws FailException
46
     * @throws SuccessException
47
     */
48
    protected function testExists($target, $expectExists, array $task)
49
    {
50
        $success = $this->curl($target, []);
51
52
        if ($success === $expectExists) {
53
            throw new SuccessException('Ok', $task);
54
        }
55
56
        $msg = $expectExists ? "Target '{$target}' is not available'" : "Target '{$target}' is available";
57
58
        throw new FailException($msg, $task);
59
    }
60
}
61

src/Checker/Service.php 2 locations

@@ 49-60 (lines=12) @@
46
     * @throws FailException
47
     * @throws SuccessException
48
     */
49
    protected function testExists($name, $expectExists, array $task)
50
    {
51
        $output = $this->runCommand("which {$name}");
52
53
        if (!empty($output) === $expectExists) {
54
            throw new SuccessException('Ok', $task);
55
        }
56
57
        $msg = $expectExists ? "Service '{$name}' is not exists'" : "Service '{$name}' is exists";
58
59
        throw new FailException($msg, $task);
60
    }
61
62
    /**
63
     * @param string  $name
@@ 70-81 (lines=12) @@
67
     * @throws FailException
68
     * @throws SuccessException
69
     */
70
    protected function testWhich($name, $expectWhich, array $task)
71
    {
72
        $output = $this->runCommand("which {$name}");
73
74
        if ($output === $expectWhich) {
75
            throw new SuccessException('Ok', $task);
76
        }
77
78
        $msg = "Service '{$name}' expected: '{$expectWhich}', but have {$output}";
79
80
        throw new FailException($msg, $task);
81
    }
82
83
    /**
84
     * @param string $name