Code Duplication    Length = 25-25 lines in 2 locations

PHPDaemon/Clients/HTTP/Pool.php 2 locations

@@ 41-65 (lines=25) @@
38
     * @call  ( url $url, callable $resultcb )
39
     * @callback $resultcb ( Connection $conn, boolean $success )
40
     */
41
    public function head($url, $params)
42
    {
43
        if (is_callable($params)) {
44
            $params = ['resultcb' => $params];
45
        }
46
        if (!isset($params['uri']) || !isset($params['host'])) {
47
            list($params['scheme'], $params['host'], $params['uri'], $params['port']) = static::parseUrl($url);
48
        }
49
        if (isset($params['connect'])) {
50
            $dest = $params['connect'];
51
        } elseif (isset($params['proxy']) && $params['proxy']) {
52
            if ($params['proxy']['type'] === 'http') {
53
                $dest = 'tcp://' . $params['proxy']['addr'];
54
            }
55
        } else {
56
            $dest = 'tcp://' . $params['host'] . (isset($params['port']) ? ':' . $params['port'] : null) . ($params['scheme'] === 'https' ? '#ssl' : '');
57
        }
58
        $this->getConnection($dest, function ($conn) use ($url, $params) {
59
            if (!$conn->isConnected()) {
60
                $params['resultcb'](false);
61
                return;
62
            }
63
            $conn->head($url, $params);
64
        });
65
    }
66
67
68
    /**
@@ 77-101 (lines=25) @@
74
     * @call  ( url $url, callable $resultcb )
75
     * @callback $resultcb ( Connection $conn, boolean $success )
76
     */
77
    public function get($url, $params)
78
    {
79
        if (is_callable($params)) {
80
            $params = ['resultcb' => $params];
81
        }
82
        if (!isset($params['uri']) || !isset($params['host'])) {
83
            list($params['scheme'], $params['host'], $params['uri'], $params['port']) = static::parseUrl($url);
84
        }
85
        if (isset($params['connect'])) {
86
            $dest = $params['connect'];
87
        } elseif (isset($params['proxy']) && $params['proxy']) {
88
            if ($params['proxy']['type'] === 'http') {
89
                $dest = 'tcp://' . $params['proxy']['addr'];
90
            }
91
        } else {
92
            $dest = 'tcp://' . $params['host'] . (isset($params['port']) ? ':' . $params['port'] : null) . ($params['scheme'] === 'https' ? '#ssl' : '');
93
        }
94
        $this->getConnection($dest, function ($conn) use ($url, $params) {
95
            if (!$conn->isConnected()) {
96
                $params['resultcb'](false);
97
                return;
98
            }
99
            $conn->get($url, $params);
100
        });
101
    }
102
103
    /**
104
     * Perform a POST request