QueryBuilder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 32
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A where() 0 20 4
A normalizePredicate() 0 8 2
1
<?php
2
3
namespace Reduce\Db\Query;
4
5
use Doctrine\DBAL\Query\QueryBuilder as DBALQueryBuilder;
6
7
class QueryBuilder extends DBALQueryBuilder
8
{
9 6
    public function where($predicate, $value = null)
10
    {
11 6
        if ($value) {
12 5
            $this->andWhere($this->normalizePredicate($predicate));
13 5
            $this->createPositionalParameter($value);
14 5
            return $this;
15
        }
16
        
17 2
        if (is_array($predicate)) {
18 1
            foreach ($predicate as $key => $value) {
19 1
                $this->where($this->normalizePredicate($key), $value);
20
            }
21
22 1
            return $this;
23
        }
24
25 1
        $this->andWhere($predicate);
26
        
27 1
        return $this;
28
    }
29
    
30 5
    protected function normalizePredicate($predicate)
31
    {
32 5
        if (strpos($predicate, '?') === false) {
33 3
            $predicate .= ' = ?';
34
        }
35
        
36 5
        return $predicate;
37
    }
38
}
39