Passed
Push — develop ( 53798b...20a922 )
by Enea
02:15
created

HasPermission::locateByName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Created on 11/02/18 by enea dhack.
6
 */
7
8
namespace Enea\Authorization\Traits;
9
10
use Enea\Authorization\Contracts\PermissionContract;
11
12
trait HasPermission
13
{
14
    use Grantable;
15
16
    public static function locateByName(string $secretName): ?PermissionContract
17
    {
18
        $permission = static::query()->where('secret_name', $secretName)->first();
19
        return $permission instanceof PermissionContract ? $permission : null;
20
    }
21
}
22