Completed
Push — master ( 2f4806...4e3d73 )
by Renato
05:45
created

CleanLogCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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 $name = 'activitylog:clean';
15
16
    /**
17
     * @var ActivityManager
18
     */
19
    protected $activity;
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description = 'Clean up old records from the activity log.';
27
28
    /**
29
     * Construct
30
     *
31
     * @param ActivityManager $activity
32
     */
33 1
    public function __construct(ActivityManager $activity)
34
    {
35 1
        parent::__construct();
36 1
        $this->activity = $activity;
37 1
    }
38
39
    /**
40
     * Handle Command
41
     *
42
     * @return void
43
     */
44 1
    public function fire()
45
    {
46 1
        $this->comment('Cleaning activity log...');
47
48 1
        $amountDeleted = $this->activity->cleanLog();
49
50 1
        $this->info("Deleted {$amountDeleted} record(s) from the activity log.");
51
52 1
        $this->comment('All done!');
53 1
    }
54
}
55