ProcessSafe   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 19
dl 0
loc 46
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 26 3
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Services\ForkingService;
6
use Illuminate\Console\Command;
7
8
class ProcessSafe extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'multiprocessing:safe
16
                            {type : Type: binaries or backfill}';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Safe binaries or backfill update using multiprocessing';
24
25
    /**
26
     * Execute the console command.
27
     */
28
    public function handle(): int
29
    {
30
        $type = $this->argument('type');
31
32
        if (! \in_array($type, ['backfill', 'binaries'], true)) {
33
            $this->error('Type must be either: binaries or backfill');
34
            $this->line('');
35
            $this->line('binaries => Do Safe Binaries update');
36
            $this->line('backfill => Do Safe Backfill update');
37
38
            return self::FAILURE;
39
        }
40
41
        try {
42
            $service = new ForkingService;
43
44
            match ($type) {
45
                'binaries' => $service->safeBinaries(),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $service->safeBinaries() targeting App\Services\ForkingService::safeBinaries() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
46
                'backfill' => $service->safeBackfill(),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $service->safeBackfill() targeting App\Services\ForkingService::safeBackfill() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
47
            };
48
49
            return self::SUCCESS;
50
        } catch (\Exception $e) {
51
            $this->error($e->getMessage());
52
53
            return self::FAILURE;
54
        }
55
    }
56
}
57