-
Notifications
You must be signed in to change notification settings - Fork 198
Expand file tree
/
Copy pathPosition.php
More file actions
133 lines (107 loc) · 2.46 KB
/
Copy pathPosition.php
File metadata and controls
133 lines (107 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
namespace Stevebauman\Location;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
class Position implements Arrayable
{
/**
* The IP address used to retrieve the location.
*/
public string $ip;
/**
* The driver used for retrieving the location.
*/
public string $driver;
/**
* The location's country name.
*/
public ?string $countryName = null;
/**
* The location's currency code.
*/
public ?string $currencyCode = null;
/**
* The location's country code.
*/
public ?string $countryCode = null;
/**
* The location's region code.
*/
public ?string $regionCode = null;
/**
* The location's region name.
*/
public ?string $regionName = null;
/**
* The location's city name.
*/
public ?string $cityName = null;
/**
* The location's zip code.
*/
public ?string $zipCode = null;
/**
* The location's ISO code.
*/
public ?string $isoCode = null;
/**
* The location's postal code.
*/
public ?string $postalCode = null;
/**
* The location's latitude.
*/
public ?string $latitude = null;
/**
* The location's longitude.
*/
public ?string $longitude = null;
/**
* The location's metro code.
*/
public ?string $metroCode = null;
/**
* The location's area code.
*/
public ?string $areaCode = null;
/**
* The location's timezone.
*/
public ?string $timezone = null;
/**
* If the location was retrieved from cache.
*/
public bool $cached = false;
/**
* Create a new position instance.
*/
public static function make(array $attributes = []): static
{
$instance = new static;
foreach ($attributes as $key => $value) {
$property = Str::camel($key);
if (property_exists($instance, $property)) {
$instance->{$property} = $value;
}
}
return $instance;
}
/**
* Determine if the position is empty.
*/
public function isEmpty(): bool
{
$data = Arr::except(
$this->toArray(), ['ip', 'driver']
);
return empty(array_filter($data));
}
/**
* Transform the instance to an array.
*/
public function toArray(): array
{
return get_object_vars($this);
}
}