-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVcAtContextClaimValue.php
More file actions
73 lines (59 loc) · 1.63 KB
/
VcAtContextClaimValue.php
File metadata and controls
73 lines (59 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);
namespace SimpleSAML\OpenID\VerifiableCredentials\VcDataModel\Claims;
use SimpleSAML\OpenID\Codebooks\AtContextsEnum;
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
use SimpleSAML\OpenID\Exceptions\VcDataModelException;
use SimpleSAML\OpenID\ValueAbstracts\ClaimInterface;
class VcAtContextClaimValue implements ClaimInterface
{
/**
* @param mixed[] $otherContexts
* @throws \SimpleSAML\OpenID\Exceptions\VcDataModelException
*/
public function __construct(
protected readonly string $baseContext,
protected readonly array $otherContexts,
AtContextsEnum $expectedBaseContext = AtContextsEnum::W3Org2018CredentialsV1,
) {
if ($this->baseContext !== $expectedBaseContext->value) {
throw new VcDataModelException(sprintf(
'Invalid VC @context claim. Base context should be %s, %s given.',
$expectedBaseContext->value,
$this->baseContext,
));
}
}
/**
* @return mixed[]
*/
public function jsonSerialize(): array
{
return $this->getValue();
}
public function getBaseContext(): string
{
return $this->baseContext;
}
/**
* @return mixed[]
*/
public function getOtherContexts(): array
{
return $this->otherContexts;
}
public function getName(): string
{
return ClaimsEnum::AtContext->value;
}
/**
* @return mixed[]
*/
public function getValue(): array
{
return [
$this->baseContext,
...$this->otherContexts,
];
}
}