@@ -54,7 +54,7 @@ class HttpCurlClient
5454 *
5555 * @return array Lista de errores de cURL.
5656 */
57- public function getErrors ()
57+ public function getErrors (): array
5858 {
5959 return $ this ->errors ;
6060 }
@@ -67,7 +67,7 @@ public function getErrors()
6767 *
6868 * @return string Descripción del último error de cURL.
6969 */
70- public function getLastError ()
70+ public function getLastError (): string
7171 {
7272 return $ this ->errors [count ($ this ->errors ) - 1 ];
7373 }
@@ -81,7 +81,7 @@ public function getLastError()
8181 * @param boolean $sslcheck Activar o desactivar la verificación del
8282 * certificado SSL.
8383 */
84- public function setSSL ($ sslcheck = true )
84+ public function setSSL (bool $ sslcheck = true ): void
8585 {
8686 $ this ->sslcheck = $ sslcheck ;
8787 }
@@ -99,8 +99,12 @@ public function setSSL($sslcheck = true)
9999 * @param array $headers Cabeceras HTTP a enviar.
100100 * @return array|false Respuesta HTTP o false en caso de error.
101101 */
102- public function query ($ method , string $ url , $ data = [], array $ headers = [])
103- {
102+ public function query (
103+ string $ method ,
104+ string $ url ,
105+ mixed $ data = [],
106+ array $ headers = []
107+ ): array |bool {
104108 // preparar datos
105109 if ($ data && $ method != 'GET ' ) {
106110 if (isset ($ data ['@files ' ])) {
@@ -148,13 +152,19 @@ public function query($method, string $url, $data = [], array $headers = [])
148152 $ this ->errors [] = curl_error ($ curl );
149153 return false ;
150154 }
151- $ headers_size = curl_getinfo ($ curl , CURLINFO_HEADER_SIZE );
155+ $ headers_size = curl_getinfo (handle: $ curl , option: CURLINFO_HEADER_SIZE );
152156 // cerrar conexión de curl
153157 curl_close ($ curl );
154158 // entregar respuesta de la solicitud
155- $ response_headers = $ this ->parseResponseHeaders (substr ($ response , 0 , $ headers_size ));
159+ $ response_headers = $ this ->parseResponseHeaders (
160+ substr (
161+ string: $ response ,
162+ offset: 0 ,
163+ length: $ headers_size
164+ )
165+ );
156166 $ body = substr ($ response , $ headers_size );
157- $ json = json_decode ($ body , true );
167+ $ json = json_decode (json: $ body , associative: true );
158168 return [
159169 'status ' => $ this ->parseResponseStatus ($ response_headers [0 ]),
160170 'header ' => $ response_headers ,
@@ -173,7 +183,7 @@ public function query($method, string $url, $data = [], array $headers = [])
173183 * @param string $headers_txt Cabeceras HTTP en formato de texto plano.
174184 * @return array Arreglo asociativo con las cabeceras procesadas.
175185 */
176- private function parseResponseHeaders ($ headers_txt )
186+ private function parseResponseHeaders (string $ headers_txt ): array
177187 {
178188 $ headers = [];
179189 $ lineas = explode ("\n" , $ headers_txt );
@@ -183,7 +193,11 @@ private function parseResponseHeaders($headers_txt)
183193 continue ;
184194 }
185195 if (strpos ($ linea , ': ' )) {
186- list ($ key , $ value ) = explode (': ' , $ linea , 2 );
196+ list ($ key , $ value ) = explode (
197+ separator: ': ' ,
198+ string: $ linea ,
199+ limit: 2
200+ );
187201 } else {
188202 $ key = 0 ;
189203 $ value = $ linea ;
@@ -214,12 +228,12 @@ private function parseResponseHeaders($headers_txt)
214228 * @return array Arreglo con información del estado, incluyendo protocolo,
215229 * código y mensaje.
216230 */
217- private function parseResponseStatus ($ response_line )
231+ private function parseResponseStatus (array | string $ response_line ): array
218232 {
219233 if (is_array ($ response_line )) {
220234 $ response_line = $ response_line [count ($ response_line ) - 1 ];
221235 }
222- $ parts = explode (' ' , $ response_line , 3 );
236+ $ parts = explode (separator: ' ' , string: $ response_line , limit: 3 );
223237 return [
224238 'protocol ' => $ parts [0 ],
225239 'code ' => $ parts [1 ],
0 commit comments