FakeIdServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php namespace Propaganistas\LaravelFakeId;
2
3
use Illuminate\Support\ServiceProvider;
4
use Jenssegers\Optimus\Optimus;
5
use Propaganistas\LaravelFakeId\Commands\FakeIdSetupCommand;
6
7
class FakeIdServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Boots the service provider.
11
     *
12
     * @return void
13
     */
14 24
    public function boot()
15
    {
16
        // Publish config.
17 24
        $this->publishes([
18 24
            __DIR__ . '/../config/config.php' => config_path('fakeid.php'),
19 24
        ], 'config');
20 24
    }
21
22
    /**
23
     * Register the service provider.
24
     *
25
     * @return void
26
     */
27 24
    public function register()
28
    {
29 24
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'fakeid');
30
31 24
        $this->registerCommand();
32 24
        $this->registerOptimus();
33 24
    }
34
35
    /**
36
     * Register the Optimus container.
37
     *
38
     * @return void
39
     */
40 16
    protected function registerOptimus()
41
    {
42 8
        $this->app->singleton('Jenssegers\Optimus\Optimus', function ($app) {
43 18
            return new Optimus(
44 18
                $app['config']['fakeid.prime'],
45 18
                $app['config']['fakeid.inverse'],
46 18
                $app['config']['fakeid.random']
47
            );
48 24
        });
49
50 24
        $this->app->alias('Jenssegers\Optimus\Optimus', 'optimus');
51 24
        $this->app->alias('Jenssegers\Optimus\Optimus', 'fakeid');
52 24
    }
53
54
    /**
55
     * Register the Artisan setup command.
56
     *
57
     * @return void
58
     */
59 16
    protected function registerCommand()
60
    {
61 8
        $this->app->singleton('fakeid.command.setup', 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...
62
            return new FakeIdSetupCommand;
63 24
        });
64
65 24
        $this->commands('fakeid.command.setup');
66 24
    }
67
}
68