예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function findAddressByCep(Cep $cep)
 {
     try {
         $request = new Request('GET', 'http://api.postmon.com.br/v1/cep/' . $cep);
         $response = $this->httpClient->send($request);
         /* @var \string[][] $json */
         $json = json_decode($response->getBody(), true);
         return new PartialAddress($json['estado_info']['nome'], $json['cidade'], isset($json['bairro']) ? $json['bairro'] : null, isset($json['logradouro']) ? $json['logradouro'] : null, isset($json['complemento']) ? $json['complemento'] : null);
     } catch (\Exception $e) {
     }
     throw CepNotFoundException::forCep($cep);
 }
 /**
  * @test
  */
 public function forCep()
 {
     $this->assertInstanceOf(CepNotFoundException::class, CepNotFoundException::forCep(Cep::fromString('12312300')));
 }