Skip to content

Commit 4889d6c

Browse files
StadlyNyholm
authored andcommitted
HostIp: Return empty collection if address was not found (#812)
* Return empty collection if address was not found If the location of the ip address cannot be determined by HostIp, return an empty AddressCollection instead of dummy data. This is particularly useful when using the Chain provider. * Fix code style Fix code style
1 parent 142f29c commit 4889d6c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

HostIp.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ private function executeQuery(string $url): AddressCollection
8585
return new AddressCollection([]);
8686
}
8787

88+
// Return empty collection if address was not found
89+
if (null === $data['lat']
90+
&& null === $data['lng']
91+
&& '(Unknown City?)' === $data['city']
92+
&& '(Unknown Country?)' === $data['country_name']
93+
&& 'XX' === $data['country_code']) {
94+
return new AddressCollection([]);
95+
}
96+
97+
// Return empty collection if address was not found
98+
if (null === $data['lat']
99+
&& null === $data['lng']
100+
&& '(Private Address)' === $data['city']
101+
&& '(Private Address)' === $data['country_name']
102+
&& 'XX' === $data['country_code']) {
103+
return new AddressCollection([]);
104+
}
105+
88106
return new AddressCollection([
89107
Address::createFromArray([
90108
'providedBy' => $this->getName(),

0 commit comments

Comments
 (0)