Completed
Push — master ( 509987...79a3d2 )
by Rasmus
02:45
created

Conditions   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A where() 0 8 2
A buildConditions() 0 4 1
1
<?php
2
3
namespace mindplay\sql\model\components;
4
5
/**
6
 * This trait implements query conditions for the `WHERE` clause.
7
 */
8
trait Conditions
9
{
10
    /**
11
     * @var string[] list of condition expressions to apply to the WHERE clause
12
     */
13
    protected $conditions = [];
14
15
    /**
16
     * @param string|string[] $exprs one or more condition expressions to apply to the WHERE clause
17
     *
18
     * @return $this
19
     */
20 1
    public function where($exprs)
21
    {
22 1
        foreach ((array) $exprs as $expr) {
23 1
            $this->conditions[] = $expr;
24
        }
25
26 1
        return $this;
27
    }
28
29
    /**
30
     * @return string combined condition expression (for use in the WHERE clause of an SQL statement)
31
     */
32 1
    protected function buildConditions()
33
    {
34 1
        return implode(" AND ", $this->conditions);
35
    }
36
}
37