CleanCommand::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 6
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Awssat\Visits\Commands;
4
5
use Awssat\Visits\Models\Visit;
6
use Illuminate\Console\Command;
7
8
class CleanCommand extends Command
9
{
10
    protected $signature = 'visits:clean';
11
    protected $description = '(Laravel-Visits) Clean expired keys and visits.';
12
13
14
    public function __construct()
15
    {
16
        parent::__construct();
17
    }
18
19
    public function handle()
20
    {
21
        $currentEngine = config('visits.engine') ?? '';
22
23
        if($currentEngine == 'eloquent') {
24
            $this->cleanEloquent();
25
        }
26
    }
27
28
    protected function cleanEloquent()
29
    {
30
        Visit::where('expired_at', '<', \Carbon\Carbon::now())->delete();
31
    }
32
}
33