-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refatoraçoes para melhor legibilidade e testes
- Loading branch information
Showing
7 changed files
with
78 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
} | ||
], | ||
"require": { | ||
"php": "^7.0", | ||
"guzzlehttp/guzzle": "~6.0", | ||
"ext-simplexml": "*", | ||
"ext-json": "*" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ | |
use Claudsonm\CepPromise\Exceptions\CepPromiseException; | ||
|
||
/** | ||
* Classe responsável por receber o CEP e disparar as requisições aos providers. | ||
* Efetua a consulta pelas informações de um CEP em diferentes serviços de | ||
* forma concorrente, retornando a resposta mais rápida.. | ||
* | ||
* @author Claudson Martins <[email protected]> | ||
*/ | ||
|
@@ -24,23 +25,21 @@ class CepPromise | |
const ERROR_VALIDATION_CODE = 1; | ||
|
||
/** | ||
* Dispara a cadeia de execução para obtenção das informações do CEP dado. | ||
* | ||
* @param $cepRawValue | ||
* | ||
* @throws CepPromiseException | ||
* Busca as informações referente ao CEP informado. | ||
* | ||
* @param string|int $cep | ||
* @return Address | ||
* @throws CepPromiseException | ||
*/ | ||
public static function fetch($cepRawValue) | ||
public static function fetch($cep) | ||
{ | ||
return (new self())->run($cepRawValue); | ||
return (new self())->run($cep); | ||
} | ||
|
||
/** | ||
* Define o encadeamento das promises. | ||
* Dispara a cadeia de execução para obtenção das informações do CEP dado. | ||
* | ||
* @param $cepRawValue | ||
* @param string|int $cepRawValue | ||
* @return Address | ||
*/ | ||
public function run($cepRawValue): Address | ||
|
@@ -108,8 +107,8 @@ private function validateInputLength() | |
|
||
private function leftPadWithZeros() | ||
{ | ||
return function (string $cepCleanValue) { | ||
return str_pad($cepCleanValue, self::CEP_SIZE, '0', STR_PAD_LEFT); | ||
return function (string $cepSanitized) { | ||
return str_pad($cepSanitized, self::CEP_SIZE, '0', STR_PAD_LEFT); | ||
}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters