Failed Conditions
Pull Request — develop (#6947)
by Filippo
10:01
created

AbsFunction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSql() 0 5 1
A parse() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Query\AST\Functions;
6
7
use Doctrine\ORM\Query\Lexer;
8
9
/**
10
 * "ABS" "(" SimpleArithmeticExpression ")"
11
 *
12
 * 
13
 * @link    www.doctrine-project.org
14
 * @since   2.0
15
 * @author  Guilherme Blanco <[email protected]>
16
 * @author  Jonathan Wage <[email protected]>
17
 * @author  Roman Borschel <[email protected]>
18
 * @author  Benjamin Eberlei <[email protected]>
19
 */
20
class AbsFunction extends FunctionNode
21
{
22
    /**
23
     * @var \Doctrine\ORM\Query\AST\SimpleArithmeticExpression
24
     */
25
    public $simpleArithmeticExpression;
26
27
    /**
28
     * @override
29
     * @inheritdoc
30
     */
31 1
    public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
32
    {
33 1
        return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression(
34 1
            $this->simpleArithmeticExpression
35 1
        ) . ')';
36
    }
37
38
    /**
39
     * @override
40
     * @inheritdoc
41
     */
42 1
    public function parse(\Doctrine\ORM\Query\Parser $parser)
43
    {
44 1
        $parser->match(Lexer::T_IDENTIFIER);
45 1
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
46
47 1
        $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
48
49 1
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
50 1
    }
51
}
52