CleanupCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 28
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 1
1
<?php
2
3
namespace tbclla\Revolut\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use tbclla\Revolut\Auth\AccessToken;
7
use Illuminate\Support\Str;
8
use tbclla\Revolut\Auth\RefreshToken;
9
10
class CleanupCommand extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'revolut:cleanup';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Delete all expired Revolut access tokens and refresh tokens.';
25
26
    /**
27
     * Execute the console command.
28
     *
29
     * @return mixed
30
     */
31
    public function handle()
32
    {
33
        $accessTokens = AccessToken::clearExpired();
34
        $this->info('Deleted ' . $accessTokens . ' expired access ' . Str::plural('token', $accessTokens));
35
36
        $refreshTokens = RefreshToken::clearExpired();
37
        $this->info('Deleted ' . $refreshTokens . ' expired refresh ' . Str::plural('token', $refreshTokens));
38
    }
39
}
40