AbstractNullComparisonCondition   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 35
wmc 5
lcom 1
cbo 1
ccs 17
cts 17
cp 1
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A toString() 0 12 2
A isEmpty() 0 4 1
getOperator() 0 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