Completed
Push — master ( 78b3b4...1185ef )
by Fumio
02:21
created

ServiceProvider::registerCommands()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1.0156

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 0
dl 0
loc 30
ccs 15
cts 20
cp 0.75
crap 1.0156
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace Jumilla\Addomnipot\Laravel;
4
5
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
6
use Illuminate\Contracts\Http\Kernel as HttpKernel;
7
8
class ServiceProvider extends BaseServiceProvider
9
{
10
    /**
11
     * Addon environment.
12
     *
13
     * @var \Jumilla\Addomnipot\Laravel\Environment
14
     */
15
    protected $environment;
16
17
    /**
18
     * Register the service provider.
19
     */
20 1
    public function register()
21
    {
22 1
        $app = $this->app;
23
24 1
        $app->instance('addon', $this->environment = new Environment($app));
25 1
        $app->alias('addon', Environment::class);
26
27
        $app->singleton(Generator::class, 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...
28
            return new Generator();
29 1
        });
30
31 1
        $this->registerCommands();
32
33 1
        $app['events']->fire(new Events\AddonWorldCreated($this->environment));
34
35 1
        $this->registerClassResolvers();
36
37 1
        (new Registrar)->register($app, $this->environment->addons());
38
39 1
        $app['events']->fire(new Events\AddonRegistered($this->environment));
40 1
    }
41
42
    /**
43
     * Register the cache related console commands.
44
     */
45 1
    public function registerCommands()
46
    {
47
        $this->app->singleton('command.addon.list', 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...
48
            return new Console\AddonListCommand();
49 1
        });
50
51
        $this->app->singleton('command.addon.status', 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...
52
            return new Console\AddonStatusCommand();
53 1
        });
54
55
        $this->app->singleton('command.addon.make', 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...
56
            return new Console\AddonMakeCommand();
57 1
        });
58
59
        $this->app->singleton('command.addon.name', 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...
60
            return new Console\AddonNameCommand();
61 1
        });
62
63 1
        $this->app->singleton('command.addon.remove', 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...
64
            return new Console\AddonRemoveCommand();
65 1
        });
66
67 1
        $this->commands([
68 1
            'command.addon.list',
69 1
            'command.addon.status',
70 1
            'command.addon.make',
71 1
            'command.addon.name',
72 1
            'command.addon.remove',
73 1
        ]);
74 1
    }
75
76
    /**
77
     */
78 1
    protected function registerClassResolvers()
79
    {
80 1
        $addons = $this->environment->addons();
81
82 1
        ClassLoader::register($this->environment, $addons);
83
84 1
        AliasResolver::register($this->app['path'], $addons, $this->app['config']->get('app.aliases'));
85 1
    }
86
87
    /**
88
     * Boot the service provider.
89
     */
90 1
    public function boot()
91
    {
92 1
        $app = $this->app;
93
94 1
        (new Registrar)->boot($app, $this->environment->addons());
95
96 1
        $app['events']->fire(new Events\AddonBooted($this->environment));
97 1
    }
98
}
99