Code Duplication    Length = 17-18 lines in 2 locations

src/Test/Proxy/AbstractProxy.php 2 locations

@@ 32-48 (lines=17) @@
29
     *
30
     * @throws \RuntimeException If proxy is not reachable within timeout
31
     */
32
    protected function waitFor($ip, $port, $timeout)
33
    {
34
        if (!$this->wait(
35
            $timeout,
36
            function () use ($ip, $port) {
37
                return true == @fsockopen($ip, $port);
38
            }
39
        )) {
40
            throw new \RuntimeException(
41
                sprintf(
42
                    'Caching proxy cannot be reached at %s:%s',
43
                    $ip,
44
                    $port
45
                )
46
            );
47
        }
48
    }
49
50
    /**
51
     * Wait for caching proxy to be started up and reachable
@@ 59-76 (lines=18) @@
56
     *
57
     * @throws \RuntimeException If proxy is not reachable within timeout
58
     */
59
    protected function waitUntil($ip, $port, $timeout)
60
    {
61
        if (!$this->wait(
62
            $timeout,
63
            function () use ($ip, $port) {
64
                // This doesn't seem to work
65
                return false == @fsockopen($ip, $port);
66
            }
67
        )) {
68
            throw new \RuntimeException(
69
                sprintf(
70
                    'Caching proxy still up at %s:%s',
71
                    $ip,
72
                    $port
73
                )
74
            );
75
        }
76
    }
77
78
    protected function wait($timeout, $callback)
79
    {