@@ -13,14 +13,7 @@ class Visit extends Entity
1313 // magic IP string/long converters
1414 public function setIpAddress ($ ipAddress )
1515 {
16- if ($ long = ip2long ($ ipAddress ))
17- {
18- $ this ->attributes ['ip_address ' ] = $ long ;
19- }
20- else
21- {
22- $ this ->attributes ['ip_address ' ] = $ ipAddress ;
23- }
16+ $ this ->attributes ['ip_address ' ] = ($ long = ip2long ($ ipAddress )) ? $ long : $ ipAddress ;
2417
2518 return $ this ;
2619 }
@@ -31,10 +24,8 @@ public function getIpAddress(string $format = 'long')
3124 {
3225 return long2ip ($ this ->attributes ['ip_address ' ]);
3326 }
34- else
35- {
36- return $ this ->attributes ['ip_address ' ];
37- }
27+
28+ return $ this ->attributes ['ip_address ' ];
3829 }
3930
4031 // search for a visit with similar characteristics to the current one
@@ -54,13 +45,12 @@ public function getSimilar($trackingMethod, $resetMinutes = 60)
5445 $ visits = new VisitModel ();
5546 // check for matching components within the last resetMinutes
5647 $ since = date ('Y-m-d H:i:s ' , strtotime ('- ' . $ resetMinutes . ' minutes ' ));
57- $ similar = $ visits ->where ('host ' , $ this ->host )
48+
49+ return $ visits ->where ('host ' , $ this ->host )
5850 ->where ('path ' , $ this ->path )
5951 ->where ('query ' , (string )$ this ->query )
6052 ->where ($ trackingMethod , $ this ->{$ trackingMethod })
6153 ->where ('created_at >= ' , $ since )
6254 ->first ();
63-
64- return $ similar ;
6555 }
6656}
0 commit comments