BasicPolicy   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDescription() 0 3 1
A evaluate() 0 8 1
1
<?php declare(strict_types=1);
2
3
namespace jschreuder\MiddleAuth\Abac;
4
5
use jschreuder\MiddleAuth\AuthorizationEntityInterface;
6
7
final class BasicPolicy implements PolicyInterface
8
{
9 4
    public function __construct(
10
        private AccessEvaluatorInterface $evaluator,
11
        private string $description
12 4
    ) {}
13
14 3
    public function evaluate(
15
        AuthorizationEntityInterface $actor,
16
        AuthorizationEntityInterface $resource,
17
        string $action,
18
        array $context
19
    ): bool
20
    {
21 3
        return $this->evaluator->hasAccess($actor, $resource, $action, $context);
22
    }
23
24 2
    public function getDescription(): string
25
    {
26 2
        return $this->description;
27
    }
28
}
29