| 1441 |
ariadna |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace GeoIp2\Model;
|
|
|
6 |
|
|
|
7 |
use GeoIp2\Util;
|
|
|
8 |
|
|
|
9 |
/**
|
|
|
10 |
* This class provides the GeoIP2 ISP model.
|
|
|
11 |
*/
|
|
|
12 |
class Isp implements \JsonSerializable
|
|
|
13 |
{
|
|
|
14 |
/**
|
|
|
15 |
* @var int|null the autonomous system number
|
|
|
16 |
* associated with the IP address
|
|
|
17 |
*/
|
|
|
18 |
public readonly ?int $autonomousSystemNumber;
|
|
|
19 |
|
|
|
20 |
/**
|
|
|
21 |
* @var string|null the organization
|
|
|
22 |
* associated with the registered autonomous system number for the IP
|
|
|
23 |
* address
|
|
|
24 |
*/
|
|
|
25 |
public readonly ?string $autonomousSystemOrganization;
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* @var string|null the name of the ISP associated with the IP
|
|
|
29 |
* address
|
|
|
30 |
*/
|
|
|
31 |
public readonly ?string $isp;
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
* @var string|null The [mobile country code
|
|
|
35 |
* (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
|
|
|
36 |
* the IP address and ISP.
|
|
|
37 |
*/
|
|
|
38 |
public readonly ?string $mobileCountryCode;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* @var string|null The [mobile network code
|
|
|
42 |
* (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
|
|
|
43 |
* the IP address and ISP.
|
|
|
44 |
*/
|
|
|
45 |
public readonly ?string $mobileNetworkCode;
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* @var string|null the name of the organization associated
|
|
|
49 |
* with the IP address
|
|
|
50 |
*/
|
|
|
51 |
public readonly ?string $organization;
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* @var string the IP address that the data in the model is
|
|
|
55 |
* for
|
|
|
56 |
*/
|
|
|
57 |
public readonly string $ipAddress;
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* @var string The network in CIDR notation associated with
|
|
|
61 |
* the record. In particular, this is the largest network where all of the
|
|
|
62 |
* fields besides $ipAddress have the same value.
|
|
|
63 |
*/
|
|
|
64 |
public readonly string $network;
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* @ignore
|
|
|
68 |
*
|
|
|
69 |
* @param array<string, mixed> $raw
|
|
|
70 |
*/
|
|
|
71 |
public function __construct(array $raw)
|
|
|
72 |
{
|
|
|
73 |
$this->autonomousSystemNumber = $raw['autonomous_system_number'] ?? null;
|
|
|
74 |
$this->autonomousSystemOrganization =
|
|
|
75 |
$raw['autonomous_system_organization'] ?? null;
|
|
|
76 |
$this->isp = $raw['isp'] ?? null;
|
|
|
77 |
$this->mobileCountryCode = $raw['mobile_country_code'] ?? null;
|
|
|
78 |
$this->mobileNetworkCode = $raw['mobile_network_code'] ?? null;
|
|
|
79 |
$this->organization = $raw['organization'] ?? null;
|
|
|
80 |
|
|
|
81 |
$ipAddress = $raw['ip_address'];
|
|
|
82 |
$this->ipAddress = $ipAddress;
|
|
|
83 |
$this->network = Util::cidr($ipAddress, $raw['prefix_len']);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* @return array<string, mixed>|null
|
|
|
88 |
*/
|
|
|
89 |
public function jsonSerialize(): ?array
|
|
|
90 |
{
|
|
|
91 |
$js = [];
|
|
|
92 |
if ($this->autonomousSystemNumber !== null) {
|
|
|
93 |
$js['autonomous_system_number'] = $this->autonomousSystemNumber;
|
|
|
94 |
}
|
|
|
95 |
if ($this->autonomousSystemOrganization !== null) {
|
|
|
96 |
$js['autonomous_system_organization'] = $this->autonomousSystemOrganization;
|
|
|
97 |
}
|
|
|
98 |
if ($this->isp !== null) {
|
|
|
99 |
$js['isp'] = $this->isp;
|
|
|
100 |
}
|
|
|
101 |
if ($this->mobileCountryCode !== null) {
|
|
|
102 |
$js['mobile_country_code'] = $this->mobileCountryCode;
|
|
|
103 |
}
|
|
|
104 |
if ($this->mobileNetworkCode !== null) {
|
|
|
105 |
$js['mobile_network_code'] = $this->mobileNetworkCode;
|
|
|
106 |
}
|
|
|
107 |
if ($this->organization !== null) {
|
|
|
108 |
$js['organization'] = $this->organization;
|
|
|
109 |
}
|
|
|
110 |
$js['ip_address'] = $this->ipAddress;
|
|
|
111 |
$js['network'] = $this->network;
|
|
|
112 |
|
|
|
113 |
return $js;
|
|
|
114 |
}
|
|
|
115 |
}
|