ModifyColumns::hold()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 4
nc 3
nop 2
crap 4
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Sql\Component;
5
6
use Sirius\Sql\Bindings;
7
use Sirius\Sql\Quoter\Quoter;
8
use Sirius\Sql\Raw;
9
10
abstract class ModifyColumns extends Component
11
{
12
    protected $bindings;
13
14
    protected $list = [];
15
16
    protected $quoter;
17
18 2
    public function __construct(Bindings $bindings, Quoter $quoter)
19
    {
20 2
        $this->bindings = $bindings;
21 2
        $this->quoter   = $quoter;
22 2
    }
23
24 2
    public function hasAny(): bool
25
    {
26 2
        return ! empty($this->list);
27
    }
28
29 2
    public function hold(string $column, ...$value): void
30
    {
31 2
        if (! empty($value) && $value[0] instanceof Raw) {
32 1
            $this->list[$column] = (string)$value[0];
33
34 1
            return;
35
        }
36
37 2
        $this->list[$column] = ":{$column}";
38 2
        if (! empty($value)) {
39 2
            $this->bindings->value($column, ...$value);
40
        }
41 2
    }
42
}
43