Passed
Push — master ( ccf673...70274a )
by Zing
03:57
created

SmsServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 9 3
A register() 0 8 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: liuning
5
 * Date: 2018/12/17
6
 * Time: 10:35 AM.
7
 */
8
9
namespace Zing\LaravelSms;
10
11
use Illuminate\Contracts\Foundation\Application;
12
use Illuminate\Notifications\ChannelManager;
13
use Illuminate\Support\Facades\Notification;
14
use Illuminate\Support\ServiceProvider;
15
use Zing\LaravelSms\Channels\SmsChannel;
16
17
class SmsServiceProvider extends ServiceProvider
18
{
19 29
    public function boot()
20
    {
21 29
        if ($this->app->runningInConsole() && function_exists('config_path')) {
22 29
            $this->publishes([
23 29
                __DIR__ . '/../config/sms.php' => config_path('sms.php'),
24 29
            ], 'config');
25
        }
26
27 29
        $this->mergeConfigFrom(__DIR__ . '/../config/sms.php', 'sms');
28 29
    }
29
30 29
    public function register()
31
    {
32
        $this->app->singleton('sms', function (Application $app) {
33 2
            return $app->make(SmsManager::class);
34 29
        });
35
        Notification::resolved(function (ChannelManager $service) {
36
            $service->extend('sms', function (Application $app) {
37 1
                return $app->make(SmsChannel::class);
38 4
            });
39 29
        });
40 29
    }
41
}
42