ArtisanServiceProvider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Test Coverage

Coverage 86.36%

Importance

Changes 0
Metric Value
wmc 7
c 0
b 0
f 0
lcom 2
cbo 5
dl 0
loc 72
ccs 19
cts 22
cp 0.8636
rs 10

6 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 registerObserverMakeCommand() 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
use Sco\Admin\Console\ObserverMakeCommand;
9
10
class ArtisanServiceProvider extends ServiceProvider
11
{
12
    protected $defer = true;
13
14
    protected $commands = [
15
        'Install'       => 'command.install',
16
        'ComponentMake' => 'command.component.make',
17
        'ObserverMake'  => 'command.observer.make',
18
    ];
19
20 48
    public function register()
21
    {
22 48
        $this->registerCommands($this->commands);
23 48
    }
24
25
    /**
26
     * Register the given commands.
27
     *
28
     * @param  array $commands
29
     *
30
     * @return void
31
     */
32 48
    protected function registerCommands(array $commands)
33
    {
34 48
        foreach (array_keys($commands) as $command) {
35 48
            call_user_func_array([$this, "register{$command}Command"], []);
36
        }
37
38 48
        $this->commands(array_values($commands));
39 48
    }
40
41
    /**
42
     * Register the command.
43
     *
44
     * @return void
45
     */
46
    protected function registerInstallCommand()
47
    {
48 48
        $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...
49
            return new InstallCommand;
50 48
        });
51 48
    }
52
53
    /**
54
     * Register the command.
55
     *
56
     * @return void
57
     */
58
    protected function registerComponentMakeCommand()
59
    {
60 48
        $this->app->singleton('command.observer.make', function ($app) {
61
            return new ObserverMakeCommand($app['files']);
62 48
        });
63 48
    }
64
65
    /**
66
     * Register the command.
67
     *
68
     * @return void
69
     */
70
    protected function registerObserverMakeCommand()
71
    {
72 48
        $this->app->singleton('command.component.make', function ($app) {
73
            return new ComponentMakeCommand($app['files']);
74 48
        });
75 48
    }
76
77 3
    public function provides()
78
    {
79 3
        return array_values($this->commands);
80
    }
81
}
82