Completed
Pull Request — master (#45)
by Pierre
03:10 queued 16s
created

PurifierServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 89.47%

Importance

Changes 7
Bugs 0 Features 1
Metric Value
c 7
b 0
f 1
dl 0
loc 60
ccs 17
cts 19
cp 0.8947
rs 10
wmc 7
lcom 1
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A setupConfig() 0 10 4
A register() 0 8 1
A provides() 0 4 1
1
<?php namespace Mews\Purifier;
2
3
use Illuminate\Container\Container;
4
use Illuminate\Foundation\Application as LaravelApplication;
5
use Illuminate\Support\ServiceProvider;
6
use Laravel\Lumen\Application as LumenApplication;
7
8
class PurifierServiceProvider 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
     * Boot the service provider.
19
     *
20
     * @return null
21
     */
22 18
    public function boot()
23
    {
24 18
        $this->setupConfig();
25 18
    }
26
27
    /**
28
     * Setup the config.
29
     *
30
     * @return void
31
     */
32 18
    protected function setupConfig()
33
    {
34 18
        $source = realpath(__DIR__.'/../config/purifier.php');
35 18
        if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
36 18
            $this->publishes([$source => config_path('purifier.php')]);
37 18
        } 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...
38
            $this->app->configure('purifier');
39
        }
40 18
        $this->mergeConfigFrom($source, 'purifier');
41 18
    }
42
43
44
    /**
45
     * Register the service provider.
46
     *
47
     * @return void
48
     */
49
    public function register()
50
    {
51 18
        $this->app->singleton('purifier', function (Container $app) {
52 18
            return new Purifier($app['files'], $app['config']);
53 18
        });
54
55 18
        $this->app->alias('purifier', Purifier::class);
56 18
    }
57
58
    /**
59
     * Get the services provided by the provider.
60
     *
61
     * @return array
62
     */
63 27
    public function provides()
64
    {
65 27
        return ['purifier'];
66
    }
67
}
68