Completed
Pull Request — master (#8105)
by
unknown
10:29
created

SqrtFunction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 28
ccs 0
cts 12
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSql() 0 4 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\AST\SimpleArithmeticExpression;
8
use Doctrine\ORM\Query\Lexer;
9
use Doctrine\ORM\Query\Parser;
10
use Doctrine\ORM\Query\SqlWalker;
11
12
/**
13
 * "SQRT" "(" SimpleArithmeticExpression ")"
14
 */
15
class SqrtFunction extends FunctionNode
16
{
17
    /** @var SimpleArithmeticExpression */
18
    public $simpleArithmeticExpression;
19
20
    /**
21
     * @override
22
     * @inheritdoc
23
     */
24
    public function getSql(SqlWalker $sqlWalker)
25
    {
26
        return $sqlWalker->getConnection()->getDatabasePlatform()->getSqrtExpression(
27
            $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression)
28
        );
29
    }
30
31
    /**
32
     * @override
33
     * @inheritdoc
34
     */
35
    public function parse(Parser $parser)
36
    {
37
        $parser->match(Lexer::T_IDENTIFIER);
38
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
39
40
        $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression();
41
42
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
43
    }
44
}
45