Completed
Push — master ( 14d825...880a30 )
by Fumio
02:39
created

ServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.3645

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 13
ccs 2
cts 7
cp 0.2857
rs 9.4286
cc 1
eloc 7
nc 1
nop 0
crap 1.3645
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
        $this->app->instance('addon', $this->addonEnvironment = new AddonEnvironment($app));
0 ignored issues
show
Bug introduced by
The variable $app does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Documentation Bug introduced by
It seems like new \Jumilla\Addomnipot\...\AddonEnvironment($app) of type object<Jumilla\Addomnipo...ravel\AddonEnvironment> is incompatible with the declared type object<Jumilla\Addomnipot\Laravel\Environment> of property $addonEnvironment.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
22
        $this->app->alias('addon', AddonEnvironment::class);
23
24
        $this->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...
25
            return new Generator();
26
        });
27
28
        $this->registerCommands();
29
30
        $this->registerClassResolvers();
31
    }
32
33
    /**
34
     * Register the cache related console commands.
35
     */
36
    public function registerCommands()
37
    {
38
        $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...
39
            return new Console\AddonCheckCommand();
40
        });
41
42
        $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...
43
            return new Console\AddonMakeCommand();
44
        });
45
46
        $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...
47
            return new Console\AddonNameCommand();
48
        });
49
50
        $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...
51
            return new Console\AddonRemoveCommand();
52
        });
53
54
        $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...
55
            return new Console\AddonStatusCommand();
56
        });
57
58
        $this->commands([
59
            'command.addon.check',
60
            'command.addon.make',
61
            'command.addon.name',
62
            'command.addon.remove',
63
            'command.addon.status',
64
        ]);
65
    }
66
67
    /**
68
     */
69
    protected function registerClassResolvers()
70
    {
71
        AddonClassLoader::register($this->addonEnvironment, $this->addonEnvironment->addons());
72
73
        AliasResolver::register($this->app['path'], $addons, $this->app['config']->get('app.aliases'));
0 ignored issues
show
Bug introduced by
The variable $addons does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
74
    }
75
}
76