Passed
Push — master ( 82c975...d842e2 )
by Darko
09:44
created

RemoveCrapReleases::handle()   A

Complexity

Conditions 4
Paths 10

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 26
rs 9.7333
cc 4
nc 10
nop 0
1
<?php
2
3
namespace App\Console\Commands;
4
5
use Blacklight\ReleaseRemover;
6
use Illuminate\Console\Command;
7
8
class RemoveCrapReleases extends Command
9
{
10
    protected $signature = 'releases:remove-crap
11
                            {--type= : Type of crap to remove}
12
                            {--time=full : Time limit in hours or full}
13
                            {--blacklist-id= : Specific blacklist ID}
14
                            {--delete : Actually delete releases}';
15
16
    protected $description = 'Remove crap releases based on various criteria';
17
18
    public function __construct()
19
    {
20
        parent::__construct();
21
    }
22
23
    public function handle(): int
24
    {
25
        $type = $this->option('type') ?? '';
26
        $time = $this->option('time') ?? 'full';
27
        $blacklistId = $this->option('blacklist-id') ?? '';
28
        $delete = $this->option('delete');
29
30
        if (! $delete) {
31
            $this->warn('Running in DRY-RUN mode. Use --delete to actually remove releases.');
32
        }
33
34
        try {
35
            $remover = new ReleaseRemover;
36
            $result = $remover->removeCrap($delete, $time, $type, $blacklistId);
0 ignored issues
show
Bug introduced by
$delete of type string is incompatible with the type boolean expected by parameter $delete of Blacklight\ReleaseRemover::removeCrap(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
            $result = $remover->removeCrap(/** @scrutinizer ignore-type */ $delete, $time, $type, $blacklistId);
Loading history...
37
38
            if ($result === true) {
39
                return self::SUCCESS;
40
            }
41
42
            $this->error($result);
0 ignored issues
show
Bug introduced by
$result of type false is incompatible with the type string expected by parameter $string of Illuminate\Console\Command::error(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
            $this->error(/** @scrutinizer ignore-type */ $result);
Loading history...
43
44
            return self::FAILURE;
45
        } catch (\Exception $e) {
46
            $this->error($e->getMessage());
47
48
            return self::FAILURE;
49
        }
50
    }
51
}
52