XHProfServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 12
c 3
b 0
f 0
dl 0
loc 35
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A extraMiddleware() 0 7 1
A boot() 0 16 3
1
<?php
2
3
namespace Bavix\XHProf;
4
5
use Bavix\XHProf\Middleware\XHProfMiddleware;
6
use Bavix\XHProf\Services\XHProfService;
7
use Illuminate\Contracts\Http\Kernel;
8
use Illuminate\Support\ServiceProvider;
9
10
class XHProfServiceProvider extends ServiceProvider
11
{
12
13
    /**
14
     * @return void
15
     */
16
    public function boot(): void
17
    {
18
        if ($this->app->runningInConsole()) {
19
            return;
20
        }
21
22
        $this->mergeConfigFrom(
23
            dirname(__DIR__) . '/config/config.php',
24
            'xhprof'
25
        );
26
27
        $this->app->singleton(XHProfMiddleware::class);
28
        $this->app->singleton(XHProfService::class);
29
30
        if (config('xhprof.global_middleware', false)) {
31
            $this->extraMiddleware(XHProfMiddleware::class);
32
        }
33
    }
34
35
    /**
36
     * @param string $className
37
     */
38
    public function extraMiddleware(string $className): void
39
    {
40
        /**
41
         * @var \Illuminate\Foundation\Http\Kernel $kernel
42
         */
43
        $kernel = $this->app[Kernel::class];
44
        $kernel->pushMiddleware($className);
45
    }
46
47
}
48