PushmixServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 30%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
c 2
b 0
f 0
dl 0
loc 60
ccs 6
cts 20
cp 0.3
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A boot() 0 23 2
A provides() 0 3 1
1
<?php
2
3
namespace Pushmix\WebNotification;
4
5
use Illuminate\Support\Facades\Artisan;
6
use Illuminate\Support\ServiceProvider;
7
use Pushmix\WebNotification\Exceptions\InvalidConfiguration;
8
9
class PushmixServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Indicates if loading of the provider is deferred.
13
     *
14
     * @var bool
15
     */
16
    protected $defer = true;
17
18
    /**
19
     * register service container bindings.
20
     */
21 1
    public function register()
22
    {
23
        $this->app->singleton('pushmix', function () {
24 1
            return new PushmixClient();
25 1
        });
26 1
    }
27
28
    /***/
29
30
    /**
31
     * booting.
32
     */
33
    public function boot()
34
    {
35
36
    // Pusblish assets
37
        $this->publishes([
38
39
            __DIR__.'/config/pushmix.php' => config_path('pushmix.php'),
40
            __DIR__.'/views' => resource_path('views/vendor/pushmix'),
41
            __DIR__.'/js' => public_path(),
42
43
        ], 'pushmix');
44
45
        // Clear Config Cache
46
        Artisan::call('config:clear');
47
48
        $this->app->when(PushmixChannel::class)
49
        ->needs(PushmixClient::class)
50
        ->give(function () {
51
            if (is_null(config('pushmix.subscription_id', null))) {
52
                throw InvalidConfiguration::configurationNotSet();
53
            }
54
55
            return new PushmixClient();
56
        });
57
    }
58
59
    /***/
60
61
    /**
62
     * providers.
63
     *
64
     * @return     array  ( description_of_the_return_value )
65
     */
66 1
    public function provides()
67
    {
68 1
        return ['pushmix'];
69
    }
70
71
    /***/
72
}
73