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
Push — master ( b2510c...ee0bb8 )
by
unknown
12:46
created

AdminSectionsServiceProvider   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 20%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 74
c 2
b 1
f 0
ccs 5
cts 25
cp 0.2
rs 10
wmc 9
lcom 1
cbo 3

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 20 4
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
     * @var array  Associative array in form of: Section::class => Policy::class
17
     */
18
    protected $policies = [];
19
20
    /**
21
     * @return array
22
     */
23 285
    public function sections()
24
    {
25 285
        return $this->sections;
26
    }
27
28
    /**
29
     * @param \SleepingOwl\Admin\Admin $admin
30
     */
31 285
    public function boot(\SleepingOwl\Admin\Admin $admin)
32
    {
33 285
        $admin->registerSections($this->sections());
34 285
    }
35
36
    /**
37
     * Register the service provider.
38
     *
39
     * @return void
40
     */
41
    public function register()
42
    {
43
        // TODO: Implement register() method.
44
    }
45
46
    /**
47
     * @param string|null $namespace
48
     *
49
     * @return array
50
     */
51
    public function policies($namespace = null)
52
    {
53
        if (is_null($namespace)) {
54
            $namespace = config('sleeping_owl.policies_namespace', '\\App\\Policies\\');
55
        }
56
57
        $policies = [];
58
        $preparedPolicies = collect($this->policies);
59
60
        foreach ($this->sections as $model => $section) {
61
            if ($preparedPolicies->has($section)) {
62
                $policies[$section] = $preparedPolicies->get($section);
63
                continue;
64
            }
65
66
            $policies[$section] = $namespace.class_basename($section).'SectionModelPolicy';
67
        }
68
69
        return $policies;
70
    }
71
72
    /**
73
     * @param string|null $namespace
74
     */
75
    public function registerPolicies($namespace = null)
76
    {
77
        foreach ($this->policies($namespace) as $section => $policy) {
78
            $this->app[Gate::class]->policy($section, $policy);
79
        }
80
    }
81
}
82