for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Psonrie\GeoLocation;
use Illuminate\Contracts\Support\Arrayable;
class Response implements Arrayable
{
/**
* The IP address used to retrieve the geo-location.
*
* @var string
*/
public $ip;
* The country code.
* @var string|null
public $countryCode;
* The country name.
public $countryName;
* The region name.
public $regionName;
* The city name.
public $cityName;
* The zip code.
public $zipCode;
* The latitude.
public $latitude;
* The longitude.
public $longitude;
* Response constructor.
* @param array $driverResponse
public function __construct($driverResponse)
$this->ip = $driverResponse['ip'] ?? $driverResponse['IPv4'];
$this->countryCode = $driverResponse['country_code'];
$this->countryName = $driverResponse['country_name'];
$this->regionName = $driverResponse['state'];
$this->cityName = $driverResponse['city'];
$this->zipCode = $driverResponse['postal'];
$this->latitude = $driverResponse['latitude'];
$this->longitude = $driverResponse['longitude'];
}
* Determine if the response is empty.
* @return bool
public function isEmpty()
$data = $this->toArray();
unset($data['ip']);
return empty(array_filter($data));
* Get the instance as an array.
* @return array
public function toArray()
return get_object_vars($this);