Completed
Pull Request — 1.1 (#24)
by Charles
09:32
created

In::getOperatorSymbol()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace SQLParser\Node;
4
use Doctrine\DBAL\Connection;
5
use Mouf\Database\MagicQueryException;
6
7
/**
8
 * This class represents an In operation in an SQL expression.
9
 *
10
 * @author David Négrier <[email protected]>
11
 */
12
class In extends AbstractTwoOperandsOperator
13
{
14
    /**
15
     * Returns the symbol for this operator.
16
     *
17
     * @return string
18
     */
19
    protected function getOperatorSymbol()
20
    {
21
        return 'IN';
22
    }
23
24
    protected function getSql(array $parameters = array(), Connection $dbConnection = null, $indent = 0, $conditionsMode = self::CONDITION_APPLY)
25
    {
26
        $rightOperand = $this->getRightOperand();
27
        if ($rightOperand instanceof Parameter) {
28
            if (!isset($parameters[$rightOperand->getName()])) {
29
                throw new MagicQueryException("Missing parameter '" . $rightOperand->getName() . "' for 'IN' operand.");
30
            }
31
            if ($parameters[$rightOperand->getName()] === []) {
32
                return "FALSE";
33
            }
34
        }
35
36
        return parent::getSql($parameters, $dbConnection, $indent, $conditionsMode);
37
    }
38
}
39