Code Duplication    Length = 13-14 lines in 5 locations

PHPDaemon/Clients/Memcache/Pool.php 5 locations

@@ 33-46 (lines=14) @@
30
     * @callback $onResponse ( )
31
     * @return void
32
     */
33
    public function set($key, $value, $exp = 0, $onResponse = null)
34
    {
35
        $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) {
36
            if (!$conn->connected) {
37
                return;
38
            }
39
            if ($onResponse !== null) {
40
                $conn->onResponse->push($onResponse);
41
                $conn->checkFree();
42
            }
43
44
            $conn->writeln(
45
                'set ' . $this->config->prefix->value . $key . ' 0 ' . $exp . ' '
46
                . mb_orig_strlen($value) . ($onResponse === null ? ' noreply' : '') . "\r\n" . $value
47
            );
48
        });
49
    }
@@ 60-72 (lines=13) @@
57
     * @callback $onResponse ( )
58
     * @return void
59
     */
60
    public function add($key, $value, $exp = 0, $onResponse = null)
61
    {
62
        $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) {
63
            if (!$conn->connected) {
64
                return;
65
            }
66
            if ($onResponse !== null) {
67
                $conn->onResponse->push($onResponse);
68
                $conn->checkFree();
69
            }
70
            $conn->writeln('add ' . $this->config->prefix->value . $key . ' 0 ' . $exp . ' ' . mb_orig_strlen($value)
71
                . ($onResponse === null ? ' noreply' : '') . "\r\n" . $value);
72
        });
73
    }
74
75
    /**
@@ 106-118 (lines=13) @@
103
     * @callback $onResponse ( )
104
     * @return void
105
     */
106
    public function replace($key, $value, $exp = 0, $onResponse = null)
107
    {
108
        $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) {
109
            if (!$conn->connected) {
110
                return;
111
            }
112
            if ($onResponse !== null) {
113
                $conn->onResponse->push($onResponse);
114
                $conn->checkFree();
115
            }
116
            $conn->writeln('replace ' . $this->config->prefix->value . $key . ' 0 ' . $exp . ' ' . mb_orig_strlen($value)
117
                . ($onResponse === null ? ' noreply' : '') . "\r\n" . $value);
118
        });
119
    }
120
121
    /**
@@ 130-142 (lines=13) @@
127
     * @callback $onResponse ( )
128
     * @return void
129
     */
130
    public function append($key, $value, $exp = 0, $onResponse = null)
131
    {
132
        $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) {
133
            if (!$conn->connected) {
134
                return;
135
            }
136
            if ($onResponse !== null) {
137
                $conn->onResponse->push($onResponse);
138
                $conn->checkFree();
139
            }
140
            $conn->writeln('replace ' . $this->config->prefix->value . $key . ' 0 ' . $exp . ' ' . mb_orig_strlen($value)
141
                . ($onResponse === null ? ' noreply' : '') . "\r\n" . $value);
142
        });
143
    }
144
145
    /**
@@ 154-166 (lines=13) @@
151
     * @callback $onResponse ( )
152
     * @return void
153
     */
154
    public function prepend($key, $value, $exp = 0, $onResponse = null)
155
    {
156
        $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) {
157
            if (!$conn->connected) {
158
                return;
159
            }
160
            if ($onResponse !== null) {
161
                $conn->onResponse->push($onResponse);
162
                $conn->setFree(false);
163
            }
164
            $conn->writeln('prepend ' . $this->config->prefix->value . $key . ' 0 ' . $exp . ' ' . mb_orig_strlen($value)
165
                . ($onResponse === null ? ' noreply' : '') . "\r\n" . $value);
166
        });
167
    }
168
169
    /**