Test Failed
Push — master ( 8544d9...bfc40d )
by Alexey
03:04
created

Day::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\DQL;
4
5
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
6
use Doctrine\ORM\Query\Lexer;
7
8
class Day extends FunctionNode
9
{
10
    public $dateExpression;
11
12
    public function parse(\Doctrine\ORM\Query\Parser $parser)
13
    {
14
        $parser->match(Lexer::T_IDENTIFIER);
15
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
16
17
        $this->dateExpression = $parser->ArithmeticPrimary();
18
19
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
20
    }
21
22
    public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
23
    {
24
        return 'date_trunc(\'day\', '.$this->dateExpression->dispatch($sqlWalker).')';
25
    }
26
}