Completed
Push — master ( 0e1003...1276c7 )
by Abdelrahman
61:46 queued 59:06
created

CoreRollbackCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Console\Commands;
6
7
use Illuminate\Console\Command;
8
use Illuminate\Support\Facades\Artisan;
9
use Symfony\Component\Console\Input\ArrayInput;
10
11
class CoreRollbackCommand extends Command
12
{
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'cortex:rollback {--force : Force the operation to run when in production.}';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Rollback Cortex Tables.';
26
27
    /**
28
     * Execute the console command.
29
     *
30
     * @return void
31
     */
32
    public function handle(): void
33
    {
34
        collect(Artisan::all())->filter(function ($command) {
35
            return mb_strpos($command->getName(), 'cortex:rollback:') !== false;
36
        })->partition(function ($command) {
37
            return in_array($command->getName(), ['cortex:rollback:foundation', 'cortex:rollback:auth']);
38
        })->flatten()->each->run(new ArrayInput(['--force' => $this->option('force')]), $this->output);
39
    }
40
}
41