Completed
Push — master ( 3a2d10...8dcf54 )
by ARCANEDEV
04:59
created

AuthorizationServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 68.42%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 66
ccs 13
cts 19
cp 0.6842
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 2
A registerLogViewerPolicies() 0 23 1
1
<?php namespace Arcanesoft\Foundation\Providers;
2
3
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
4
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
5
6
/**
7
 * Class     AuthorizationServiceProvider
8
 *
9
 * @package  Arcanesoft\Foundation\Providers
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class AuthorizationServiceProvider extends ServiceProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * The policy mappings for the application.
20
     *
21
     * @var array
22
     */
23
    protected $policies = [
24
        //
25
    ];
26
27
    /* ------------------------------------------------------------------------------------------------
28
     |  Main Functions
29
     | ------------------------------------------------------------------------------------------------
30
     */
31
    /**
32
     * Register any application authentication / authorization services.
33
     *
34
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
35
     */
36 24
    public function boot(GateContract $gate)
37
    {
38 24
        $this->registerPolicies($gate);
39
40
        /** @var  \Illuminate\Auth\Access\Gate  $gate */
41
        $gate->before(function ($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...
42
            /** @var  \Arcanesoft\Auth\Models\User  $user */
43
            return $user->isAdmin() ? true : null;
44 24
        });
45
46 24
        $this->registerLogViewerPolicies($gate);
47 24
    }
48
49
    /**
50
     * Register LogViewer policies.
51
     *
52
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
53
     */
54 24
    private function registerLogViewerPolicies(GateContract $gate)
55
    {
56
        // TODO: Complete the log-viewer policy implementations.
57
        $gate->define('foundation::log-viewer.dashboard', function ($user) {
0 ignored issues
show
Unused Code introduced by
The parameter $user 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...
58
            return true;
59 24
        });
60
61
        $gate->define('foundation::log-viewer.list', function ($user) {
0 ignored issues
show
Unused Code introduced by
The parameter $user 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...
62
            return true;
63 24
        });
64
65
        $gate->define('foundation::log-viewer.show', function ($user) {
0 ignored issues
show
Unused Code introduced by
The parameter $user 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...
66
            return true;
67 24
        });
68
69
        $gate->define('foundation::log-viewer.download', function ($user) {
0 ignored issues
show
Unused Code introduced by
The parameter $user 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...
70
            return true;
71 24
        });
72
73 24
        $gate->define('foundation::log-viewer.delete', function ($user) {
0 ignored issues
show
Unused Code introduced by
The parameter $user 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...
74
            return true;
75 24
        });
76 24
    }
77
}
78