Completed
Push — master ( 983ab2...28a127 )
by ARCANEDEV
06:40
created

AuthorizationServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 87
ccs 27
cts 27
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 9 1
A registerPostsPolicies() 0 7 1
A registerCategoriesPolicies() 0 7 1
A registerTagsPolicies() 0 7 1
A registerOtherPolicies() 0 4 1
1
<?php namespace Arcanesoft\Blog\Providers;
2
3
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider;
4
use Arcanesoft\Blog\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 8
    public function boot(GateContract $gate)
38
    {
39 8
        parent::registerPolicies($gate);
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 8
        $this->registerPostsPolicies($gate);
42 8
        $this->registerCategoriesPolicies($gate);
43 8
        $this->registerTagsPolicies($gate);
44 8
        $this->registerOtherPolicies($gate);
0 ignored issues
show
Unused Code introduced by
The call to the method Arcanesoft\Blog\Provider...registerOtherPolicies() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
45 8
    }
46
47
    /* ------------------------------------------------------------------------------------------------
48
     |  Policies
49
     | ------------------------------------------------------------------------------------------------
50
     */
51
    /**
52
     * Register posts authorizations.
53
     *
54
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
55
     */
56 8
    private function registerPostsPolicies(GateContract $gate)
57
    {
58 8
        $this->defineMany($gate,
59 8
            Policies\PostsPolicy::class,
60 8
            Policies\PostsPolicy::getPolicies()
61 6
        );
62 8
    }
63
64
    /**
65
     * Register categories authorizations.
66
     *
67
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
68
     */
69 8
    private function registerCategoriesPolicies(GateContract $gate)
70
    {
71 8
        $this->defineMany($gate,
72 8
            Policies\CategoriesPolicy::class,
73 8
            Policies\CategoriesPolicy::getPolicies()
74 6
        );
75 8
    }
76
77
    /**
78
     * Register tags authorizations.
79
     *
80
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
81
     */
82 8
    private function registerTagsPolicies(GateContract $gate)
83
    {
84 8
        $this->defineMany($gate,
85 8
            Policies\TagsPolicy::class,
86 8
            Policies\TagsPolicy::getPolicies()
87 6
        );
88 8
    }
89
90
    /**
91
     * Register other authorizations for blog module.
92
     *
93
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
94
     */
95 8
    private function registerOtherPolicies(GateContract $gate)
0 ignored issues
show
Unused Code introduced by
The parameter $gate 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...
96
    {
97
        //
98 8
    }
99
}
100