Code Duplication    Length = 12-12 lines in 8 locations

src/Client.php 8 locations

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