Completed
Push — develop ( 20a922...5bb600 )
by Enea
05:08 queued 03:13
created

HasPermission::locateByName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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