Completed
Push — master ( b3fdf0...570788 )
by ARCANEDEV
03:05
created

AuthorizationServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 37
ccs 11
cts 11
cp 1
rs 10
wmc 3
lcom 0
cbo 3

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 12
    public function boot(GateContract $gate)
26
    {
27 12
        $this->registerPolicies($gate);
28
29
        /** @var  \Illuminate\Auth\Access\Gate  $gate */
30 12
        $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 12
        });
33
34 12
        $this->registerLogViewerPolicies($gate);
35 12
    }
36
37
    /**
38
     * Register LogViewer policies.
39
     *
40
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
41
     */
42 12
    private function registerLogViewerPolicies(GateContract $gate)
43
    {
44 12
        $this->defineMany(
45
            $gate,
46 12
            Policies\LogViewerPolicy::class,
47 12
            Policies\LogViewerPolicy::getPolicies()
48
        );
49 12
    }
50
}
51