Completed
Push — master ( 22fa00...44c771 )
by ARCANEDEV
07:45
created

AuthorizationServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A registerDashboardPolicies() 0 7 1
A registerUsersPolicies() 0 7 1
A registerRolesPolicies() 0 7 1
A boot() 0 10 1
A registerPermissionsPolicies() 0 7 1
A registerPasswordResetsPolicies() 0 7 1
1
<?php namespace Arcanesoft\Auth\Providers;
2
3
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider;
4
use Arcanesoft\Auth\Policies;
5
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
6
7
/**
8
 * Class     AuthorizationServiceProvider
9
 *
10
 * @package  Arcanesoft\Auth\Providers
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class AuthorizationServiceProvider extends ServiceProvider
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Properties
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * The policy mappings for the application.
21
     *
22
     * @var array
23
     */
24
    protected $policies = [
25
        //
26
    ];
27
28
    /* ------------------------------------------------------------------------------------------------
29
     |  Main Functions
30
     | ------------------------------------------------------------------------------------------------
31
     */
32
    /**
33
     * Register any application authentication / authorization services.
34
     *
35
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
36
     */
37 12
    public function boot(GateContract $gate)
38
    {
39 12
        parent::registerPolicies();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (registerPolicies() instead of boot()). Are you sure this is correct? If so, you might want to change this to $this->registerPolicies().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
40
41 12
        $this->registerDashboardPolicies($gate);
42 12
        $this->registerUsersPolicies($gate);
43 12
        $this->registerRolesPolicies($gate);
44 12
        $this->registerPermissionsPolicies($gate);
45 12
        $this->registerPasswordResetsPolicies($gate);
46 12
    }
47
48
    /* ------------------------------------------------------------------------------------------------
49
     |  Policies
50
     | ------------------------------------------------------------------------------------------------
51
     */
52
    /**
53
     * Register dashboard authorizations.
54
     *
55
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
56
     */
57 12
    private function registerDashboardPolicies($gate)
58
    {
59 12
        $this->defineMany($gate,
60 12
            Policies\DashboardPolicy::class,
61 12
            Policies\DashboardPolicy::getPolicies()
62 12
        );
63 12
    }
64
65
    /**
66
     * Register users authorizations.
67
     *
68
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
69
     */
70 12
    private function registerUsersPolicies(GateContract $gate)
71
    {
72 12
        $this->defineMany($gate,
73 12
            Policies\UsersPolicy::class,
74 12
            Policies\UsersPolicy::getPolicies()
75 12
        );
76 12
    }
77
78
    /**
79
     * Register roles authorizations.
80
     *
81
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
82
     */
83 12
    private function registerRolesPolicies(GateContract $gate)
84
    {
85 12
        $this->defineMany($gate,
86 12
            Policies\RolesPolicy::class,
87 12
            Policies\RolesPolicy::getPolicies()
88 12
        );
89 12
    }
90
91
    /**
92
     * Register permissions authorizations.
93
     *
94
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
95
     */
96 12
    private function registerPermissionsPolicies(GateContract $gate)
97
    {
98 12
        $this->defineMany($gate,
99 12
            Policies\PermissionsPolicy::class,
100 12
            Policies\PermissionsPolicy::getPolicies()
101 12
        );
102 12
    }
103
104
    /**
105
     * Register password resets authorizations.
106
     *
107
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
108
     */
109 12
    private function registerPasswordResetsPolicies(GateContract $gate)
110
    {
111 12
        $this->defineMany($gate,
112 12
            Policies\PasswordResetsPolicy::class,
113 12
            Policies\PasswordResetsPolicy::getPolicies()
114 12
        );
115 12
    }
116
}
117