Conditions   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildConditions() 0 3 1
A where() 0 7 2
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