QueryDetectorServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace BeyondCode\QueryDetector;
4
5
use Illuminate\Contracts\Http\Kernel;
6
use Illuminate\Support\ServiceProvider;
7
8
class QueryDetectorServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot()
14
    {
15
        if ($this->app->runningInConsole()) {
16
            $this->publishes([
17
                __DIR__.'/../config/config.php' => config_path('querydetector.php'),
18
            ], 'config');
19
        }
20
21
        $this->registerMiddleware(QueryDetectorMiddleware::class);
22
    }
23
24
    /**
25
     * Register the application services.
26
     */
27
    public function register()
28
    {
29
        $this->app->singleton(QueryDetector::class);
30
31
        $this->app->alias(QueryDetector::class, 'querydetector');
32
33
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'querydetector');
34
    }
35
36
    /**
37
     * Register the middleware
38
     *
39
     * @param  string $middleware
40
     */
41
    protected function registerMiddleware($middleware)
42
    {
43
        $kernel = $this->app[Kernel::class];
44
        $kernel->pushMiddleware($middleware);
45
    }
46
}
47