AuthorizationEntity::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 3
dl 0
loc 10
ccs 5
cts 5
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace jschreuder\MiddleAuth\Basic;
4
5
use InvalidArgumentException;
6
use jschreuder\MiddleAuth\AuthorizationEntityInterface;
7
8
final class AuthorizationEntity implements AuthorizationEntityInterface
9
{
10 16
    public function __construct(
11
        private string $type,
12
        private string $id,
13
        private array $attributes = []
14
    ) {
15 16
        if (empty(trim($type))) {
16 2
            throw new InvalidArgumentException('Type of AuthorizationEntity cannot be empty.');
17
        }
18 14
        if (empty(trim($id))) {
19 2
            throw new InvalidArgumentException('ID of AuthorizationEntity cannot be empty.');
20
        }
21
    }
22
23 9
    public function getId(): string
24
    {
25 9
        return $this->id;
26
    }
27
28 9
    public function getType(): string
29
    {
30 9
        return $this->type;
31
    }
32
33 1
    public function getAttributes(): array
34
    {
35 1
        return $this->attributes;
36
    }
37
}
38