MobilyWsServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Test Coverage

Coverage 68%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 8
dl 0
loc 45
ccs 17
cts 25
cp 0.68
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 22 2
A register() 0 10 1
1
<?php
2
3
namespace NotificationChannels\MobilyWs;
4
5
use GuzzleHttp\Client;
6
use Illuminate\Support\ServiceProvider;
7
use NotificationChannels\MobilyWs\Console\MobilyWsNotificationMakeCommand;
8
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
9
10
class MobilyWsServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap the application services.
14
     */
15 2
    public function boot()
16
    {
17 2
        $this->app->when(MobilyWsChannel::class)
18 2
            ->needs(MobilyWsApi::class)
19
            ->give(function () {
20 2
                $mobilyWsConfig = $this->app['config']['mobilyws'];
21 2
                if (is_null($mobilyWsConfig)) {
22 1
                    throw CouldNotSendMobilyWsNotification::withErrorMessage('Config file was not found. Please publish the config file');
23
                }
24
25 1
                return new MobilyWsApi(
26 1
                    new MobilyWsConfig($mobilyWsConfig),
27 1
                    new Client(
28 1
                        $mobilyWsConfig['guzzle']['client']
29 1
                    )
30 1
                );
31 2
            });
32
33 1
        $this->publishes([
34 1
            __DIR__.'/../config/mobilyws.php' => config_path('mobilyws.php'),
35 1
        ]);
36 1
    }
37
    
38
    /**
39
     * Register the service provider.
40
     *
41
     * @return void
42
     */
43
    public function register()
44
    {
45
        $this->app->singleton(
46
            'command.mobilyws.notification',
47
            function ($app) {
48
                return new MobilyWsNotificationMakeCommand($app['files']);
49
            }
50
        );
51
        $this->commands('command.mobilyws.notification');
52
    }
53
    
54
}
55