CleanupCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 39
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 6 1
1
<?php
2
3
namespace Clarkeash\Doorman\Commands;
4
5
use Clarkeash\Doorman\Models\BaseInvite;
6
use Illuminate\Console\Command;
7
8
class CleanupCommand extends Command
9
{
10
    /**
11
     * @var BaseInvite
12
     */
13
    protected $invite;
14
15 62
    public function __construct(BaseInvite $invite)
16
    {
17 62
        parent::__construct();
18 62
        $this->invite = $invite;
19 62
    }
20
21
    /**
22
     * The console command signature.
23
     *
24
     * @var string
25
     */
26
    protected $signature = 'doorman:cleanup';
27
    
28
    /**
29
     * The console command description.
30
     *
31
     * @var string
32
     */
33
    protected $description = 'Remove expired invites from the database.';
34
    
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40 1
    public function handle()
41
    {
42 1
        $useless = $this->invite->useless()->count();
43 1
        $this->invite->useless()->delete();
44 1
        $this->info('Successfully deleted ' . $useless . ' expired invites from the database.');
45 1
    }
46
}
47