Code Duplication    Length = 16-16 lines in 2 locations

src/Api.php 2 locations

@@ 1373-1388 (lines=16) @@
1370
     *
1371
     * @return bool
1372
     */
1373
    public function isMessageType($type, $object)
1374
    {
1375
        if ($object === null) {
1376
            return null;
1377
        }
1378
        
1379
        if ($object instanceof Update) {
1380
            if ($object->has('message')) {
1381
                $object = $object->getMessage();
1382
            }else{
1383
                throw new \InvalidArgumentException('The object must be or contain a message');
1384
            }
1385
        }
1386
        
1387
        return $object->isType($type);
1388
    }
1389
1390
    /**
1391
     * Detect Message Type Based on Update or Message Object.
@@ 1402-1417 (lines=16) @@
1399
     *
1400
     * @return string|null
1401
     */
1402
    public function detectMessageType($object)
1403
    {
1404
        if ($object === null) {
1405
            return null;
1406
        }
1407
        
1408
        if ($object instanceof Update) {
1409
            if ($object->has('message')) {
1410
                $object = $object->getMessage();
1411
            } else {
1412
                throw new \InvalidArgumentException('The object must be or contain a message');
1413
            }
1414
        }
1415
1416
        return $object->detectType();
1417
    }
1418
1419
    /**
1420
     * Sends a GET request to Telegram Bot API and returns the result.