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

SqrtFunction::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
nc 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
 * "SQRT" "(" 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 SqrtFunction 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 $sqlWalker->getConnection()->getDatabasePlatform()->getSqrtExpression(
34 1
            $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression)
35
        );
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