Completed
Push — master ( 4fd0f8...3b1739 )
by Colin
07:33
created

ServiceProvider::setUpConfig()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
1
<?php namespace Cviebrock\EloquentSluggable;
2
3
use Cviebrock\EloquentSluggable\Services\SlugService;
4
use Illuminate\Foundation\Application as LaravelApplication;
5
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
6
use Laravel\Lumen\Application as LumenApplication;
7
8
/**
9
 * Class ServiceProvider
10
 *
11
 * @package Cviebrock\EloquentSluggable
12
 */
13
class ServiceProvider extends BaseServiceProvider
14
{
15
16
    /**
17
     * Bootstrap the application services.
18
     */
19
    public function boot()
20
    {
21
        $this->setUpConfig();
22
    }
23
24
    /**
25
     * Register the application services.
26
     */
27
    public function register()
28
    {
29
        $this->app->singleton(SluggableObserver::class, function ($app) {
30
            return new SluggableObserver(new SlugService(), $app['events']);
31
        });
32
    }
33
34
    protected function setUpConfig()
35
    {
36
        $source = dirname(__DIR__) . '/resources/config/sluggable.php';
37
38
        if ($this->app instanceof LaravelApplication) {
39
            $this->publishes([$source => config_path('sluggable.php')], 'config');
40
        } elseif ($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...
41
            $this->app->configure('sluggable');
42
        }
43
44
        $this->mergeConfigFrom($source, 'sluggable');
45
    }
46
}
47