AuthorizationEntity::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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