Completed
Push — master ( 0cdd35...cbf418 )
by Rafael
03:53 queued 02:54
created

TotalVoiceServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 13
cts 13
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace NotificationChannels\TotalVoice;
4
5
use Illuminate\Support\ServiceProvider;
6
use TotalVoice\Client as TotalVoiceService;
7
8
class TotalVoiceServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13 2
    public function boot()
14
    {
15 2
        $this->app->when(TotalVoiceChannel::class)
16 2
            ->needs(TotalVoice::class)
17
            ->give(function () {
18 2
                return new TotalVoice(
19 2
                    $this->app->make(TotalVoiceService::class),
20 2
                    $this->app->make(TotalVoiceConfig::class)
21 2
                );
22 2
            });
23
24
        $this->app->bind(TotalVoiceService::class, function () {
25 2
            $config = $this->app['config']['services.totalvoice'];
26 2
            $access_token = array_get($config, 'access_token');
27
28 2
            return new TotalVoiceService($access_token);
29 2
        });
30 2
    }
31
32
    /**
33
     * Register the application services.
34
     */
35
    public function register()
36
    {
37
        $this->app->bind(TotalVoiceConfig::class, function () {
38
            return new TotalVoiceConfig($this->app['config']['services.totalvoice']);
39
        });
40
    }
41
}
42