Code Duplication    Length = 27-32 lines in 2 locations

lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php 1 location

@@ 35-66 (lines=32) @@
32
 * @author  Roman Borschel <[email protected]>
33
 * @author  Benjamin Eberlei <[email protected]>
34
 */
35
class AbsFunction extends FunctionNode
36
{
37
    /**
38
     * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression
39
     */
40
    public $simpleArithmeticExpression;
41
42
    /**
43
     * @override
44
     * @inheritdoc
45
     */
46
    public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
47
    {
48
        return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression(
49
            $this->simpleArithmeticExpression
50
        ) . ')';
51
    }
52
53
    /**
54
     * @override
55
     * @inheritdoc
56
     */
57
    public function parse(\Doctrine\ORM\Query\Parser $parser)
58
    {
59
        $parser->match(Lexer::T_IDENTIFIER);
60
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
61
62
        $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
63
64
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
65
    }
66
}
67

tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php 1 location

@@ 2314-2340 (lines=27) @@
2311
    }
2312
}
2313
2314
class MyAbsFunction extends FunctionNode
2315
{
2316
    public $simpleArithmeticExpression;
2317
2318
    /**
2319
     * @override
2320
     */
2321
    public function getSql(SqlWalker $sqlWalker)
2322
    {
2323
        return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) . ')';
2324
    }
2325
2326
    /**
2327
     * @override
2328
     */
2329
    public function parse(Parser $parser)
2330
    {
2331
        $lexer = $parser->getLexer();
2332
2333
        $parser->match(Lexer::T_IDENTIFIER);
2334
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
2335
2336
        $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
2337
2338
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
2339
    }
2340
}
2341
/**
2342
 * @Entity
2343
 */