PhpSmsServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Toplan\PhpSms;
4
5
use Illuminate\Support\ServiceProvider;
6
use Laravel\Lumen\Application as LumenApplication;
7
8
class PhpSmsServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = true;
16
17
    /**
18
     * Bootstrap the application events.
19
     */
20
    public function boot()
21
    {
22
        if (function_exists('config_path')) {
23
            $publishPath = config_path('phpsms.php');
24
        } else {
25
            $publishPath = base_path('config/phpsms.php');
26
        }
27
        $this->publishes([
28
            __DIR__ . '/../config/phpsms.php' => $publishPath,
29
        ], 'config');
30
    }
31
32
    /**
33
     * Register the service provider.
34
     */
35
    public function register()
36
    {
37
        if ($this->app instanceof LumenApplication) {
0 ignored issues
show
Bug introduced by
The class Laravel\Lumen\Application does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
38
            $this->app->configure('phpsms');
39
        }
40
        $this->mergeConfigFrom(__DIR__ . '/../config/phpsms.php', 'phpsms');
41
42
        $this->app->singleton('Toplan\\PhpSms\\Sms', function () {
43
            Sms::scheme(config('phpsms.scheme', []));
44
            Sms::config(config('phpsms.agents', []));
45
46
            return new Sms(false);
47
        });
48
    }
49
50
    /**
51
     * Get the services provided by the provider.
52
     *
53
     * @return array
54
     */
55
    public function provides()
56
    {
57
        return ['Toplan\\PhpSms\\Sms'];
58
    }
59
}
60