Month::parse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace KI\CoreBundle\DQL;
4
5
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
6
use Doctrine\ORM\Query\Lexer;
7
use Doctrine\ORM\Query\Parser;
8
use Doctrine\ORM\Query\SqlWalker;
9
10
/**
11
 * Date ::= "HOUR" "("ArithmeticPrimary")"
12
 */
13 View Code Duplication
class Month extends FunctionNode
14
{
15
    public $dateExpression;
16
17
    public function parse(Parser $parser)
18
    {
19
        $parser->match(Lexer::T_IDENTIFIER);
20
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
21
        $this->dateExpression = $parser->ArithmeticPrimary();
22
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
23
    }
24
25
    public function getSql(SqlWalker $sqlWalker)
26
    {
27
        return 'MONTH(FROM_UNIXTIME('.$this->dateExpression->dispatch($sqlWalker).'))';
28
    }
29
}
30