3131 * not "foo.example.com". This attribute is only available from the
3232 * City Plus and Insights web services and the GeoIP2 Enterprise
3333 * database.
34- * @property-read string $ipAddress The IP address that the data in the model
34+ * @property-read string|null $ipAddress The IP address that the data in the model
3535 * is for. If you performed a "me" lookup against the web service, this
3636 * will be the externally routable IP address for the system the code is
3737 * running on. If the system is behind a NAT, this may differ from the IP
7070 * @property-read string|null $isp The name of the ISP associated with the IP
7171 * address. This attribute is only available from the City Plus and Insights
7272 * web services and the GeoIP2 Enterprise database.
73- * @property-read string $network The network in CIDR notation associated with
73+ * @property-read string|null $network The network in CIDR notation associated with
7474 * the record. In particular, this is the largest network where all of the
7575 * fields besides $ipAddress have the same value.
7676 * @property-read string|null $organization The name of the organization
@@ -122,7 +122,7 @@ class Traits implements \JsonSerializable
122122 public readonly ?string $ autonomousSystemOrganization ;
123123 public readonly ?string $ connectionType ;
124124 public readonly ?string $ domain ;
125- public readonly string $ ipAddress ;
125+ public readonly ? string $ ipAddress ;
126126 public readonly bool $ isAnonymous ;
127127 public readonly bool $ isAnonymousProxy ;
128128 public readonly bool $ isAnonymousVpn ;
@@ -135,7 +135,7 @@ class Traits implements \JsonSerializable
135135 public readonly bool $ isTorExitNode ;
136136 public readonly ?string $ mobileCountryCode ;
137137 public readonly ?string $ mobileNetworkCode ;
138- public readonly string $ network ;
138+ public readonly ? string $ network ;
139139 public readonly ?string $ organization ;
140140 public readonly ?float $ staticIpScore ;
141141 public readonly ?int $ userCount ;
@@ -168,7 +168,7 @@ public function __construct(array $record)
168168 if (isset ($ record ['network ' ])) {
169169 $ this ->network = $ record ['network ' ];
170170 } else {
171- $ this ->network = Util::cidr ($ this ->ipAddress , $ record ['prefix_len ' ] ?? 0 ) ;
171+ $ this ->network = isset ( $ record [ ' prefix_len ' ]) ? Util::cidr ($ this ->ipAddress , $ record ['prefix_len ' ]) : null ;
172172 }
173173 }
174174
@@ -187,7 +187,9 @@ public function jsonSerialize(): array
187187 if ($ this ->domain !== null ) {
188188 $ js ['domain ' ] = $ this ->domain ;
189189 }
190- $ js ['ip_address ' ] = $ this ->ipAddress ;
190+ if ($ this ->ipAddress !== null ) {
191+ $ js ['ip_address ' ] = $ this ->ipAddress ;
192+ }
191193 if ($ this ->isAnonymous !== false ) {
192194 $ js ['is_anonymous ' ] = $ this ->isAnonymous ;
193195 }
@@ -224,7 +226,9 @@ public function jsonSerialize(): array
224226 if ($ this ->mobileNetworkCode !== null ) {
225227 $ js ['mobile_network_code ' ] = $ this ->mobileNetworkCode ;
226228 }
227- $ js ['network ' ] = $ this ->network ;
229+ if ($ this ->network !== null ) {
230+ $ js ['network ' ] = $ this ->network ;
231+ }
228232 if ($ this ->organization !== null ) {
229233 $ js ['organization ' ] = $ this ->organization ;
230234 }
0 commit comments