Failed Conditions
Pull Request — develop (#6947)
by Filippo
10:01
created

DateDiffFunction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSql() 0 5 1
A parse() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Query\AST\Functions;
6
7
use Doctrine\ORM\Query\Lexer;
8
use Doctrine\ORM\Query\SqlWalker;
9
use Doctrine\ORM\Query\Parser;
10
11
/**
12
 * "DATE_DIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")"
13
 *
14
 * 
15
 * @link    www.doctrine-project.org
16
 * @since   2.0
17
 * @author  Benjamin Eberlei <[email protected]>
18
 */
19
class DateDiffFunction extends FunctionNode
20
{
21
    public $date1;
22
    public $date2;
23
24
    /**
25
     * @override
26
     * @inheritdoc
27
     */
28 1
    public function getSql(SqlWalker $sqlWalker)
29
    {
30 1
        return $sqlWalker->getConnection()->getDatabasePlatform()->getDateDiffExpression(
31 1
            $this->date1->dispatch($sqlWalker),
32 1
            $this->date2->dispatch($sqlWalker)
33
        );
34
    }
35
36
    /**
37
     * @override
38
     * @inheritdoc
39
     */
40 1
    public function parse(Parser $parser)
41
    {
42 1
        $parser->match(Lexer::T_IDENTIFIER);
43 1
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
44
45 1
        $this->date1 = $parser->ArithmeticPrimary();
46 1
        $parser->match(Lexer::T_COMMA);
47 1
        $this->date2 = $parser->ArithmeticPrimary();
48
49 1
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
50 1
    }
51
}
52