1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NStack\Models; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class IpAddress |
7
|
|
|
* |
8
|
|
|
* @package NStack\Models |
9
|
|
|
* @author Tiago Araujo <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class IpAddress extends Model |
12
|
|
|
{ |
13
|
|
|
/** @var int */ |
14
|
|
|
protected $id; |
15
|
|
|
|
16
|
|
|
/** @var string */ |
17
|
|
|
protected $ipStart; |
18
|
|
|
|
19
|
|
|
/** @var string */ |
20
|
|
|
protected $ipEnd; |
21
|
|
|
|
22
|
|
|
/** @var string */ |
23
|
|
|
protected $country; |
24
|
|
|
|
25
|
|
|
/** @var string */ |
26
|
|
|
protected $stateProv; |
27
|
|
|
|
28
|
|
|
/** @var string */ |
29
|
|
|
protected $city; |
30
|
|
|
|
31
|
|
|
/** @var float */ |
32
|
|
|
protected $lat; |
33
|
|
|
|
34
|
|
|
/** @var float */ |
35
|
|
|
protected $lng; |
36
|
|
|
|
37
|
|
|
/** @var string */ |
38
|
|
|
protected $timeZoneOffset; |
39
|
|
|
|
40
|
|
|
/** @var string */ |
41
|
|
|
protected $timeZoneName; |
42
|
|
|
|
43
|
|
|
/** @var string */ |
44
|
|
|
protected $ispName; |
45
|
|
|
|
46
|
|
|
/** @var string */ |
47
|
|
|
protected $connectionType; |
48
|
|
|
|
49
|
|
|
/** @var string */ |
50
|
|
|
protected $type; |
51
|
|
|
|
52
|
|
|
/** @var string */ |
53
|
|
|
protected $requiredIp; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* parse |
57
|
|
|
* |
58
|
|
|
* @param array $data |
59
|
|
|
* @author Tiago Araujo <[email protected]> |
60
|
|
|
*/ |
61
|
2 |
|
public function parse(array $data) |
62
|
|
|
{ |
63
|
2 |
|
$this->id = (int)$data['id']; |
64
|
2 |
|
$this->ipStart = (string)$data['ip_start']; |
65
|
2 |
|
$this->ipEnd = (string)$data['ip_end']; |
66
|
2 |
|
$this->country = (string)$data['country']; |
67
|
2 |
|
$this->stateProv = (string)$data['state_prov']; |
68
|
2 |
|
$this->city = (string)$data['city']; |
69
|
2 |
|
$this->lat = (float)$data['lat']; |
70
|
2 |
|
$this->lng = (float)$data['lng']; |
71
|
2 |
|
$this->timeZoneOffset = (string)$data['time_zone_offset']; |
72
|
2 |
|
$this->timeZoneName = (string)$data['time_zone_name']; |
73
|
2 |
|
$this->ispName = (string)$data['isp_name']; |
74
|
2 |
|
$this->connectionType = (string)$data['connection_type']; |
75
|
2 |
|
$this->type = (string)$data['type']; |
76
|
2 |
|
$this->requiredIp = (string)$data['required_ip']; |
77
|
2 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* toArray |
81
|
|
|
* |
82
|
|
|
* @return array |
83
|
|
|
* @author Tiago Araujo <[email protected]> |
84
|
|
|
*/ |
85
|
|
|
public function toArray(): array |
86
|
|
|
{ |
87
|
|
|
return [ |
88
|
|
|
'id' => $this->id, |
89
|
|
|
'ip_start' => $this->ipStart, |
90
|
|
|
'ip_end' => $this->ipEnd, |
91
|
|
|
'country' => $this->country, |
92
|
|
|
'state_prov' => $this->stateProv, |
93
|
|
|
'city' => $this->city, |
94
|
|
|
'lat' => $this->lat, |
95
|
|
|
'lng' => $this->lng, |
96
|
|
|
'time_zone_offset' => $this->timeZoneOffset, |
97
|
|
|
'time_zone_name' => $this->timeZoneName, |
98
|
|
|
'isp_name' => $this->ispName, |
99
|
|
|
'connection_type' => $this->connectionType, |
100
|
|
|
'type' => $this->type, |
101
|
|
|
'required_ip' => $this->requiredIp, |
102
|
|
|
]; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return int |
107
|
|
|
*/ |
108
|
|
|
public function getId(): int |
109
|
|
|
{ |
110
|
|
|
return $this->id; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function getIpStart(): string |
117
|
|
|
{ |
118
|
|
|
return $this->ipStart; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
public function getIpEnd(): string |
125
|
|
|
{ |
126
|
|
|
return $this->ipEnd; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
|
|
public function getCountry(): string |
133
|
|
|
{ |
134
|
|
|
return $this->country; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return string |
139
|
|
|
*/ |
140
|
|
|
public function getStateProv(): string |
141
|
|
|
{ |
142
|
|
|
return $this->stateProv; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
public function getCity(): string |
149
|
|
|
{ |
150
|
|
|
return $this->city; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return float |
155
|
|
|
*/ |
156
|
|
|
public function getLat(): float |
157
|
|
|
{ |
158
|
|
|
return $this->lat; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return float |
163
|
|
|
*/ |
164
|
|
|
public function getLng(): float |
165
|
|
|
{ |
166
|
|
|
return $this->lng; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return string |
171
|
|
|
*/ |
172
|
|
|
public function getTimeZoneOffset(): string |
173
|
|
|
{ |
174
|
|
|
return $this->timeZoneOffset; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return string |
179
|
|
|
*/ |
180
|
|
|
public function getTimeZoneName(): string |
181
|
|
|
{ |
182
|
|
|
return $this->timeZoneName; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return string |
187
|
|
|
*/ |
188
|
|
|
public function getIspName(): string |
189
|
|
|
{ |
190
|
|
|
return $this->ispName; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return string |
195
|
|
|
*/ |
196
|
|
|
public function getConnectionType(): string |
197
|
|
|
{ |
198
|
|
|
return $this->connectionType; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return string |
203
|
|
|
*/ |
204
|
|
|
public function getType(): string |
205
|
|
|
{ |
206
|
|
|
return $this->type; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @return string |
211
|
|
|
*/ |
212
|
|
|
public function getRequiredIp(): string |
213
|
|
|
{ |
214
|
|
|
return $this->requiredIp; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
} |