Skip to content

Commit 85a4268

Browse files
committed
Apply Rector
1 parent d4d24a0 commit 85a4268

File tree

6 files changed

+17
-26
lines changed

6 files changed

+17
-26
lines changed

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@
115115
$rectorConfig
116116
->ruleWithConfiguration(TypedPropertyRector::class, [
117117
// Set to false if you use in libraries, or it does create breaking changes.
118-
TypedPropertyRector::INLINE_PUBLIC => true,
118+
TypedPropertyRector::INLINE_PUBLIC => false,
119119
]);
120120
};

src/Config/Events.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
use CodeIgniter\Events\Events;
44
use Config\Services;
55

6-
Events::on('post_controller_constructor', function () {
7-
// Ignore CLI requests
8-
return is_cli() ?: service('visits')->record();
9-
});
6+
Events::on('post_controller_constructor', fn() => // Ignore CLI requests
7+
is_cli() ?: service('visits')->record());

src/Config/Services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static function visits(VisitsConfig $config = null, bool $getShared = tru
1313
return static::getSharedInstance('visits', $config);
1414
}
1515

16-
$config = $config ?? config('Visits');
16+
$config ??= config('Visits');
1717

1818
return new Visits($config);
1919
}

src/Entities/Visit.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/Language/en/Visits.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Tatter\Visits\Language\en;
4+
35
return [
46
'noTrackingMethod' => 'No tracking method selected.',
57
'invalidResetMinutes' => 'Minutes-to-reset must be a positive integer or zero.',

src/Visits.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace Tatter\Visits;
22

3+
use CodeIgniter\Session\Session;
34
use CodeIgniter\Config\BaseConfig;
45
use CodeIgniter\Config\Services;
56
use CodeIgniter\Database\ConnectionInterface;
@@ -25,11 +26,11 @@ class Visits
2526
protected $db;
2627

2728
/**
28-
* The active user session, for session data and tracking.
29-
*
30-
* @var \CodeIgniter\Session\Session
31-
*/
32-
protected $session;
29+
* The active user session, for session data and tracking.
30+
*
31+
* @var Session
32+
*/
33+
protected $session;
3334

3435
// initiate library, check for existing session
3536
public function __construct(VisitsConfig $config, $db = null)

0 commit comments

Comments
 (0)