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

Where   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 40
rs 10
c 1
b 0
f 1
wmc 7
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A filter() 0 9 3
A toSql() 0 6 2
A values() 0 3 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