AbstractNullComparisonCondition::isEmpty()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Muffin\Conditions;
4
5
use Muffin\Escaper;
6
use Muffin\Type;
7
8
abstract class AbstractNullComparisonCondition extends AbstractCondition
9
{
10
    private
11
        $column;
12
13 17
    public function __construct($column)
14
    {
15 17
        if($column instanceof Type)
16 17
        {
17 5
            $column = $column->getName();
18 5
        }
19
20 17
        $this->column = (string) $column;
21 17
    }
22
23 9
    public function toString(Escaper $escaper)
24
    {
25 9
        if(empty($this->column))
26 9
        {
27 4
            return '';
28
        }
29
30 5
        return sprintf('%s %s',
31 5
            $this->column,
32 5
            $this->getOperator()
33 5
        );
34
    }
35
36 8
    public function isEmpty()
37
    {
38 8
        return empty($this->column);
39
    }
40
41
    abstract protected function getOperator();
42
}
43