Passed
Push — main ( b73123...a8595a )
by Garbuz
02:48
created

DeleteGlobalTokenCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Garbuzivan\Laraveltokens\Commands;
6
7
use Garbuzivan\Laraveltokens\TokenManager;
8
use Illuminate\Console\Command;
9
use Illuminate\Support\Composer;
10
11
class DeleteGlobalTokenCommand extends Command
12
{
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'tokens:global-delete {token}';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Удалить глобальный токен (tokens:global-delete {token})';
26
27
    /**
28
     * The console command signature.
29
     *
30
     * @var string
31
     */
32
    protected $signature = 'tokens:global-delete {token}';
33
34
    /**
35
     * @var Composer
36
     */
37
    public Composer $composer;
38
39
    /**
40
     * @var TokenManager
41
     */
42
    public TokenManager $TokenManager;
43
44
    /**
45
     * Create a new command instance.
46
     */
47
    public function __construct(TokenManager $TokenManager)
48
    {
49
        parent::__construct();
50
        $this->TokenManager = $TokenManager;
51
    }
52
53
    /**
54
     * Execute the command.
55
     *
56
     * @return mixed
57
     */
58
    public function handle()
59
    {
60
        $arguments = $this->arguments();
61
        $token = $arguments['token'] ?? null;
62
        if (is_null($token)) {
63
            $this->line('Токен не введен.');
64
            return 1;
65
        }
66
        $this->TokenManager->deleteGlobalToken($token);
67
        $this->line('Токен удален.');
68
        return 1;
69
    }
70
}
71