Completed
Pull Request — master (#12)
by ARCANEDEV
05:21
created

AuthorizationServiceProvider::boot()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 2
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\LaravelImpersonator\Providers;
6
7
use Arcanedev\LaravelPolicies\Contracts\PolicyManager;
8
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider;
9
10
/**
11
 * Class     AuthorizationServiceProvider
12
 *
13
 * @package  Arcanedev\LaravelImpersonator\Providers
14
 * @author   ARCANEDEV <[email protected]>
15
 */
16
class AuthorizationServiceProvider extends ServiceProvider
17
{
18
    /* -----------------------------------------------------------------
19
     |  Getters
20
     | -----------------------------------------------------------------
21
     */
22
23
    /**
24
     * Get policy's classes.
25
     *
26
     * @return iterable
27
     */
28 168
    public function policyClasses(): iterable
29
    {
30 168
        return (array) config('impersonator.policies', []);
31
    }
32
33
    /* -----------------------------------------------------------------
34
     |  Main Methods
35
     | -----------------------------------------------------------------
36
     */
37
38
    /**
39
     * Register any application authentication / authorization services.
40
     */
41 168
    public function boot(): void
42
    {
43 168
        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...
44
45 168
        $manager = $this->app->make(PolicyManager::class);
46
47 168
        foreach ($this->policyClasses() as $class) {
48 168
            $manager->registerClass($class);
49
        }
50 168
    }
51
}
52