| @@ -31,4 +31,4 @@ | ||
| 31 | 31 | /** | 
| 32 | 32 | * Custom InvalidInputException. | 
| 33 | 33 | */ | 
| 34 | -class InvalidInputException extends \Exception{} | |
| 34 | +class InvalidInputException extends \Exception {} | |
| @@ -31,4 +31,4 @@ | ||
| 31 | 31 | /** | 
| 32 | 32 | * Custom ValidationException. | 
| 33 | 33 | */ | 
| 34 | -class ValidationException extends \Exception{} | |
| 34 | +class ValidationException extends \Exception {} | |
| @@ -31,4 +31,4 @@ | ||
| 31 | 31 | /** | 
| 32 | 32 | * Custom BankRejectException. | 
| 33 | 33 | */ | 
| 34 | -class BankRejectException extends \Exception{} | |
| 34 | +class BankRejectException extends \Exception {} | |
| @@ -31,4 +31,4 @@ | ||
| 31 | 31 | /** | 
| 32 | 32 | * Custom AuthException. | 
| 33 | 33 | */ | 
| 34 | -class AuthException extends \Exception{} | |
| 34 | +class AuthException extends \Exception {} | |
| @@ -31,4 +31,4 @@ | ||
| 31 | 31 | /** | 
| 32 | 32 | * Custom TimeoutException. | 
| 33 | 33 | */ | 
| 34 | -class TimeoutException extends \Exception{} | |
| 34 | +class TimeoutException extends \Exception {} | |
| @@ -31,4 +31,4 @@ | ||
| 31 | 31 | /** | 
| 32 | 32 | * Custom InstapagoException. | 
| 33 | 33 | */ | 
| 34 | -class InstapagoException extends \Exception{} | |
| 34 | +class InstapagoException extends \Exception {} | |
| @@ -51,7 +51,7 @@ discard block | ||
| 51 | 51 | return $this; | 
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | -  public function release(){ | |
| 54 | +  public function release() { | |
| 55 | 55 | $this->validations = [ | 
| 56 | 56 | 'amount' => [FILTER_VALIDATE_FLOAT], | 
| 57 | 57 |        'id' => [FILTER_VALIDATE_REGEXP, '/^([0-9a-f]{8})\-([0-9a-f]{4})\-([0-9a-f]{4})\-([0-9a-f]{4})\-([0-9a-f]{12})$/'], | 
| @@ -59,23 +59,23 @@ discard block | ||
| 59 | 59 | return $this; | 
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | -  public function query(){ | |
| 62 | +  public function query() { | |
| 63 | 63 | $this->validations = [ | 
| 64 | 64 |        'id' => [FILTER_VALIDATE_REGEXP, '/^([0-9a-f]{8})\-([0-9a-f]{4})\-([0-9a-f]{4})\-([0-9a-f]{4})\-([0-9a-f]{12})$/'], | 
| 65 | 65 | ]; | 
| 66 | 66 | return $this; | 
| 67 | 67 | } | 
| 68 | 68 | |
| 69 | -  public function validate($fields){ | |
| 69 | +  public function validate($fields) { | |
| 70 | 70 |      foreach ($this->validations as $key => $filters) { | 
| 71 | -      if ( !$this->_validation($fields[$key], $filters) ){ | |
| 71 | +      if ( ! $this->_validation($fields[$key], $filters)) { | |
| 72 | 72 |          throw new Exceptions\ValidationException("Error {$key}: {$fields[$key]}"); | 
| 73 | 73 | } | 
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | 76 | } | 
| 77 | 77 | |
| 78 | - private function _validation ($value, $filters) | |
| 78 | + private function _validation($value, $filters) | |
| 79 | 79 |    { | 
| 80 | 80 | $filter = $filters[0]; | 
| 81 | 81 | $flags = []; | 
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 | * Requeridas. | 
| 48 | 48 | */ | 
| 49 | 49 |    public function __construct($keyId, $publicKeyId) { | 
| 50 | -    if ( empty($keyId) || empty($publicKeyId) ) { | |
| 50 | +    if (empty($keyId) || empty($publicKeyId)) { | |
| 51 | 51 |        throw new Exceptions\InstapagoException('Los parámetros "keyId" y "publicKeyId" son requeridos para procesar la petición.'); | 
| 52 | 52 | } | 
| 53 | 53 | $this->publicKeyId = $publicKeyId; | 
| @@ -124,7 +124,7 @@ discard block | ||
| 124 | 124 | * @return array<string> Respuesta de Instapago | 
| 125 | 125 | * @throws Exceptions\InstapagoException | 
| 126 | 126 | */ | 
| 127 | -  public function continuePayment($fields){ | |
| 127 | +  public function continuePayment($fields) { | |
| 128 | 128 | (new Validator())->release()->validate($fields); | 
| 129 | 129 | $fields = [ | 
| 130 | 130 | 'KeyID' => $this->keyId, //required | 
| @@ -205,7 +205,7 @@ discard block | ||
| 205 | 205 | |
| 206 | 206 | $args = []; | 
| 207 | 207 | $key = null; | 
| 208 | -    if (! in_array($method, ['GET', 'POST', 'DELETE'])) { | |
| 208 | +    if ( ! in_array($method, ['GET', 'POST', 'DELETE'])) { | |
| 209 | 209 |        throw new Exception("Not implemented yet", 1); | 
| 210 | 210 | } | 
| 211 | 211 | $key = $method == 'GET' ? 'query' : 'form_params'; | 
| @@ -241,20 +241,20 @@ discard block | ||
| 241 | 241 | throw new Exceptions\AuthException( | 
| 242 | 242 | 'Error de autenticación, ha ocurrido un error' | 
| 243 | 243 | . ' con las llaves utilizadas.'); | 
| 244 | -    }else if ($code == 403) { | |
| 244 | +    } else if ($code == 403) { | |
| 245 | 245 | throw new Exceptions\BankRejectException( | 
| 246 | 246 | 'Pago Rechazado por el banco.' | 
| 247 | 247 | ); | 
| 248 | -    }else if ($code == 500) { | |
| 248 | +    } else if ($code == 500) { | |
| 249 | 249 | throw new Exceptions\InstapagoException( | 
| 250 | 250 | 'Ha Ocurrido un error interno dentro del servidor.' | 
| 251 | 251 | ); | 
| 252 | -    }else if ($code == 503) { | |
| 252 | +    } else if ($code == 503) { | |
| 253 | 253 | throw new Exceptions\InstapagoException( | 
| 254 | 254 | 'Ha Ocurrido un error al procesar los parámetros de entrada.' | 
| 255 | 255 | . ' Revise los datos enviados y vuelva a intentarlo.' | 
| 256 | 256 | ); | 
| 257 | -    }else if ($code == 201) { | |
| 257 | +    } else if ($code == 201) { | |
| 258 | 258 | return [ | 
| 259 | 259 | 'code' => $code, | 
| 260 | 260 | 'msg_banco' => $obj->message, | 
| @@ -241,20 +241,20 @@ | ||
| 241 | 241 | throw new Exceptions\AuthException( | 
| 242 | 242 | 'Error de autenticación, ha ocurrido un error' | 
| 243 | 243 | . ' con las llaves utilizadas.'); | 
| 244 | -    }else if ($code == 403) { | |
| 244 | +    } else if ($code == 403) { | |
| 245 | 245 | throw new Exceptions\BankRejectException( | 
| 246 | 246 | 'Pago Rechazado por el banco.' | 
| 247 | 247 | ); | 
| 248 | -    }else if ($code == 500) { | |
| 248 | +    } else if ($code == 500) { | |
| 249 | 249 | throw new Exceptions\InstapagoException( | 
| 250 | 250 | 'Ha Ocurrido un error interno dentro del servidor.' | 
| 251 | 251 | ); | 
| 252 | -    }else if ($code == 503) { | |
| 252 | +    } else if ($code == 503) { | |
| 253 | 253 | throw new Exceptions\InstapagoException( | 
| 254 | 254 | 'Ha Ocurrido un error al procesar los parámetros de entrada.' | 
| 255 | 255 | . ' Revise los datos enviados y vuelva a intentarlo.' | 
| 256 | 256 | ); | 
| 257 | -    }else if ($code == 201) { | |
| 257 | +    } else if ($code == 201) { | |
| 258 | 258 | return [ | 
| 259 | 259 | 'code' => $code, | 
| 260 | 260 | 'msg_banco' => $obj->message, |