Evaluator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 2
b 0
f 0
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A same() 0 4 1
A has() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Created on 22/02/18 by enea dhack.
7
 */
8
9
namespace Enea\Authorization\Drivers\Database;
10
11
use Closure;
12
use Illuminate\Database\Eloquent\Builder;
13
14
abstract class Evaluator
15
{
16 7
    protected function has(Builder $repository): Closure
17
    {
18 7
        return function (array $grantableNames) use ($repository): bool {
19 7
            return ($this->same($grantableNames)($repository))->exists();
20 7
        };
21
    }
22
23 10
    protected function same(array $grantableNames): Closure
24
    {
25 10
        return function (Builder $repository) use ($grantableNames): Builder {
26 10
            return $repository->limit(1)->whereIn('secret_name', $grantableNames);
27 10
        };
28
    }
29
}
30