@@ -24,15 +24,15 @@ public function __construct(int|string $cep)
2424 $ response = ViaCep::fromCep ($ cep );
2525 $ this ->status = $ response ["statusText " ];
2626 $ this ->cep = $ cep ;
27- $ this ->complement = $ response ["complemento " ];
28- $ this ->ibge = $ response ["ibge " ];
29- $ this ->gia = $ response ["gia " ];
30- $ this ->siafi = $ response ["siafi " ];
31- $ this ->ddd = $ response ["ddd " ];
32- $ this ->street = $ response ["logradouro " ];
33- $ this ->area = $ response ["bairro " ];
34- $ this ->city = $ response ["localidade " ];
35- $ this ->state = $ response ["uf " ];
27+ $ this ->complement = array_key_exists ( " complemento " , $ response) ? $ response ["complemento " ] : null ;
28+ $ this ->ibge = array_key_exists ( " ibge " , $ response) ? $ response ["ibge " ] : null ;
29+ $ this ->gia = array_key_exists ( " gia " , $ response) ? $ response ["gia " ] : null ;
30+ $ this ->siafi = array_key_exists ( " siafi " , $ response) ? $ response ["siafi " ] : null ;
31+ $ this ->ddd = array_key_exists ( " ddd " , $ response) ? $ response ["ddd " ] : null ;
32+ $ this ->street = array_key_exists ( " logradouro " , $ response) ? $ response ["logradouro " ] : null ;
33+ $ this ->area = array_key_exists ( " bairro " , $ response) ? $ response ["bairro " ] : null ;
34+ $ this ->city = array_key_exists ( " localidade " , $ response) ? $ response ["localidade " ] : null ;
35+ $ this ->state = array_key_exists ( " uf " , $ response) ? $ response ["uf " ] : null ;
3636 $ this ->country = "BR " ;
3737 }
3838
0 commit comments