Code Duplication    Length = 20-20 lines in 2 locations

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

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