Completed
Push — master ( 96dd95...b25769 )
by ARCANEDEV
02:59
created

AuthorizationServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 92.86%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 0
cbo 3
dl 0
loc 37
ccs 13
cts 14
cp 0.9286
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 11 2
A registerLogViewerPolicies() 0 8 1
1
<?php namespace Arcanesoft\Foundation\Providers;
2
3
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider;
4
use Arcanesoft\Contracts\Auth\Models\User;
5
use Arcanesoft\Foundation\Policies;
6
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
7
8
/**
9
 * Class     AuthorizationServiceProvider
10
 *
11
 * @package  Arcanesoft\Foundation\Providers
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class AuthorizationServiceProvider extends ServiceProvider
15
{
16
    /* ------------------------------------------------------------------------------------------------
17
     |  Main Functions
18
     | ------------------------------------------------------------------------------------------------
19
     */
20
    /**
21
     * Register any application authentication / authorization services.
22
     *
23
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
24
     */
25 24
    public function boot(GateContract $gate)
26
    {
27 24
        $this->registerPolicies($gate);
28
29
        /** @var  \Illuminate\Auth\Access\Gate  $gate */
30 24
        $gate->before(function (User $user, $ability) {
0 ignored issues
show
Unused Code introduced by
The parameter $ability is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
            return $user->isAdmin() ? true : null;
32 24
        });
33
34 24
        $this->registerLogViewerPolicies($gate);
35 24
    }
36
37
    /**
38
     * Register LogViewer policies.
39
     *
40
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
41
     */
42 24
    private function registerLogViewerPolicies(GateContract $gate)
43
    {
44 24
        $this->defineMany(
45 18
            $gate,
46 24
            Policies\LogViewerPolicy::class,
47 24
            Policies\LogViewerPolicy::getPolicies()
48 18
        );
49 24
    }
50
}
51