GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch development (184ec4)
by butschster
06:08
created

AdminSectionsServiceProvider   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 23.81%

Importance

Changes 0
Metric Value
dl 0
loc 61
ccs 5
cts 21
cp 0.2381
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A sections() 0 4 1
A boot() 0 4 1
A register() 0 4 1
A policies() 0 12 3
A registerPolicies() 0 6 2
1
<?php
2
3
namespace SleepingOwl\Admin\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Contracts\Auth\Access\Gate;
7
8
class AdminSectionsServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * @var array  Associative array in form of: Model::class => Section::class
12
     */
13
    protected $sections = [];
14
15
    /**
16
     * @return array
17
     */
18 283
    public function sections()
19
    {
20 283
        return $this->sections;
21
    }
22
23
    /**
24
     * @param \SleepingOwl\Admin\Admin $admin
25
     */
26 283
    public function boot(\SleepingOwl\Admin\Admin $admin)
27
    {
28 283
        $admin->registerSections($this->sections());
29 283
    }
30
31
    /**
32
     * Register the service provider.
33
     *
34
     * @return void
35
     */
36
    public function register()
37
    {
38
        // TODO: Implement register() method.
39
    }
40
41
    /**
42
     * @param string|null $namespace
43
     *
44
     * @return array
45
     */
46
    public function policies($namespace = null)
47
    {
48
        if (is_null($namespace)) {
49
            $namespace = config('sleeping_owl.policies_namespace', '\\App\\Policies\\');
50
        }
51
        $policies = [];
52
        foreach ($this->sections as $model => $section) {
53
            $policies[$section] = $namespace.class_basename($section).'SectionModelPolicy';
54
        }
55
56
        return $policies;
57
    }
58
59
    /**
60
     * @param string|null $namespace
61
     */
62
    public function registerPolicies($namespace = null)
63
    {
64
        foreach ($this->policies($namespace) as $section => $policy) {
65
            $this->app[Gate::class]->policy($section, $policy);
66
        }
67
    }
68
}
69