Skip to content

Commit

Permalink
check if array key exists, fixes undefined offset: 0 error
Browse files Browse the repository at this point in the history
  • Loading branch information
td204 committed Nov 5, 2018
1 parent 0642853 commit 8b1a766
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Cornford/Googlmapper/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function location($location)
$postalCode = null;

foreach ($resultObject->results[0]->address_components as $addressComponent) {
if ($addressComponent->types[0] == 'postal_code') {
if (count($addressComponent->types) > 0 && $addressComponent->types[0] == 'postal_code') {
$postalCode = $addressComponent->long_name;
}
}
Expand Down

0 comments on commit 8b1a766

Please sign in to comment.