Code Duplication    Length = 12-12 lines in 9 locations

src/Client.php 9 locations

@@ 221-232 (lines=12) @@
218
        };
219
    }
220
221
    protected static function getMessageEvent(Closure $action)
222
    {
223
        return function (Update $update) use ($action) {
224
            if (!$update->getMessage()) {
225
                return true;
226
            }
227
228
            $reflectionAction = new ReflectionFunction($action);
229
            $reflectionAction->invokeArgs([$update->getMessage()]);
230
            return false;
231
        };
232
    }
233
234
    protected static function getEditedMessageEvent(Closure $action)
235
    {
@@ 234-245 (lines=12) @@
231
        };
232
    }
233
234
    protected static function getEditedMessageEvent(Closure $action)
235
    {
236
        return function (Update $update) use ($action) {
237
            if (!$update->getEditedMessage()) {
238
                return true;
239
            }
240
241
            $reflectionAction = new ReflectionFunction($action);
242
            $reflectionAction->invokeArgs([$update->getEditedMessage()]);
243
            return false;
244
        };
245
    }
246
247
    protected static function getChannelPostEvent(Closure $action)
248
    {
@@ 247-258 (lines=12) @@
244
        };
245
    }
246
247
    protected static function getChannelPostEvent(Closure $action)
248
    {
249
        return function (Update $update) use ($action) {
250
            if (!$update->getChannelPost()) {
251
                return true;
252
            }
253
254
            $reflectionAction = new ReflectionFunction($action);
255
            $reflectionAction->invokeArgs([$update->getChannelPost()]);
256
            return false;
257
        };
258
    }
259
260
    protected static function getCallbackQueryEvent(Closure $action)
261
    {
@@ 260-271 (lines=12) @@
257
        };
258
    }
259
260
    protected static function getCallbackQueryEvent(Closure $action)
261
    {
262
        return function (Update $update) use ($action) {
263
            if (!$update->getCallbackQuery()) {
264
                return true;
265
            }
266
267
            $reflectionAction = new ReflectionFunction($action);
268
            $reflectionAction->invokeArgs([$update->getCallbackQuery()]);
269
            return false;
270
        };
271
    }
272
273
    protected static function getEditedChannelPostEvent(Closure $action)
274
    {
@@ 273-284 (lines=12) @@
270
        };
271
    }
272
273
    protected static function getEditedChannelPostEvent(Closure $action)
274
    {
275
        return function (Update $update) use ($action) {
276
            if (!$update->getEditedChannelPost()) {
277
                return true;
278
            }
279
280
            $reflectionAction = new ReflectionFunction($action);
281
            $reflectionAction->invokeArgs([$update->getEditedChannelPost()]);
282
            return false;
283
        };
284
    }
285
286
    protected static function getInlineQueryEvent(Closure $action)
287
    {
@@ 286-297 (lines=12) @@
283
        };
284
    }
285
286
    protected static function getInlineQueryEvent(Closure $action)
287
    {
288
        return function (Update $update) use ($action) {
289
            if (!$update->getInlineQuery()) {
290
                return true;
291
            }
292
293
            $reflectionAction = new ReflectionFunction($action);
294
            $reflectionAction->invokeArgs([$update->getInlineQuery()]);
295
            return false;
296
        };
297
    }
298
299
    protected static function getChosenInlineResultEvent(Closure $action)
300
    {
@@ 299-310 (lines=12) @@
296
        };
297
    }
298
299
    protected static function getChosenInlineResultEvent(Closure $action)
300
    {
301
        return function (Update $update) use ($action) {
302
            if (!$update->getChosenInlineResult()) {
303
                return true;
304
            }
305
306
            $reflectionAction = new ReflectionFunction($action);
307
            $reflectionAction->invokeArgs([$update->getChosenInlineResult()]);
308
            return false;
309
        };
310
    }
311
312
    protected static function getShippingQueryEvent(Closure $action)
313
    {
@@ 312-323 (lines=12) @@
309
        };
310
    }
311
312
    protected static function getShippingQueryEvent(Closure $action)
313
    {
314
        return function (Update $update) use ($action) {
315
            if (!$update->getShippingQuery()) {
316
                return true;
317
            }
318
319
            $reflectionAction = new ReflectionFunction($action);
320
            $reflectionAction->invokeArgs([$update->getShippingQuery()]);
321
            return false;
322
        };
323
    }
324
325
    protected static function getPreCheckoutQueryEvent(Closure $action)
326
    {
@@ 325-336 (lines=12) @@
322
        };
323
    }
324
325
    protected static function getPreCheckoutQueryEvent(Closure $action)
326
    {
327
        return function (Update $update) use ($action) {
328
            if (!$update->getPreCheckoutQuery()) {
329
                return true;
330
            }
331
332
            $reflectionAction = new ReflectionFunction($action);
333
            $reflectionAction->invokeArgs([$update->getPreCheckoutQuery()]);
334
            return false;
335
        };
336
    }
337
338
    /**
339
     * Returns check function to handling the command.