Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
32 | 2 | public function update(string $table, array $attributes): self |
|
33 | { |
||
34 | 2 | $this->attributes = $attributes; |
|
35 | |||
36 | 2 | $set = ''; |
|
37 | 2 | $key = array_keys($attributes); |
|
38 | 2 | $pop = array_pop($key); |
|
39 | |||
40 | 2 | foreach ($attributes as $key => $value) { |
|
41 | 2 | $set .= ($key == $pop) ? '' : "`{$key}` = :{$key}, "; |
|
42 | } |
||
43 | |||
44 | 2 | $set .= "`{$pop}` = :{$pop}"; |
|
45 | |||
46 | 2 | $this->statement = "UPDATE `{$table}` SET {$set}"; |
|
47 | |||
48 | 2 | return $this; |
|
49 | } |
||
57 |