Code Duplication    Length = 35-35 lines in 2 locations

src/DB.php 2 locations

@@ 619-653 (lines=35) @@
616
     * @return bool If the insert was successful
617
     * @throws TelegramException
618
     */
619
    public static function insertInlineQueryRequest(InlineQuery $inline_query)
620
    {
621
        if (!self::isDbConnected()) {
622
            return false;
623
        }
624
625
        try {
626
            $sth = self::$pdo->prepare('
627
                INSERT IGNORE INTO `' . TB_INLINE_QUERY . '`
628
                (`id`, `user_id`, `location`, `query`, `offset`, `created_at`)
629
                VALUES
630
                (:id, :user_id, :location, :query, :offset, :created_at)
631
            ');
632
633
            $date    = self::getTimestamp();
634
            $user_id = null;
635
636
            $user = $inline_query->getFrom();
637
            if ($user instanceof User) {
638
                $user_id = $user->getId();
639
                self::insertUser($user, $date);
640
            }
641
642
            $sth->bindValue(':id', $inline_query->getId());
643
            $sth->bindValue(':user_id', $user_id);
644
            $sth->bindValue(':location', $inline_query->getLocation());
645
            $sth->bindValue(':query', $inline_query->getQuery());
646
            $sth->bindValue(':offset', $inline_query->getOffset());
647
            $sth->bindValue(':created_at', $date);
648
649
            return $sth->execute();
650
        } catch (PDOException $e) {
651
            throw new TelegramException($e->getMessage());
652
        }
653
    }
654
655
    /**
656
     * Insert chosen inline result request into database
@@ 663-697 (lines=35) @@
660
     * @return bool If the insert was successful
661
     * @throws TelegramException
662
     */
663
    public static function insertChosenInlineResultRequest(ChosenInlineResult $chosen_inline_result)
664
    {
665
        if (!self::isDbConnected()) {
666
            return false;
667
        }
668
669
        try {
670
            $sth = self::$pdo->prepare('
671
                INSERT INTO `' . TB_CHOSEN_INLINE_RESULT . '`
672
                (`result_id`, `user_id`, `location`, `inline_message_id`, `query`, `created_at`)
673
                VALUES
674
                (:result_id, :user_id, :location, :inline_message_id, :query, :created_at)
675
            ');
676
677
            $date    = self::getTimestamp();
678
            $user_id = null;
679
680
            $user = $chosen_inline_result->getFrom();
681
            if ($user instanceof User) {
682
                $user_id = $user->getId();
683
                self::insertUser($user, $date);
684
            }
685
686
            $sth->bindValue(':result_id', $chosen_inline_result->getResultId());
687
            $sth->bindValue(':user_id', $user_id);
688
            $sth->bindValue(':location', $chosen_inline_result->getLocation());
689
            $sth->bindValue(':inline_message_id', $chosen_inline_result->getInlineMessageId());
690
            $sth->bindValue(':query', $chosen_inline_result->getQuery());
691
            $sth->bindValue(':created_at', $date);
692
693
            return $sth->execute();
694
        } catch (PDOException $e) {
695
            throw new TelegramException($e->getMessage());
696
        }
697
    }
698
699
    /**
700
     * Insert callback query request into database