Skip to content

Commit

Permalink
trata $json->response quando o JSON está vazio
Browse files Browse the repository at this point in the history
  • Loading branch information
wgnann committed Jan 31, 2025
1 parent dc4030d commit a6c5aa8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/IDMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static function extract_email($json, $domain, $type)
{
# dtainival deixou de existir por enquanto
#$last = ['date' => 0, 'email' => null];
if ($json->response == true) {
if (isset($json->response) and $json->response == true) {
$last = ['date' => 0, 'email' => null,];
foreach ($json->result as $data) {
if (in_array($data->tipema, $type)) {
Expand All @@ -118,7 +118,7 @@ static function extract_email($json, $domain, $type)
static function extract_lists($json, $domain, $type)
{
$emails = [];
if ($json->response == true) {
if (isset($json->response) and $json->response == true) {
foreach ($json->result as $data) {
if (in_array($data->tipema, $type)) {
$email = $data->emausp;
Expand Down Expand Up @@ -167,7 +167,7 @@ static function cache_find_email($nusp, $type)

$json = json_decode($cache);
$last = ['date' => 0, 'email' => null];
if ($json->response == true) {
if (isset($json->response) and $json->response == true) {
foreach ($json->result as $email => $data) {
if (in_array($data->tipo, $type) and $data->codpes == $nusp) {
$date = strtotime($data->dtainival);
Expand Down

0 comments on commit a6c5aa8

Please sign in to comment.