Skip to content

Commit

Permalink
Merge pull request #308 from td204/master
Browse files Browse the repository at this point in the history
Check if array key exists for address_components (fixes undefined offset: 0)
  • Loading branch information
bradcornford authored Mar 10, 2019
2 parents f56b90a + 8b1a766 commit 785e8c1
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 785e8c1

Please sign in to comment.