RawFunction::parse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of Hydrogen package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace RDS\Hydrogen\Fun;
11
12
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
13
use Doctrine\ORM\Query\AST\Literal;
14
use Doctrine\ORM\Query\Lexer;
15
use Doctrine\ORM\Query\Parser;
16
use Doctrine\ORM\Query\SqlWalker;
17
18
/**
19
 * Class RawFunction
20
 */
21
class RawFunction extends FunctionNode
22
{
23
    /**
24
     * @var Literal
25
     */
26
    private $expr;
27
28
    /**
29
     * @param Parser $parser
30
     */
31
    public function parse(Parser $parser): void
32
    {
33
        $parser->match(Lexer::T_IDENTIFIER);
34
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
35
        $this->expr = $parser->StringPrimary();
36
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
37
    }
38
39
    /**
40
     * @param SqlWalker $sqlWalker
41
     * @return string
42
     */
43
    public function getSql(SqlWalker $sqlWalker): string
44
    {
45
        return $this->expr->value;
46
    }
47
}
48