@@ -5,20 +5,20 @@ |
||
5 | 5 | |
6 | 6 | class Como |
7 | 7 | { |
8 | - private $_where; |
|
8 | + private $_where; |
|
9 | 9 | |
10 | - public function __construct(WhereInterface $WhereInterface) |
|
11 | - { |
|
12 | - $this->_where = $WhereInterface; |
|
13 | - } |
|
10 | + public function __construct(WhereInterface $WhereInterface) |
|
11 | + { |
|
12 | + $this->_where = $WhereInterface; |
|
13 | + } |
|
14 | 14 | |
15 | - public function sql(): string |
|
16 | - { |
|
17 | - return $this->_where->sql(); |
|
18 | - } |
|
15 | + public function sql(): string |
|
16 | + { |
|
17 | + return $this->_where->sql(); |
|
18 | + } |
|
19 | 19 | |
20 | - public function datos(): array |
|
21 | - { |
|
22 | - return $this->_where->datos(); |
|
23 | - } |
|
20 | + public function datos(): array |
|
21 | + { |
|
22 | + return $this->_where->datos(); |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -6,60 +6,60 @@ |
||
6 | 6 | |
7 | 7 | class ValidadorDeParametrosWhereBetween implements ValidadorDeParametrosInterface |
8 | 8 | { |
9 | - private $_datos; |
|
9 | + private $_datos; |
|
10 | 10 | |
11 | - public function __construct(array $datos) |
|
12 | - { |
|
13 | - $this->_datos = $this->setDatos($datos); |
|
14 | - } |
|
11 | + public function __construct(array $datos) |
|
12 | + { |
|
13 | + $this->_datos = $this->setDatos($datos); |
|
14 | + } |
|
15 | 15 | |
16 | - public function datos(): array |
|
17 | - { |
|
18 | - return $this->_datos; |
|
19 | - } |
|
16 | + public function datos(): array |
|
17 | + { |
|
18 | + return $this->_datos; |
|
19 | + } |
|
20 | 20 | |
21 | - private function setDatos(array $array): array |
|
22 | - { |
|
23 | - $this->numeroDeElementosValido($array); |
|
24 | - $this->columnaEsString($array); |
|
25 | - $this->valoresNoSonIguales($array); |
|
26 | - $this->contieneValoresVacios($array); |
|
21 | + private function setDatos(array $array): array |
|
22 | + { |
|
23 | + $this->numeroDeElementosValido($array); |
|
24 | + $this->columnaEsString($array); |
|
25 | + $this->valoresNoSonIguales($array); |
|
26 | + $this->contieneValoresVacios($array); |
|
27 | 27 | |
28 | - return $array; |
|
29 | - } |
|
28 | + return $array; |
|
29 | + } |
|
30 | 30 | |
31 | - private function contieneValoresVacios($array): void |
|
32 | - { |
|
33 | - foreach ($array as $value) |
|
34 | - { |
|
35 | - if(empty($value)) |
|
36 | - { |
|
37 | - throw new Exception("Error Processing Request"); |
|
38 | - } |
|
39 | - } |
|
40 | - } |
|
31 | + private function contieneValoresVacios($array): void |
|
32 | + { |
|
33 | + foreach ($array as $value) |
|
34 | + { |
|
35 | + if(empty($value)) |
|
36 | + { |
|
37 | + throw new Exception("Error Processing Request"); |
|
38 | + } |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - private function valoresNoSonIguales($array): void |
|
43 | - { |
|
44 | - if($array[1] == $array[2]) |
|
45 | - { |
|
46 | - throw new Exception("Error Processing Request"); |
|
47 | - } |
|
48 | - } |
|
42 | + private function valoresNoSonIguales($array): void |
|
43 | + { |
|
44 | + if($array[1] == $array[2]) |
|
45 | + { |
|
46 | + throw new Exception("Error Processing Request"); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | |
50 | - private function numeroDeElementosValido($array): void |
|
51 | - { |
|
52 | - if(count($array) !== 3) |
|
53 | - { |
|
54 | - throw new Exception("Error Processing Request"); |
|
55 | - } |
|
56 | - } |
|
50 | + private function numeroDeElementosValido($array): void |
|
51 | + { |
|
52 | + if(count($array) !== 3) |
|
53 | + { |
|
54 | + throw new Exception("Error Processing Request"); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | - private function columnaEsString($array): void |
|
59 | - { |
|
60 | - if(!is_string($array[0])) |
|
61 | - { |
|
62 | - throw new Exception("Error Processing Request"); |
|
63 | - } |
|
64 | - } |
|
58 | + private function columnaEsString($array): void |
|
59 | + { |
|
60 | + if(!is_string($array[0])) |
|
61 | + { |
|
62 | + throw new Exception("Error Processing Request"); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -6,74 +6,74 @@ |
||
6 | 6 | |
7 | 7 | class ValidadorDeParametrosWhere implements ValidadorDeParametrosInterface |
8 | 8 | { |
9 | - private $_operadoresValidos = [ |
|
10 | - '=', |
|
11 | - '>', |
|
12 | - '<', |
|
13 | - '>=', |
|
14 | - '<=', |
|
15 | - '<>', |
|
16 | - '!=', |
|
17 | - '!<', |
|
18 | - '!>', |
|
19 | - 'LIKE', |
|
20 | - 'IN', |
|
21 | - ]; |
|
9 | + private $_operadoresValidos = [ |
|
10 | + '=', |
|
11 | + '>', |
|
12 | + '<', |
|
13 | + '>=', |
|
14 | + '<=', |
|
15 | + '<>', |
|
16 | + '!=', |
|
17 | + '!<', |
|
18 | + '!>', |
|
19 | + 'LIKE', |
|
20 | + 'IN', |
|
21 | + ]; |
|
22 | 22 | |
23 | - private $_datos; |
|
23 | + private $_datos; |
|
24 | 24 | |
25 | - public function __construct(array $datos) |
|
26 | - { |
|
27 | - $this->_datos = $this->setDatos($datos); |
|
28 | - } |
|
25 | + public function __construct(array $datos) |
|
26 | + { |
|
27 | + $this->_datos = $this->setDatos($datos); |
|
28 | + } |
|
29 | 29 | |
30 | - public function datos(): array |
|
31 | - { |
|
32 | - return $this->_datos; |
|
33 | - } |
|
30 | + public function datos(): array |
|
31 | + { |
|
32 | + return $this->_datos; |
|
33 | + } |
|
34 | 34 | |
35 | - public function setDatos($array): array |
|
36 | - { |
|
37 | - $this->numeroDeElementosValido($array); |
|
38 | - $this->contieneValoresVacios($array); |
|
39 | - $this->columnaEsString($array); |
|
40 | - $this->operadorValido($array); |
|
35 | + public function setDatos($array): array |
|
36 | + { |
|
37 | + $this->numeroDeElementosValido($array); |
|
38 | + $this->contieneValoresVacios($array); |
|
39 | + $this->columnaEsString($array); |
|
40 | + $this->operadorValido($array); |
|
41 | 41 | |
42 | - return $array; |
|
43 | - } |
|
42 | + return $array; |
|
43 | + } |
|
44 | 44 | |
45 | - private function contieneValoresVacios($array): void |
|
46 | - { |
|
47 | - foreach ($array as $value) |
|
48 | - { |
|
49 | - if(empty($value)) |
|
50 | - { |
|
51 | - throw new Exception("Error Processing Request"); |
|
52 | - } |
|
53 | - } |
|
54 | - } |
|
45 | + private function contieneValoresVacios($array): void |
|
46 | + { |
|
47 | + foreach ($array as $value) |
|
48 | + { |
|
49 | + if(empty($value)) |
|
50 | + { |
|
51 | + throw new Exception("Error Processing Request"); |
|
52 | + } |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | - private function numeroDeElementosValido($array): void |
|
57 | - { |
|
58 | - if(count($array) !== 3) |
|
59 | - { |
|
60 | - throw new Exception("Error Processing Request"); |
|
61 | - } |
|
62 | - } |
|
56 | + private function numeroDeElementosValido($array): void |
|
57 | + { |
|
58 | + if(count($array) !== 3) |
|
59 | + { |
|
60 | + throw new Exception("Error Processing Request"); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - private function operadorValido($array): void |
|
65 | - { |
|
66 | - if(!in_array($array[1], $this->_operadoresValidos)) |
|
67 | - { |
|
68 | - throw new Exception("Error Processing Request"); |
|
69 | - } |
|
70 | - } |
|
64 | + private function operadorValido($array): void |
|
65 | + { |
|
66 | + if(!in_array($array[1], $this->_operadoresValidos)) |
|
67 | + { |
|
68 | + throw new Exception("Error Processing Request"); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - private function columnaEsString($array): void |
|
73 | - { |
|
74 | - if(!is_string($array[0])) |
|
75 | - { |
|
76 | - throw new Exception("Error Processing Request"); |
|
77 | - } |
|
78 | - } |
|
72 | + private function columnaEsString($array): void |
|
73 | + { |
|
74 | + if(!is_string($array[0])) |
|
75 | + { |
|
76 | + throw new Exception("Error Processing Request"); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -6,20 +6,20 @@ |
||
6 | 6 | |
7 | 7 | class WhereAnd implements WhereInterface |
8 | 8 | { |
9 | - private $_where; |
|
9 | + private $_where; |
|
10 | 10 | |
11 | - public function __construct(ValidadorDeParametrosInterface $ValidadorDeParametrosInterface) |
|
12 | - { |
|
13 | - $this->_where = $ValidadorDeParametrosInterface->datos(); |
|
14 | - } |
|
11 | + public function __construct(ValidadorDeParametrosInterface $ValidadorDeParametrosInterface) |
|
12 | + { |
|
13 | + $this->_where = $ValidadorDeParametrosInterface->datos(); |
|
14 | + } |
|
15 | 15 | |
16 | - public function sql(): string |
|
17 | - { |
|
18 | - return 'WHERE '.$this->_where[0].' '.$this->_where[1].' ? AND '.$this->_where[3].' '.$this->_where[4].' ?'; |
|
19 | - } |
|
16 | + public function sql(): string |
|
17 | + { |
|
18 | + return 'WHERE '.$this->_where[0].' '.$this->_where[1].' ? AND '.$this->_where[3].' '.$this->_where[4].' ?'; |
|
19 | + } |
|
20 | 20 | |
21 | - public function datos(): array |
|
22 | - { |
|
23 | - return [ $this->_where[2], $this->_where[5] ]; |
|
24 | - } |
|
21 | + public function datos(): array |
|
22 | + { |
|
23 | + return [ $this->_where[2], $this->_where[5] ]; |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -5,25 +5,25 @@ |
||
5 | 5 | |
6 | 6 | class Tabla |
7 | 7 | { |
8 | - private $_tabla; |
|
8 | + private $_tabla; |
|
9 | 9 | |
10 | - public function __construct(string $Tabla) |
|
11 | - { |
|
12 | - $this->_tabla = $this->setTabla($Tabla); |
|
13 | - } |
|
10 | + public function __construct(string $Tabla) |
|
11 | + { |
|
12 | + $this->_tabla = $this->setTabla($Tabla); |
|
13 | + } |
|
14 | 14 | |
15 | - public function sql(): string |
|
16 | - { |
|
17 | - return $this->_tabla; |
|
18 | - } |
|
15 | + public function sql(): string |
|
16 | + { |
|
17 | + return $this->_tabla; |
|
18 | + } |
|
19 | 19 | |
20 | - private function setTabla(string $tabla): string |
|
21 | - { |
|
22 | - if(empty($tabla)) |
|
23 | - { |
|
24 | - throw new Exception("Error Processing Request"); |
|
25 | - } |
|
20 | + private function setTabla(string $tabla): string |
|
21 | + { |
|
22 | + if(empty($tabla)) |
|
23 | + { |
|
24 | + throw new Exception("Error Processing Request"); |
|
25 | + } |
|
26 | 26 | |
27 | - return $tabla; |
|
28 | - } |
|
27 | + return $tabla; |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -6,20 +6,20 @@ |
||
6 | 6 | |
7 | 7 | class WhereNotBetween implements WhereInterface |
8 | 8 | { |
9 | - private $_where; |
|
9 | + private $_where; |
|
10 | 10 | |
11 | - public function __construct(ValidadorDeParametrosInterface $ValidadorDeParametrosInterface) |
|
12 | - { |
|
13 | - $this->_where = $ValidadorDeParametrosInterface->datos(); |
|
14 | - } |
|
11 | + public function __construct(ValidadorDeParametrosInterface $ValidadorDeParametrosInterface) |
|
12 | + { |
|
13 | + $this->_where = $ValidadorDeParametrosInterface->datos(); |
|
14 | + } |
|
15 | 15 | |
16 | - public function sql(): string |
|
17 | - { |
|
18 | - return 'WHERE NOT BETWEEN '.$this->_where[0].' ? AND ?'; |
|
19 | - } |
|
16 | + public function sql(): string |
|
17 | + { |
|
18 | + return 'WHERE NOT BETWEEN '.$this->_where[0].' ? AND ?'; |
|
19 | + } |
|
20 | 20 | |
21 | - public function datos(): array |
|
22 | - { |
|
23 | - return [ $this->_where[1], $this->_where[2] ]; |
|
24 | - } |
|
21 | + public function datos(): array |
|
22 | + { |
|
23 | + return [ $this->_where[1], $this->_where[2] ]; |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -6,20 +6,20 @@ |
||
6 | 6 | |
7 | 7 | class WhereBetween implements WhereInterface |
8 | 8 | { |
9 | - private $_where; |
|
9 | + private $_where; |
|
10 | 10 | |
11 | - public function __construct(ValidadorDeParametrosInterface $ValidadorDeParametrosInterface) |
|
12 | - { |
|
13 | - $this->_where = $ValidadorDeParametrosInterface->datos(); |
|
14 | - } |
|
11 | + public function __construct(ValidadorDeParametrosInterface $ValidadorDeParametrosInterface) |
|
12 | + { |
|
13 | + $this->_where = $ValidadorDeParametrosInterface->datos(); |
|
14 | + } |
|
15 | 15 | |
16 | - public function sql(): string |
|
17 | - { |
|
18 | - return 'WHERE BETWEEN '.$this->_where[0].' ? AND ?'; |
|
19 | - } |
|
16 | + public function sql(): string |
|
17 | + { |
|
18 | + return 'WHERE BETWEEN '.$this->_where[0].' ? AND ?'; |
|
19 | + } |
|
20 | 20 | |
21 | - public function datos(): array |
|
22 | - { |
|
23 | - return [ $this->_where[1], $this->_where[2] ]; |
|
24 | - } |
|
21 | + public function datos(): array |
|
22 | + { |
|
23 | + return [ $this->_where[1], $this->_where[2] ]; |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -6,17 +6,17 @@ |
||
6 | 6 | |
7 | 7 | class CamposYTabla |
8 | 8 | { |
9 | - private $_campos; |
|
10 | - private $_tabla; |
|
9 | + private $_campos; |
|
10 | + private $_tabla; |
|
11 | 11 | |
12 | - public function __construct(Campos $Campos, Tabla $Tabla) |
|
13 | - { |
|
14 | - $this->_campos = $Campos->sql(); |
|
15 | - $this->_tabla = $Tabla->sql(); |
|
16 | - } |
|
12 | + public function __construct(Campos $Campos, Tabla $Tabla) |
|
13 | + { |
|
14 | + $this->_campos = $Campos->sql(); |
|
15 | + $this->_tabla = $Tabla->sql(); |
|
16 | + } |
|
17 | 17 | |
18 | - public function sql(): string |
|
19 | - { |
|
20 | - return $this->_campos.' FROM '.$this->_tabla; |
|
21 | - } |
|
18 | + public function sql(): string |
|
19 | + { |
|
20 | + return $this->_campos.' FROM '.$this->_tabla; |
|
21 | + } |
|
22 | 22 | } |
@@ -5,44 +5,44 @@ |
||
5 | 5 | |
6 | 6 | class Campos |
7 | 7 | { |
8 | - private $_campos; |
|
9 | - |
|
10 | - public function __construct(array $array) |
|
11 | - { |
|
12 | - $this->_campos = $this->setCampos($array); |
|
13 | - } |
|
14 | - |
|
15 | - public function sql(): string |
|
16 | - { |
|
17 | - return $this->_campos; |
|
18 | - } |
|
19 | - |
|
20 | - private function setCampos(array $array): string |
|
21 | - { |
|
22 | - $this->camposNoEstaVacio($array); |
|
23 | - |
|
24 | - $campos = ''; |
|
25 | - foreach($array as $arr) |
|
26 | - { |
|
27 | - $campos = $arr.','.$campos; |
|
28 | - } |
|
29 | - |
|
30 | - return trim($campos, ','); |
|
31 | - } |
|
32 | - |
|
33 | - private function camposNoEstaVacio(array $array): void |
|
34 | - { |
|
35 | - if(count($array) == 0) |
|
36 | - { |
|
37 | - throw new Exception("Error Processing Request"); |
|
38 | - } |
|
39 | - |
|
40 | - foreach ($array as $value) |
|
41 | - { |
|
42 | - if(empty($value)) |
|
43 | - { |
|
44 | - throw new Exception("Error Processing Request"); |
|
45 | - } |
|
46 | - } |
|
47 | - } |
|
8 | + private $_campos; |
|
9 | + |
|
10 | + public function __construct(array $array) |
|
11 | + { |
|
12 | + $this->_campos = $this->setCampos($array); |
|
13 | + } |
|
14 | + |
|
15 | + public function sql(): string |
|
16 | + { |
|
17 | + return $this->_campos; |
|
18 | + } |
|
19 | + |
|
20 | + private function setCampos(array $array): string |
|
21 | + { |
|
22 | + $this->camposNoEstaVacio($array); |
|
23 | + |
|
24 | + $campos = ''; |
|
25 | + foreach($array as $arr) |
|
26 | + { |
|
27 | + $campos = $arr.','.$campos; |
|
28 | + } |
|
29 | + |
|
30 | + return trim($campos, ','); |
|
31 | + } |
|
32 | + |
|
33 | + private function camposNoEstaVacio(array $array): void |
|
34 | + { |
|
35 | + if(count($array) == 0) |
|
36 | + { |
|
37 | + throw new Exception("Error Processing Request"); |
|
38 | + } |
|
39 | + |
|
40 | + foreach ($array as $value) |
|
41 | + { |
|
42 | + if(empty($value)) |
|
43 | + { |
|
44 | + throw new Exception("Error Processing Request"); |
|
45 | + } |
|
46 | + } |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | \ No newline at end of file |