Code Duplication    Length = 12-12 lines in 8 locations

src/Client.php 8 locations

@@ 188-199 (lines=12) @@
185
        };
186
    }
187
188
    protected static function getEditedMessageEvent(Closure $action)
189
    {
190
        return function (Update $update) use ($action) {
191
            if (!$update->getEditedMessage()) {
192
                return true;
193
            }
194
195
            $reflectionAction = new ReflectionFunction($action);
196
            $reflectionAction->invokeArgs([$update->getEditedMessage()]);
197
            return false;
198
        };
199
    }
200
201
    protected static function getChannelPostEvent(Closure $action)
202
    {
@@ 201-212 (lines=12) @@
198
        };
199
    }
200
201
    protected static function getChannelPostEvent(Closure $action)
202
    {
203
        return function (Update $update) use ($action) {
204
            if (!$update->getChannelPost()) {
205
                return true;
206
            }
207
208
            $reflectionAction = new ReflectionFunction($action);
209
            $reflectionAction->invokeArgs([$update->getChannelPost()]);
210
            return false;
211
        };
212
    }
213
214
    protected static function getCallbackQueryEvent(Closure $action)
215
    {
@@ 214-225 (lines=12) @@
211
        };
212
    }
213
214
    protected static function getCallbackQueryEvent(Closure $action)
215
    {
216
        return function (Update $update) use ($action) {
217
            if (!$update->getCallbackQuery()) {
218
                return true;
219
            }
220
221
            $reflectionAction = new ReflectionFunction($action);
222
            $reflectionAction->invokeArgs([$update->getCallbackQuery()]);
223
            return false;
224
        };
225
    }
226
227
    protected static function getEditedChannelPostEvent(Closure $action)
228
    {
@@ 227-238 (lines=12) @@
224
        };
225
    }
226
227
    protected static function getEditedChannelPostEvent(Closure $action)
228
    {
229
        return function (Update $update) use ($action) {
230
            if (!$update->getEditedChannelPost()) {
231
                return true;
232
            }
233
234
            $reflectionAction = new ReflectionFunction($action);
235
            $reflectionAction->invokeArgs([$update->getEditedChannelPost()]);
236
            return false;
237
        };
238
    }
239
240
    protected static function getInlineQueryEvent(Closure $action)
241
    {
@@ 240-251 (lines=12) @@
237
        };
238
    }
239
240
    protected static function getInlineQueryEvent(Closure $action)
241
    {
242
        return function (Update $update) use ($action) {
243
            if (!$update->getInlineQuery()) {
244
                return true;
245
            }
246
247
            $reflectionAction = new ReflectionFunction($action);
248
            $reflectionAction->invokeArgs([$update->getInlineQuery()]);
249
            return false;
250
        };
251
    }
252
253
    protected static function getChosenInlineResultEvent(Closure $action)
254
    {
@@ 253-264 (lines=12) @@
250
        };
251
    }
252
253
    protected static function getChosenInlineResultEvent(Closure $action)
254
    {
255
        return function (Update $update) use ($action) {
256
            if (!$update->getChosenInlineResult()) {
257
                return true;
258
            }
259
260
            $reflectionAction = new ReflectionFunction($action);
261
            $reflectionAction->invokeArgs([$update->getChosenInlineResult()]);
262
            return false;
263
        };
264
    }
265
266
    protected static function getShippingQueryEvent(Closure $action)
267
    {
@@ 266-277 (lines=12) @@
263
        };
264
    }
265
266
    protected static function getShippingQueryEvent(Closure $action)
267
    {
268
        return function (Update $update) use ($action) {
269
            if (!$update->getShippingQuery()) {
270
                return true;
271
            }
272
273
            $reflectionAction = new ReflectionFunction($action);
274
            $reflectionAction->invokeArgs([$update->getShippingQuery()]);
275
            return false;
276
        };
277
    }
278
279
    protected static function getPreCheckoutQueryEvent(Closure $action)
280
    {
@@ 279-290 (lines=12) @@
276
        };
277
    }
278
279
    protected static function getPreCheckoutQueryEvent(Closure $action)
280
    {
281
        return function (Update $update) use ($action) {
282
            if (!$update->getPreCheckoutQuery()) {
283
                return true;
284
            }
285
286
            $reflectionAction = new ReflectionFunction($action);
287
            $reflectionAction->invokeArgs([$update->getPreCheckoutQuery()]);
288
            return false;
289
        };
290
    }
291
292
    /**
293
     * Returns check function to handling the command.