Code Duplication    Length = 20-20 lines in 2 locations

lib/Doctrine/ORM/Query/Parser.php 2 locations

@@ 2731-2750 (lines=20) @@
2728
     *
2729
     * @return \Doctrine\ORM\Query\AST\SimpleArithmeticExpression
2730
     */
2731
    public function SimpleArithmeticExpression()
2732
    {
2733
        $terms = [];
2734
        $terms[] = $this->ArithmeticTerm();
2735
2736
        while (($isPlus = $this->lexer->isNextToken(Lexer::T_PLUS)) || $this->lexer->isNextToken(Lexer::T_MINUS)) {
2737
            $this->match(($isPlus) ? Lexer::T_PLUS : Lexer::T_MINUS);
2738
2739
            $terms[] = $this->lexer->token['value'];
2740
            $terms[] = $this->ArithmeticTerm();
2741
        }
2742
2743
        // Phase 1 AST optimization: Prevent AST\SimpleArithmeticExpression
2744
        // if only one AST\ArithmeticTerm is defined
2745
        if (count($terms) == 1) {
2746
            return $terms[0];
2747
        }
2748
2749
        return new AST\SimpleArithmeticExpression($terms);
2750
    }
2751
2752
    /**
2753
     * ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}*
@@ 2757-2776 (lines=20) @@
2754
     *
2755
     * @return \Doctrine\ORM\Query\AST\ArithmeticTerm
2756
     */
2757
    public function ArithmeticTerm()
2758
    {
2759
        $factors = [];
2760
        $factors[] = $this->ArithmeticFactor();
2761
2762
        while (($isMult = $this->lexer->isNextToken(Lexer::T_MULTIPLY)) || $this->lexer->isNextToken(Lexer::T_DIVIDE)) {
2763
            $this->match(($isMult) ? Lexer::T_MULTIPLY : Lexer::T_DIVIDE);
2764
2765
            $factors[] = $this->lexer->token['value'];
2766
            $factors[] = $this->ArithmeticFactor();
2767
        }
2768
2769
        // Phase 1 AST optimization: Prevent AST\ArithmeticTerm
2770
        // if only one AST\ArithmeticFactor is defined
2771
        if (count($factors) == 1) {
2772
            return $factors[0];
2773
        }
2774
2775
        return new AST\ArithmeticTerm($factors);
2776
    }
2777
2778
    /**
2779
     * ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary