Passed
Branch master (23c1c2)
by Wanderson
03:02
created

Update::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Win\Repositories\Database\Sql\Builders;
4
5
use Win\Repositories\Database\Sql\Builder;
6
7
/**
8
 * UPDATE ... SET ...
9
 */
10
class Update extends Builder
11
{
12
	public function __toString()
13
	{
14
		return 'UPDATE ' . $this->query->table
15
			. ' SET ' . $this->set()
16
			. $this->query->where
17
			. $this->query->limit;
18
	}
19
20
	/** @return string */
21
	protected function set()
22
	{
23
		return implode(', ', array_map(function ($column) {
24
			return $column . ' = ?';
25
		}, array_keys($this->query->values)));
26
	}
27
28
	public function getValues()
29
	{
30
		return array_merge(
31
			$this->query->values,
32
			$this->query->where->values
33
		);
34
	}
35
}
36