Cancelled
Push — test-branch ( 5c534a )
by Yonathan
06:17 queued 06:17
created

BasePolicy::before()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.864

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 2
cts 5
cp 0.4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2.864
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 13
    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 13
        if ($user->user_role->name == 'admin') {
15
            $userText = '{id='.$user->id.'}';
16
            Log::notice('User '.$userText.' has bypassed policy as an Admin');
17
            return true;
18
        }
19 13
    }
20
}
21