InstallCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
dl 0
loc 43
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 1
A setAppNamespace() 0 3 1
1
<?php
2
3
namespace Bakery\Console;
4
5
use Illuminate\Console\Command;
6
7
class InstallCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'bakery:install';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Install all Bakery resources';
22
23
    /**
24
     * Execute the console command.
25
     *
26
     * @return void
27
     */
28
    public function handle()
29
    {
30
        $this->comment('Publishing Bakery Configuration...');
31
        $this->callSilent('vendor:publish', ['--tag' => 'bakery-config']);
32
33
        $this->comment('Generating User Schema...');
34
        $this->callSilent('bakery:modelschema', ['name' => 'User']);
35
        copy(__DIR__.'/stubs/user-schema.stub', app_path('Bakery/User.php'));
36
37
        $this->setAppNamespace(app_path('Bakery/User.php'), $this->laravel->getNamespace());
38
    }
39
40
    /**
41
     * Set the namespace on the given file.
42
     *
43
     * @param string $file
44
     * @param string $namespace
45
     * @return void
46
     */
47
    public function setAppNamespace($file, $namespace)
48
    {
49
        file_put_contents($file, str_replace('App\\', $namespace, file_get_contents($file)));
50
    }
51
}
52