Set::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace HexMakina\Crudites\Grammar\Clause;
4
5
use HexMakina\Crudites\Grammar\Predicate;
6
7
class Set extends Clause
8
{
9
    protected string $alterations = '';
10
11
    public function __construct(array $alterations)
12
    {
13
        parent::__construct();
14
        foreach ($alterations as $field_name => $value) {
15
            $predicate = (new Predicate([$field_name], '='))->withValue($value, 'set_'.$field_name);
16
            
17
            $this->alterations .= $predicate->__toString().',';
18
            $this->bindings = array_merge($this->bindings, $predicate->bindings());
19
        }
20
    }
21
22
    public function __toString(): string
23
    {
24
        return 'SET ' . rtrim($this->alterations, ',');
25
    }
26
27
    public function name(): string
28
    {
29
        return self::SET;
30
    }
31
}