@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function testCamposSoloRetornaTexto() |
| 41 | 41 | { |
| 42 | - $campos = new Campos(['*','78']); |
|
| 42 | + $campos = new Campos(['*', '78']); |
|
| 43 | 43 | $this->assertIsString($campos->campos()); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -53,31 +53,31 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function testDondeSoloRetornaTexto() |
| 55 | 55 | { |
| 56 | - $donde = new Donde(['id','=','23']); |
|
| 56 | + $donde = new Donde(['id', '=', '23']); |
|
| 57 | 57 | $this->assertIsString($donde->donde()); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function testLaColumnaSoloPuedeSerAlfaNumerica() |
| 61 | 61 | { |
| 62 | 62 | $this->expectException(Exception::class); |
| 63 | - $donde = new Donde(['%','=',2]); |
|
| 63 | + $donde = new Donde(['%', '=', 2]); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function testElValorSoloPuedeSerAlfaNumerico() |
| 67 | 67 | { |
| 68 | 68 | $this->expectException(Exception::class); |
| 69 | - $donde = new Donde(['id','=','#']); |
|
| 69 | + $donde = new Donde(['id', '=', '#']); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function testElComparadorSoloPuedeSerLogico() |
| 73 | 73 | { |
| 74 | 74 | $this->expectException(Exception::class); |
| 75 | - $donde = new Donde(['id','12','23']); |
|
| 75 | + $donde = new Donde(['id', '12', '23']); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public function testLosDatosQueDevuelveSiempreSonArray() |
| 79 | 79 | { |
| 80 | - $donde = new Donde(['id','=','1']); |
|
| 80 | + $donde = new Donde(['id', '=', '1']); |
|
| 81 | 81 | $this->assertIsArray($donde->datos()); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -91,32 +91,32 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | public function testEntreSoloRetornaTexto() |
| 93 | 93 | { |
| 94 | - $Entre = new Entre(['id','45','23']); |
|
| 94 | + $Entre = new Entre(['id', '45', '23']); |
|
| 95 | 95 | $this->assertIsString($Entre->donde()); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public function testLosDatosQueDevuelveEntreSiempreSonArray() |
| 99 | 99 | { |
| 100 | - $donde = new Entre(['id','1','1']); |
|
| 100 | + $donde = new Entre(['id', '1', '1']); |
|
| 101 | 101 | $this->assertIsArray($donde->datos()); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | public function testLaColumnaDeEntreSoloPuedeSerAlfaNumerica() |
| 105 | 105 | { |
| 106 | 106 | $this->expectException(Exception::class); |
| 107 | - $donde = new Entre(['=','1','1']); |
|
| 107 | + $donde = new Entre(['=', '1', '1']); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | public function testElPrimeroValorDeEntreSoloPuedeSerAlfaNumerico() |
| 111 | 111 | { |
| 112 | 112 | $this->expectException(Exception::class); |
| 113 | - $donde = new Entre(['id','=','1']); |
|
| 113 | + $donde = new Entre(['id', '=', '1']); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public function testElSegundoValorDeEntreSoloPuedeSerAlfaNumerico() |
| 117 | 117 | { |
| 118 | 118 | $this->expectException(Exception::class); |
| 119 | - $donde = new Entre(['id','1','&']); |
|
| 119 | + $donde = new Entre(['id', '1', '&']); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | //ODonde |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | public function testODondeSoloRetornaTexto() |
| 125 | 125 | { |
| 126 | 126 | $ODonde = new ODonde( |
| 127 | - new Donde(['id','=','1']), |
|
| 128 | - new Donde(['id','=','2']) |
|
| 127 | + new Donde(['id', '=', '1']), |
|
| 128 | + new Donde(['id', '=', '2']) |
|
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | 131 | $this->assertIsString($ODonde->donde()); |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | public function testLosDatosQueDevuelveODondeSiempreSonArray() |
| 135 | 135 | { |
| 136 | 136 | $donde = new ODonde( |
| 137 | - new Donde(['id','=','1']), |
|
| 138 | - new Donde(['id','=','2']) |
|
| 137 | + new Donde(['id', '=', '1']), |
|
| 138 | + new Donde(['id', '=', '2']) |
|
| 139 | 139 | ); |
| 140 | 140 | $this->assertIsArray($donde->datos()); |
| 141 | 141 | } |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | public function testYDondeSoloRetornaTexto() |
| 147 | 147 | { |
| 148 | 148 | $YDonde = new YDonde( |
| 149 | - new Donde(['id','=','1']), |
|
| 150 | - new Donde(['id','=','2']) |
|
| 149 | + new Donde(['id', '=', '1']), |
|
| 150 | + new Donde(['id', '=', '2']) |
|
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | 153 | $this->assertIsString($YDonde->donde()); |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | public function testLosDatosQueDevuelveYDondeSiempreSonArray() |
| 157 | 157 | { |
| 158 | 158 | $donde = new YDonde( |
| 159 | - new Donde(['id','=','1']), |
|
| 160 | - new Donde(['id','=','2']) |
|
| 159 | + new Donde(['id', '=', '1']), |
|
| 160 | + new Donde(['id', '=', '2']) |
|
| 161 | 161 | ); |
| 162 | 162 | $this->assertIsArray($donde->datos()); |
| 163 | 163 | } |
@@ -29,14 +29,14 @@ |
||
| 29 | 29 | public function conectar(): PDO |
| 30 | 30 | { |
| 31 | 31 | try |
| 32 | - { |
|
| 33 | - $this->_pdo = new PDO('mysql:host='.$this->_hostBaseDeDatos->hostBaseDeDatos().';dbname='.$this->_baseDeDatos->baseDeDatos().';chartset=utf8mb4',$this->_usuarioBaseDeDatos->usuarioBaseDeDatos(),$this->_contraseñaBaseDeDatos->contraseñaBaseDeDatos()); |
|
| 34 | - $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 35 | - } |
|
| 36 | - catch(PDOException) |
|
| 37 | - { |
|
| 38 | - throw new ConexionABaseDeDatosException("Error al conectar con base de datos"); |
|
| 39 | - } |
|
| 32 | + { |
|
| 33 | + $this->_pdo = new PDO('mysql:host='.$this->_hostBaseDeDatos->hostBaseDeDatos().';dbname='.$this->_baseDeDatos->baseDeDatos().';chartset=utf8mb4',$this->_usuarioBaseDeDatos->usuarioBaseDeDatos(),$this->_contraseñaBaseDeDatos->contraseñaBaseDeDatos()); |
|
| 34 | + $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 35 | + } |
|
| 36 | + catch(PDOException) |
|
| 37 | + { |
|
| 38 | + throw new ConexionABaseDeDatosException("Error al conectar con base de datos"); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | return $this->_pdo; |
| 42 | 42 | } |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | private $_usuarioBaseDeDatos; |
| 13 | 13 | private $_contraseñaBaseDeDatos; |
| 14 | 14 | |
| 15 | - public function __construct |
|
| 16 | - ( |
|
| 15 | + public function __construct( |
|
| 17 | 16 | HostBaseDeDatos $HostBaseDeDatos, |
| 18 | 17 | BaseDeDatos $BaseDeDatos, |
| 19 | 18 | UsuarioBaseDeDatos $UsuarioBaseDeDatos, |
@@ -30,10 +29,10 @@ discard block |
||
| 30 | 29 | { |
| 31 | 30 | try |
| 32 | 31 | { |
| 33 | - $this->_pdo = new PDO('mysql:host='.$this->_hostBaseDeDatos->hostBaseDeDatos().';dbname='.$this->_baseDeDatos->baseDeDatos().';chartset=utf8mb4',$this->_usuarioBaseDeDatos->usuarioBaseDeDatos(),$this->_contraseñaBaseDeDatos->contraseñaBaseDeDatos()); |
|
| 32 | + $this->_pdo = new PDO('mysql:host='.$this->_hostBaseDeDatos->hostBaseDeDatos().';dbname='.$this->_baseDeDatos->baseDeDatos().';chartset=utf8mb4', $this->_usuarioBaseDeDatos->usuarioBaseDeDatos(), $this->_contraseñaBaseDeDatos->contraseñaBaseDeDatos()); |
|
| 34 | 33 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 35 | 34 | } |
| 36 | - catch(PDOException) |
|
| 35 | + catch (PDOException) |
|
| 37 | 36 | { |
| 38 | 37 | throw new ConexionABaseDeDatosException("Error al conectar con base de datos"); |
| 39 | 38 | } |
@@ -32,8 +32,7 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $this->_pdo = new PDO('mysql:host='.$this->_hostBaseDeDatos->hostBaseDeDatos().';dbname='.$this->_baseDeDatos->baseDeDatos().';chartset=utf8mb4',$this->_usuarioBaseDeDatos->usuarioBaseDeDatos(),$this->_contraseñaBaseDeDatos->contraseñaBaseDeDatos()); |
| 34 | 34 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 35 | - } |
|
| 36 | - catch(PDOException) |
|
| 35 | + } catch(PDOException) |
|
| 37 | 36 | { |
| 38 | 37 | throw new ConexionABaseDeDatosException("Error al conectar con base de datos"); |
| 39 | 38 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | private function setTabla(string $tabla): string |
| 21 | 21 | { |
| 22 | - if(empty($tabla)) |
|
| 22 | + if (empty($tabla)) |
|
| 23 | 23 | { |
| 24 | 24 | throw new Exception("La tabla no puede estar vacia"); |
| 25 | 25 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | |
| 32 | 32 | private function numero($limite) |
| 33 | 33 | { |
| 34 | - if(!is_numeric($limite)) |
|
| 34 | + if (!is_numeric($limite)) |
|
| 35 | 35 | { |
| 36 | 36 | throw new Exception("La sentencia LIMITE solo puede ser número"); |
| 37 | 37 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | private function setDonde(array $columnas): string |
| 38 | 38 | { |
| 39 | - if(count($columnas) !== 3) |
|
| 39 | + if (count($columnas) !== 3) |
|
| 40 | 40 | { |
| 41 | 41 | throw new Exception("Elementos faltantes o sobrantes en la sentencia WHERE", 1); |
| 42 | 42 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | private function alfaNumerico($string) |
| 54 | 54 | { |
| 55 | - if(!ctype_alnum($string)) |
|
| 55 | + if (!ctype_alnum($string)) |
|
| 56 | 56 | { |
| 57 | 57 | throw new Exception("Caracter invalido en el campo de la sentencia WHERE"); |
| 58 | 58 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function datos(): array |
| 23 | 23 | { |
| 24 | - return array($this->_primerDonde->datos()[0],$this->_segundoDonde->datos()[0]); |
|
| 24 | + return array($this->_primerDonde->datos()[0], $this->_segundoDonde->datos()[0]); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | private function setDonde(): string |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | private function setEntre(array $columnas): string |
| 27 | 27 | { |
| 28 | - if(count($columnas) !== 3) |
|
| 28 | + if (count($columnas) !== 3) |
|
| 29 | 29 | { |
| 30 | 30 | throw new Exception("Faltan elementos en la sentencia BETWEEN"); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - foreach($columnas as $columna) |
|
| 33 | + foreach ($columnas as $columna) |
|
| 34 | 34 | { |
| 35 | 35 | $this->alfaNumerico($columna); |
| 36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | private function alfaNumerico($string) |
| 44 | 44 | { |
| 45 | - if(!ctype_alnum($string)) |
|
| 45 | + if (!ctype_alnum($string)) |
|
| 46 | 46 | { |
| 47 | 47 | throw new Exception("Caracter invalido en el campo de la sentencia BETWEEN"); |
| 48 | 48 | } |
@@ -50,6 +50,6 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | private function setDatos(array $columnas): array |
| 52 | 52 | { |
| 53 | - return array($columnas[1],$columnas[2]); |
|
| 53 | + return array($columnas[1], $columnas[2]); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | \ No newline at end of file |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function datos(): array |
| 25 | 25 | { |
| 26 | - return array($this->_primerDonde->datos()[0],$this->_segundoDonde->datos()[0]); |
|
| 26 | + return array($this->_primerDonde->datos()[0], $this->_segundoDonde->datos()[0]); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | private function setDonde(): string |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | private function setCampos(array $columnas): string |
| 21 | 21 | { |
| 22 | - if(count($columnas) == 0) |
|
| 22 | + if (count($columnas) == 0) |
|
| 23 | 23 | { |
| 24 | 24 | throw new Exception("No existen campos indicados"); |
| 25 | 25 | } |