File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public function setIpAddress($ipAddress): void
5252 */
5353 public function getIpAddress (): ?string
5454 {
55- if (is_int ($ this ->attributes ['ip_address ' ])) {
55+ if (is_numeric ($ this ->attributes ['ip_address ' ])) {
5656 return long2ip ($ this ->attributes ['ip_address ' ]);
5757 }
5858
Original file line number Diff line number Diff line change @@ -37,4 +37,20 @@ public function ipAddressProvider(): array
3737 [null , null , null ],
3838 ];
3939 }
40+
41+ public function testIpAddressHandlesStrings (): void
42+ {
43+ $ visit = new Visit ();
44+ $ visit ->setAttributes ([
45+ 'ip_address ' => '2130706433 ' ,
46+ ]);
47+
48+ $ result = $ visit ->getIpAddress ();
49+ $ this ->assertSame ('127.0.0.1 ' , $ result );
50+
51+ $ visit ->setAttributes ([
52+ 'ip_address ' => 'foo ' ,
53+ ]);
54+ $ this ->assertNull ($ visit ->getIpAddress ());
55+ }
4056}
You can’t perform that action at this time.
0 commit comments