Completed
Push — master ( 1337ee...b15437 )
by Wanderson
01:57
created

Where::values()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Win\DAO;
4
5
/**
6
 * Where SQL
7
 * Cria condições SQL
8
 */
9
class Where {
10
11
	private $condition = null;
12
	private $values = [];
13
14
	/** Construtor */
15
	public function __construct() {
16
		$this->condition = null;
17
		$this->values = [];
18
	}
19
20
	/**
21
	 * Adiciona novos filtros
22
	 * @param string $condition
23
	 * @param mixed[] $values
24
	 */
25
	public function filter($condition, $values) {
26
		if (count($values)) {
27
			if (!is_null($this->condition)) {
28
				$this->condition .= ' AND ';
29
			}
30
			$this->condition .= $condition;
31
			$this->values = $this->values + $values;
32
		}
33
	}
34
35
	/** @return string */
36
	public function toSql() {
37
		if (!is_null($this->condition)) {
38
			return ' WHERE ' . $this->condition . ' ';
39
		}
40
		return ' ';
41
	}
42
43
	/** @return mixed[] */
44
	public function values() {
45
		return array_values($this->values);
46
	}
47
48
}
49