Total Complexity | 8 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
6 | class Donde |
||
7 | { |
||
8 | private $_donde; |
||
9 | private $_datos; |
||
10 | private $_operadoresValidos = [ |
||
11 | '=', |
||
12 | '>', |
||
13 | '<', |
||
14 | '>=', |
||
15 | '<=', |
||
16 | '<>', |
||
17 | '!=', |
||
18 | '!<', |
||
19 | '!>', |
||
20 | ]; |
||
21 | |||
22 | public function __construct(array $Donde) |
||
25 | } |
||
26 | |||
27 | public function donde(): string |
||
30 | } |
||
31 | |||
32 | public function datos(): array |
||
35 | } |
||
36 | |||
37 | private function setDonde(array $columnas): string |
||
38 | { |
||
39 | if(count($columnas) !== 3) |
||
40 | { |
||
41 | throw new Exception("Elementos faltantes o sobrantes en la sentencia WHERE", 1); |
||
42 | } |
||
43 | |||
44 | $this->operadorValido($columnas[1]); |
||
45 | |||
46 | $this->_datos = $this->setDatos($columnas); |
||
47 | |||
48 | return ' WHERE '.$columnas[0].' '.$columnas[1].' ? '; |
||
49 | } |
||
50 | |||
51 | private function operadorValido($string) |
||
52 | { |
||
53 | if (!in_array($string, $this->_operadoresValidos)) |
||
54 | { |
||
55 | throw new Exception("Comparador lógico invalido en el campo de la sentencia WHERE"); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | private function setDatos(array $columnas): array |
||
62 | } |
||
63 | } |