Code Duplication    Length = 9-11 lines in 7 locations

PHPDaemon/Clients/Gearman/Connection.php 7 locations

@@ 151-161 (lines=11) @@
148
     * @param null $context
149
     * @param null $unique
150
     */
151
    public function runJob($function_name, $payload, $unique = null) {
152
153
        if ($unique) {
154
            $unique = uuid_create();
155
        }
156
157
        $cb = func_get_arg(func_num_args() - 1);
158
        $this->jobAwaitResult = true;
159
160
        $this->sendCommand("SUBMIT_JOB", [$function_name, $unique,  $payload], $cb);
161
    }
162
163
    /**
164
     * Function run task and whait result in callback
@@ 171-179 (lines=9) @@
168
     * @param null $context
169
     * @param null $unique
170
     */
171
    public function doNormal($function_name, $payload, $unique = null) {
172
173
        if ($unique) {
174
            $unique = uuid_create();
175
        }
176
177
        $cb = func_get_arg(func_num_args() - 1);
178
        $this->sendCommand("SUBMIT_JOB", [$function_name, $unique,  $payload], $cb);
179
    }
180
181
    /**
182
     * Function run task in background
@@ 189-197 (lines=9) @@
186
     * @param null $context
187
     * @param null $unique
188
     */
189
    public function doBackground($function_name, $payload, $unique = null) {
190
191
        if ($unique) {
192
            $unique = uuid_create();
193
        }
194
195
        $cb = func_get_arg(func_num_args() - 1);
196
        $this->sendCommand("SUBMIT_JOB_BG", [$function_name, $unique,  $payload], $cb);
197
    }
198
199
    /**
200
     * Function run task with high prority
@@ 207-215 (lines=9) @@
204
     * @param null $context
205
     * @param null $unique
206
     */
207
    public function doHigh($function_name, $payload, $unique = null) {
208
209
        if ($unique) {
210
            $unique = uuid_create();
211
        }
212
213
        $cb = func_get_arg(func_num_args() - 1);
214
        $this->sendCommand("SUBMIT_JOB_HIGH", [$function_name, $unique,  $payload], $cb);
215
    }
216
217
    /**
218
     * Function run task in background with high prority
@@ 225-233 (lines=9) @@
222
     * @param null $context
223
     * @param null $unique
224
     */
225
    public function doHighBackground($function_name, $payload, $unique = null) {
226
227
        if ($unique) {
228
            $unique = uuid_create();
229
        }
230
231
        $cb = func_get_arg(func_num_args() - 1);
232
        $this->sendCommand("SUBMIT_JOB_HIGH_BG", [$function_name, $unique,  $payload], $cb);
233
    }
234
235
    /**
236
     * Function run task with low prority
@@ 243-251 (lines=9) @@
240
     * @param null $context
241
     * @param null $unique
242
     */
243
    public function doLow($function_name, $payload, $unique = null) {
244
245
        if ($unique) {
246
            $unique = uuid_create();
247
        }
248
249
        $cb = func_get_arg(func_num_args() - 1);
250
        $this->sendCommand("SUBMIT_JOB_LOW", [$function_name, $unique,  $payload], $cb);
251
    }
252
253
    /**
254
     * Function run task in background with low prority
@@ 261-269 (lines=9) @@
258
     * @param null $context
259
     * @param null $unique
260
     */
261
    public function doLowBackground($function_name, $payload, $unique = null) {
262
263
        if ($unique) {
264
            $unique = uuid_create();
265
        }
266
267
        $cb = func_get_arg(func_num_args() - 1);
268
        $this->sendCommand("SUBMIT_JOB_LOW_BG", [$function_name, $unique,  $payload], $cb);
269
    }
270
271
    /**
272
     * Функция исполняет удаленно таск