Completed
Push — master ( fc24a2...683923 )
by wen
10:29
created

ArtisanServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 4
dl 0
loc 58
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A registerCommands() 0 8 2
A registerInstallCommand() 0 6 1
A registerComponentMakeCommand() 0 6 1
A provides() 0 4 1
1
<?php
2
3
namespace Sco\Admin\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
use Sco\Admin\Console\ComponentMakeCommand;
7
use Sco\Admin\Console\InstallCommand;
8
9
class ArtisanServiceProvider extends ServiceProvider
10
{
11
    protected $defer = true;
12
13
    protected $commands = [
14
        'Install' => 'command.install',
15
        'ComponentMake' => 'command.component.make',
16
    ];
17
18
    public function register()
19
    {
20
        $this->registerCommands($this->commands);
21
    }
22
23
    /**
24
     * Register the given commands.
25
     *
26
     * @param  array  $commands
27
     * @return void
28
     */
29
    protected function registerCommands(array $commands)
30
    {
31
        foreach (array_keys($commands) as $command) {
32
            call_user_func_array([$this, "register{$command}Command"], []);
33
        }
34
35
        $this->commands(array_values($commands));
36
    }
37
38
    /**
39
     * Register the command.
40
     *
41
     * @return void
42
     */
43
    protected function registerInstallCommand()
44
    {
45
        $this->app->singleton('command.install', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
            return new InstallCommand;
47
        });
48
    }
49
50
    /**
51
     * Register the command.
52
     *
53
     * @return void
54
     */
55
    protected function registerComponentMakeCommand()
56
    {
57
        $this->app->singleton('command.component.make', function ($app) {
58
            return new ComponentMakeCommand($app['files']);
59
        });
60
    }
61
62
    public function provides()
63
    {
64
        return array_values($this->commands);
65
    }
66
}
67