| Total Complexity | 3 |
| Total Lines | 111 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Response implements Arrayable |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * The IP address used to retrieve the geo-location. |
||
| 11 | * |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | public $ip; |
||
| 15 | /** |
||
| 16 | * The country code. |
||
| 17 | * |
||
| 18 | * @var string|null |
||
| 19 | */ |
||
| 20 | public $countryCode; |
||
| 21 | /** |
||
| 22 | * The country name. |
||
| 23 | * |
||
| 24 | * @var string|null |
||
| 25 | */ |
||
| 26 | public $countryName; |
||
| 27 | /** |
||
| 28 | * The region code. |
||
| 29 | * |
||
| 30 | * @var string|null |
||
| 31 | */ |
||
| 32 | public $regionCode; |
||
| 33 | /** |
||
| 34 | * The region name. |
||
| 35 | * |
||
| 36 | * @var string|null |
||
| 37 | */ |
||
| 38 | public $regionName; |
||
| 39 | /** |
||
| 40 | * The city name. |
||
| 41 | * |
||
| 42 | * @var string|null |
||
| 43 | */ |
||
| 44 | public $cityName; |
||
| 45 | /** |
||
| 46 | * The zip code. |
||
| 47 | * |
||
| 48 | * @var string|null |
||
| 49 | */ |
||
| 50 | public $zipCode; |
||
| 51 | /** |
||
| 52 | * The time zone. |
||
| 53 | * |
||
| 54 | * @var string|null |
||
| 55 | */ |
||
| 56 | public $timeZone; |
||
| 57 | /** |
||
| 58 | * The latitude. |
||
| 59 | * |
||
| 60 | * @var string|null |
||
| 61 | */ |
||
| 62 | public $latitude; |
||
| 63 | /** |
||
| 64 | * The longitude. |
||
| 65 | * |
||
| 66 | * @var string|null |
||
| 67 | */ |
||
| 68 | public $longitude; |
||
| 69 | /** |
||
| 70 | * The metro code. |
||
| 71 | * |
||
| 72 | * @var string|null |
||
| 73 | */ |
||
| 74 | public $metroCode; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Response constructor. |
||
| 78 | * |
||
| 79 | * @param array $driverResponse |
||
| 80 | */ |
||
| 81 | public function __construct($driverResponse) |
||
| 82 | { |
||
| 83 | $this->ip = $driverResponse['ip']; |
||
| 84 | $this->countryCode = $driverResponse['country_code']; |
||
| 85 | $this->countryName = $driverResponse['country_name']; |
||
| 86 | $this->regionCode = $driverResponse['region_code']; |
||
| 87 | $this->regionName = $driverResponse['region_name']; |
||
| 88 | $this->cityName = $driverResponse['city']; |
||
| 89 | $this->zipCode = $driverResponse['zip_code']; |
||
| 90 | $this->timeZone = $driverResponse['time_zone']; |
||
| 91 | $this->latitude = $driverResponse['latitude']; |
||
| 92 | $this->longitude = $driverResponse['longitude']; |
||
| 93 | $this->metroCode = $driverResponse['metro_code']; |
||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Determine if the response is empty. |
||
| 98 | * |
||
| 99 | * @return bool |
||
| 100 | */ |
||
| 101 | public function isEmpty() |
||
| 102 | { |
||
| 103 | $data = $this->toArray(); |
||
| 104 | |||
| 105 | unset($data['ip']); |
||
| 106 | |||
| 107 | return empty(array_filter($data)); |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Get the instance as an array. |
||
| 112 | * |
||
| 113 | * @return array |
||
| 114 | */ |
||
| 115 | public function toArray() |
||
| 118 | } |
||
| 119 | } |
||
| 120 |