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

Conditions::buildConditions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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