ServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 2
rs 10
1
<?php
2
3
namespace EmailChangeVerification;
4
5
use EmailChangeVerification\Broker\BrokerManager;
6
use EmailChangeVerification\Commands\ClearEmailChangesCommand;
7
use Illuminate\Contracts\Support\DeferrableProvider;
8
9
class ServiceProvider extends \Illuminate\Support\ServiceProvider implements DeferrableProvider
10
{
11 22
    public function boot()
12
    {
13 22
        if ($this->app->runningInConsole()) {
14 22
            $this->publishes([
15 22
                __DIR__ . '/../config/email-change-verification.php' => config_path('email-change-verification.php'),
16 22
            ], 'config');
17
18
19 22
            $this->commands([
20 22
                ClearEmailChangesCommand::class,
21 22
            ]);
22
        }
23
    }
24
25
    /**
26
     * Register the service provider.
27
     *
28
     * @return void
29
     */
30 22
    public function register()
31
    {
32 22
        $this->mergeConfigFrom(__DIR__ . '/../config/email-change-verification.php', 'email-change-verification');
33
34 22
        $this->registerEmailChangeBroker();
35
    }
36
37
    /**
38
     * Register the email change broker instance.
39
     *
40
     * @return void
41
     */
42 22
    protected function registerEmailChangeBroker()
43
    {
44 22
        $this->app->singleton('auth.email_changes', function ($app) {
45 21
            return new BrokerManager($app);
46 22
        });
47
48 22
        $this->app->bind('auth.email_changes.broker', function ($app) {
49
            return $app->make('auth.email_changes')->broker();
50 22
        });
51
    }
52
53
    /**
54
     * Get the services provided by the provider.
55
     *
56
     * @return array
57
     */
58 1
    public function provides()
59
    {
60 1
        return [ 'auth.email_changes', 'auth.email_changes.broker' ];
61
    }
62
}
63