DateFunction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 24
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSql() 0 4 1
A getClassName() 0 3 1
A parse() 0 9 1
1
<?php
2
namespace Hospitalplugin\DQLFunctions;
3
4
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
5
use Doctrine\ORM\Query\SqlWalker;
6
use Doctrine\ORM\Query\Parser;
7
use Doctrine\ORM\Query\Lexer;
8
9
class DateFunction extends FunctionNode
10
{
11
12
    private $arg;
13
14
    public function getSql(SqlWalker $sqlWalker)
15
    {
16
        return sprintf('DATE(%s)', $this->arg->dispatch($sqlWalker));
17
    }
18
19
    public function parse(Parser $parser)
20
    {
21
        $parser->match(Lexer::T_IDENTIFIER);
22
        $parser->match(Lexer::T_OPEN_PARENTHESIS);
23
        
24
        $this->arg = $parser->ArithmeticPrimary();
25
        
26
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
27
    }
28
    
29
    public static function getClassName() {
30
        return "Hospitalplugin\DQLFunctions\DateFunction";
31
    }
32
}