Set   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A name() 0 3 1
A __construct() 0 8 2
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
}