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

Day   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 9 1
A getSql() 0 4 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
}