Total Complexity | 6 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 50% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | final class ValidationContext |
||
8 | { |
||
9 | public const DEFAULT_CLOCK_LEEWAY = 1 * 60; |
||
10 | |||
11 | /** |
||
12 | * @var string[] |
||
13 | */ |
||
14 | private $allowedAlgorithms; |
||
15 | |||
16 | /** |
||
17 | * @var CoseKeyInterface |
||
18 | */ |
||
19 | private $key; |
||
20 | |||
21 | /** |
||
22 | * @var int|null |
||
23 | */ |
||
24 | private $referenceUnixTime; |
||
25 | |||
26 | /** |
||
27 | * @param string[] $allowedAlgorithms |
||
28 | */ |
||
29 | 5 | public function __construct(array $allowedAlgorithms, CoseKeyInterface $key) |
|
30 | { |
||
31 | 5 | $this->key = $key; |
|
32 | // TODO: check types |
||
33 | 5 | $this->allowedAlgorithms = $allowedAlgorithms; |
|
34 | 5 | } |
|
35 | |||
36 | /** |
||
37 | * @return string[] |
||
38 | */ |
||
39 | 5 | public function getAllowedAlgorithms(): array |
|
40 | { |
||
41 | 5 | return $this->allowedAlgorithms; |
|
42 | } |
||
43 | |||
44 | 4 | public function getKey(): CoseKeyInterface |
|
45 | { |
||
46 | 4 | return $this->key; |
|
47 | } |
||
48 | |||
49 | public function getReferenceUnixTime(): int |
||
50 | { |
||
51 | return $this->referenceUnixTime ?? time(); |
||
52 | } |
||
53 | |||
54 | public function getClockLeeway(): int |
||
55 | { |
||
56 | return self::DEFAULT_CLOCK_LEEWAY; |
||
57 | } |
||
58 | |||
59 | public function withReferenceUnixTime(int $timestamp): self |
||
64 | } |
||
65 | } |
||
66 |