Passed
Push — master ( 7a0761...b9ca99 )
by Bruno
03:45
created

ModelariumPublishCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 26 4
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Laravel\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Modelarium\Modelarium;
7
8
use function Safe\unlink;
9
10
class ModelariumPublishCommand extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'modelarium:publish';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Publishes project files from Modelarium';
25
26
    /**
27
     * Create a new command instance.
28
     *
29
     * @return void
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
        $this->info("Removing original User code.");
44
        $f = base_path('app/User.php');
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

44
        $f = /** @scrutinizer ignore-call */ base_path('app/User.php');
Loading history...
45
        if (file_exists($f)) {
46
            unlink($f);
47
        }
48
        $f = base_path('database/migrations/2014_10_12_000000_create_users_table.php');
49
        if (file_exists($f)) {
50
            unlink($f);
51
        }
52
53
        foreach (Modelarium::getDirectiveLaravelLibraries() as $plugin) {
54
            $this->call('vendor:publish', [
55
                '--provider' => "$plugin\\Laravel\\ServiceProvider",
56
                '--tag' => "schema",
57
                '--force' => true
58
            ]);
59
    
60
            $this->call('vendor:publish', [
61
                '--provider' => "$plugin\\Laravel\\ServiceProvider",
62
                '--tag' => "schemabase",
63
            ]);
64
        }
65
66
        $this->info("Setup done.");
67
    }
68
}
69