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::policies()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 20
c 2
b 1
f 0
cc 4
eloc 11
nc 6
nop 1
ccs 0
cts 13
cp 0
crap 20
rs 9.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