DateDiff   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 23
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 9 1
A getSql() 0 7 1
1
<?php
2
3
namespace Luxifer\DQL\Datetime;
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
 * DateFunction ::= "DATEDIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")"
12
 * @author Florent Viel <[email protected]>
13
 */
14
class DateDiff extends FunctionNode
15
{
16
    public $firstDateExpression;
17
    public $secondDateExpression;
18
19 1
    public function parse(Parser $parser)
20
    {
21 1
        $parser->match(Lexer::T_IDENTIFIER);
22 1
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
23 1
        $this->firstDateExpression = $parser->ArithmeticPrimary();
24 1
        $parser->match(Lexer::T_COMMA);
25 1
        $this->secondDateExpression = $parser->ArithmeticPrimary();
26 1
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
27 1
    }
28
29 1
    public function getSql(SqlWalker $sqlWalker)
30
    {
31
        return 'DATEDIFF(' .
32 1
            $this->firstDateExpression->dispatch($sqlWalker) . ', ' .
33 1
            $this->secondDateExpression->dispatch($sqlWalker) .
34 1
        ')';
35
    }
36
}
37