Evaluator::same()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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