Conditions::buildConditions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace mindplay\sql\model\components;
4
5
use mindplay\sql\model\expr;
6
7
/**
8
 * This trait implements query conditions for the `WHERE` clause.
9
 */
10
trait Conditions
11
{
12
    /**
13
     * @var string[] list of condition expressions to apply to the WHERE clause
14
     */
15
    protected array $conditions = [];
16
17
    /**
18
     * @param string|string[] $exprs one or more condition expressions to apply to the WHERE clause
19
     *
20
     * @return $this
21
     */
22 1
    public function where(string|array $exprs): static
23
    {
24 1
        foreach ((array) $exprs as $expr) {
25 1
            $this->conditions[] = $expr;
26
        }
27
28 1
        return $this;
29
    }
30
31
    /**
32
     * @return string combined condition expression (for use in the WHERE clause of an SQL statement)
33
     */
34 1
    protected function buildConditions(): string
35
    {
36 1
        return expr::all($this->conditions);
37
    }
38
}
39