Completed
Push — master ( 037c01...3910ea )
by Oscar
01:42
created

Update   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace SimpleCrud\Queries;
5
6
use SimpleCrud\Table;
7
8
final class Update extends Query
9
{
10
    use Traits\HasRelatedWith;
11
12
    protected const ALLOWED_METHODS = [
13
        'set',
14
        'setFlag',
15
        'where',
16
        'orWhere',
17
        'catWhere',
18
        'orderBy',
19
        'limit',
20
        'offset',
21
    ];
22
23
    public function __construct(Table $table, array $data = [])
24
    {
25
        $this->table = $table;
26
27
        $this->query = $table->getDatabase()
28
            ->update()
29
            ->table((string) $table);
30
31
        foreach ($data as $fieldName => $value) {
32
            $this->table->{$fieldName}->update($this->query, $value);
33
        }
34
    }
35
}
36