Code Duplication    Length = 16-16 lines in 2 locations

src/Api.php 2 locations

@@ 1262-1277 (lines=16) @@
1259
     *
1260
     * @return bool
1261
     */
1262
    public function isMessageType($type, $object)
1263
    {
1264
        if ($object === null) {
1265
            return null;
1266
        }
1267
        
1268
        if ($object instanceof Update) {
1269
            if ($object->has('message')) {
1270
                $object = $object->getMessage();
1271
            }else{
1272
                throw new \InvalidArgumentException('The object must be or contain a message');
1273
            }
1274
        }
1275
        
1276
        return $object->isType($type);
1277
    }
1278
1279
    /**
1280
     * Detect Message Type Based on Update or Message Object.
@@ 1291-1306 (lines=16) @@
1288
     *
1289
     * @return string|null
1290
     */
1291
    public function detectMessageType($object)
1292
    {
1293
        if ($object === null) {
1294
            return null;
1295
        }
1296
        
1297
        if ($object instanceof Update) {
1298
            if ($object->has('message')) {
1299
                $object = $object->getMessage();
1300
            } else {
1301
                throw new \InvalidArgumentException('The object must be or contain a message');
1302
            }
1303
        }
1304
1305
        return $object->detectType();
1306
    }
1307
1308
    /**
1309
     * Sends a GET request to Telegram Bot API and returns the result.