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

Update   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 6 1
A set() 0 5 1
A getValues() 0 5 1
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