IfElse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 1
cbo 4
dl 0
loc 30
ccs 15
cts 15
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 14 1
A getSql() 0 8 1
1
<?php
2
3
namespace Luxifer\DQL\String;
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
 * ConcatWsFunction ::= "IF" "(" ConditionalExpression "," ArithmeticExpression "," ArithmeticExpression ")"
12
 */
13
class IfElse extends FunctionNode
14
{
15
    public $condition;
16
    public $isTrueStatement;
17
    public $isFalseStatement;
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->condition = $parser->ConditionalExpression();
24
25 1
        $parser->match(Lexer::T_COMMA);
26 1
        $this->isTrueStatement = $parser->ArithmeticExpression();
27
28 1
        $parser->match(Lexer::T_COMMA);
29 1
        $this->isFalseStatement = $parser->ArithmeticExpression();
30
31 1
        $parser->match(Lexer::T_CLOSE_PARENTHESIS);
32 1
    }
33
34 1
    public function getSql(SqlWalker $sqlWalker)
35
    {
36
        return 'IF(' .
37 1
            $this->condition->dispatch($sqlWalker) . ', ' .
38 1
            $this->isTrueStatement->dispatch($sqlWalker) . ', ' .
39 1
            $this->isFalseStatement->dispatch($sqlWalker) .
40 1
        ')';
41
    }
42
}
43