Completed
Push — master ( 67c7d1...f02869 )
by Nicolas
02:52
created

SidebarServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 30
rs 10
c 3
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A boot() 0 7 2
A onBackend() 0 8 2
1
<?php namespace Modules\Core\Providers;
2
3
use Illuminate\Support\ServiceProvider;
4
use Maatwebsite\Sidebar\SidebarManager;
5
use Modules\Core\Sidebar\AdminSidebar;
6
use Illuminate\Http\Request;
7
8
class SidebarServiceProvider extends ServiceProvider
9
{
10
    protected $defer = true;
11
    private $request;
12
13
    /**
14
     * Register the service provider.
15
     * @return void
16
     */
17
    public function register()
18
    {
19
    }
20
21
    public function boot(SidebarManager $manager, Request $request)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
22
    {
23
        $this->request = $request;
24
        if ($this->onBackend() === true ) {
25
            $manager->register(AdminSidebar::class);
26
        }
27
    }
28
29
    private function onBackend()
30
    {
31
        $url = $this->request->url();
32
        if (str_contains($url, config('asgard.core.core.admin-prefix'))) {
33
            return true;
34
        }
35
        return false;
36
    }
37
}
38