Completed
Push — master ( a52a56...4b8006 )
by Renato
09:08
created

CleanLogCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 9.4285
1
<?php
2
namespace NwLaravel\ActivityLog\Commands;
3
4
use Illuminate\Console\Command;
5
use NwLaravel\ActivityLog\ActivityManager;
6
7
class CleanLogCommand extends Command
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'activitylog:clean';
15
16
    /**
17
     * @var ActivityManager
18
     */
19
    protected $activity;
20
21
    /**
22
     * Construct
23
     *
24
     * @param ActivityManager $activity
25
     */
26
    public function __construct(ActivityManager $activity)
27
    {
28
        $this->activity = $activity;
29
    }
30
31
    /**
32
     * The console command description.
33
     *
34
     * @var string
35
     */
36
    protected $description = 'Clean up old records from the activity log.';
37
38
    /**
39
     * Handle Command
40
     * 
41
     * @return void
42
     */
43
    public function handle()
44
    {
45
        $this->comment('Cleaning activity log...');
46
47
        $amountDeleted = $this->activity->cleanLog();
48
49
        $this->info("Deleted {$amountDeleted} record(s) from the activity log.");
50
51
        $this->comment('All done!');
52
    }
53
}