Skip to content

Commit 1bcdfe9

Browse files
committed
Fixed "Cannot assign null to property"
1 parent 6fbcd17 commit 1bcdfe9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Objects/CepAbertoResponse.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ public function __construct(int|string $cep)
2626

2727
$this->status = $response["statusText"];
2828
if(array_key_exists("cidade", $response)){
29-
$this->ibge = array_key_exists("ibge", $response["cidade"]) ? $response["cidade"]["ibge"] : null;
30-
$this->ddd = array_key_exists("ddd", $response["cidade"]) ? $response["cidade"]["ddd"] : null;
31-
$this->city = array_key_exists("nome", $response["cidade"]) ? $response["cidade"]["nome"] : null;
29+
$this->ibge = array_key_exists("ibge", $response["cidade"]) ? $response["cidade"]["ibge"] : "";
30+
$this->ddd = array_key_exists("ddd", $response["cidade"]) ? $response["cidade"]["ddd"] : "";
31+
$this->city = array_key_exists("nome", $response["cidade"]) ? $response["cidade"]["nome"] : "";
3232
}
33-
$this->street = array_key_exists("logradouro", $response) ? $response["logradouro"] : null;
34-
$this->complement = array_key_exists("complemento", $response) ? $response["complemento"] : null;
35-
$this->area = array_key_exists("bairro", $response) ? $response["bairro"] : null;
33+
$this->street = array_key_exists("logradouro", $response) ? $response["logradouro"] : "";
34+
$this->complement = array_key_exists("complemento", $response) ? $response["complemento"] : "";
35+
$this->area = array_key_exists("bairro", $response) ? $response["bairro"] : "";
3636
if(array_key_exists("estado", $response)){
37-
$this->state = array_key_exists("sigla", $response["estado"]) ? $response["estado"]["sigla"] : null;
37+
$this->state = array_key_exists("sigla", $response["estado"]) ? $response["estado"]["sigla"] : "";
3838
}
39-
$this->longitude = array_key_exists("longitude", $response) ? $response["longitude"] : null;
40-
$this->latitude = array_key_exists("latitude", $response) ? $response["latitude"] : null;
41-
$this->altitude = array_key_exists("altitude", $response) ? $response["altitude"] : null;
39+
$this->longitude = array_key_exists("longitude", $response) ? $response["longitude"] : "";
40+
$this->latitude = array_key_exists("latitude", $response) ? $response["latitude"] : "";
41+
$this->altitude = array_key_exists("altitude", $response) ? $response["altitude"] : "";
4242
$this->cep = $cep;
4343
}
4444

0 commit comments

Comments
 (0)