Passed
Push — feature/admin-only-job-create ( 4243e9...e9cbd9 )
by Tristan
13:05 queued 07:52
created

BasePolicy::before()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace App\Policies;
4
5
use Illuminate\Auth\Access\HandlesAuthorization;
6
use Illuminate\Support\Facades\Log;
7
8
class BasePolicy
9
{
10
    use HandlesAuthorization;
11
12 11
    public function before($user, $ability)
1 ignored issue
show
Unused Code introduced by
The parameter $ability is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

12
    public function before($user, /** @scrutinizer ignore-unused */ $ability)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
introduced by
Method \App\Policies\BasePolicy::before() does not have parameter type hint nor @param annotation for its parameter $user.
Loading history...
introduced by
Method \App\Policies\BasePolicy::before() does not have parameter type hint nor @param annotation for its parameter $ability.
Loading history...
introduced by
Method \App\Policies\BasePolicy::before() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function before()
Loading history...
13
    {
14 11
        if ($user->user_role->name == 'admin') {
15 1
            $userText = '{id='.$user->id.'}';
16 1
            Log::notice('User '.$userText.' has bypassed policy as an Admin');
17 1
            return true;
18
        }
19 10
    }
20
}
21