Completed
Push — master ( 284085...99e334 )
by Fumio
02:01
created

ServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 15

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 91
ccs 36
cts 36
cp 1
rs 9.1666
c 1
b 0
f 0
wmc 4
lcom 1
cbo 15

4 Methods

Rating   Name   Duplication   Size   Complexity  
A registerClassResolvers() 0 8 1
A register() 0 21 1
A boot() 0 8 1
B registerCommands() 0 30 1
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 2
    public function register()
21
    {
22 2
        $app = $this->app;
23
24 2
        $app->instance('addon', $this->environment = new Environment($app));
25 2
        $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 2
        });
30
31 2
        $this->registerCommands();
32
33 2
        $app['events']->fire(new Events\AddonWorldCreated($this->environment));
34
35 2
        $this->registerClassResolvers();
36
37 2
        (new Registrar)->register($app, $this->environment->addons());
38
39 2
        $app['events']->fire(new Events\AddonRegistered($this->environment));
40 2
    }
41
42
    /**
43
     * Register the cache related console commands.
44
     */
45 2
    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 1
            return new Commands\AddonListCommand();
49 2
        });
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 1
            return new Commands\AddonStatusCommand();
53 2
        });
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 1
            return new Commands\AddonMakeCommand();
57 2
        });
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 1
            return new Commands\AddonNameCommand();
61 2
        });
62
63 2
        $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 1
            return new Commands\AddonRemoveCommand();
65 2
        });
66
67 2
        $this->commands([
68 2
            'command.addon.list',
69
            'command.addon.status',
70
            'command.addon.make',
71
            'command.addon.name',
72
            'command.addon.remove',
73
        ]);
74 2
    }
75
76
    /**
77
     */
78 2
    protected function registerClassResolvers()
79
    {
80 2
        $addons = $this->environment->addons();
81
82 2
        ClassLoader::register($this->environment, $addons);
83
84 2
        AliasResolver::register($this->app['path'], $addons, $this->app['config']->get('app.aliases', []));
85 2
    }
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