Code Duplication    Length = 12-12 lines in 7 locations

src/Client.php 7 locations

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