Completed
Push — master ( 880a30...6b3c1e )
by Fumio
02:31
created

ServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 11

Test Coverage

Coverage 82.35%

Importance

Changes 3
Bugs 2 Features 1
Metric Value
wmc 3
c 3
b 2
f 1
lcom 1
cbo 11
dl 0
loc 73
ccs 28
cts 34
cp 0.8235
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 1
B registerCommands() 0 30 1
A registerClassResolvers() 0 8 1
1
<?php
2
3
namespace Jumilla\Addomnipot\Laravel;
4
5
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
6
7
class ServiceProvider extends BaseServiceProvider
8
{
9
    /**
10
     * Addon environment.
11
     *
12
     * @var \Jumilla\Addomnipot\Laravel\Environment
13
     */
14
    protected $addonEnvironment;
15
16
    /**
17
     * Register the service provider.
18
     */
19 1
    public function register()
20
    {
21 1
        $app = $this->app;
22
23 1
        $app->instance('addon', $this->addonEnvironment = new Environment($app));
24 1
        $app->alias('addon', Environment::class);
25
26
        $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...
27
            return new Generator();
28 1
        });
29
30 1
        $this->registerCommands();
31
32 1
        $this->registerClassResolvers();
33 1
    }
34
35
    /**
36
     * Register the cache related console commands.
37
     */
38 1
    public function registerCommands()
39
    {
40
        $this->app->singleton('command.addon.check', 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...
41
            return new Console\AddonCheckCommand();
42 1
        });
43
44
        $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...
45
            return new Console\AddonMakeCommand();
46 1
        });
47
48
        $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...
49
            return new Console\AddonNameCommand();
50 1
        });
51
52
        $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...
53
            return new Console\AddonRemoveCommand();
54 1
        });
55
56 1
        $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...
57
            return new Console\AddonStatusCommand();
58 1
        });
59
60 1
        $this->commands([
61 1
            'command.addon.check',
62 1
            'command.addon.make',
63 1
            'command.addon.name',
64 1
            'command.addon.remove',
65 1
            'command.addon.status',
66 1
        ]);
67 1
    }
68
69
    /**
70
     */
71 1
    protected function registerClassResolvers()
72
    {
73 1
        $addons = $this->addonEnvironment->addons();
74
75 1
        ClassLoader::register($this->addonEnvironment, $addons);
76
77 1
        AliasResolver::register($this->app['path'], $addons, $this->app['config']->get('app.aliases'));
78 1
    }
79
}
80