Skip to content

Commit be52cdd

Browse files
committed
Move to ClaimInterface
1 parent 141e58c commit be52cdd

4 files changed

Lines changed: 70 additions & 14 deletions

File tree

src/VerifiableCredentials/VcDataModel/Claims/VcAtContextClaimValue.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
namespace SimpleSAML\OpenID\VerifiableCredentials\VcDataModel\Claims;
66

7-
use JsonSerializable;
7+
use SimpleSAML\OpenID\Claims\ClaimInterface;
88
use SimpleSAML\OpenID\Codebooks\AtContextsEnum;
9+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
910
use SimpleSAML\OpenID\Exceptions\VcDataModelException;
1011

11-
class VcAtContextClaimValue implements JsonSerializable
12+
class VcAtContextClaimValue implements ClaimInterface
1213
{
1314
/**
1415
* @param mixed[] $otherContexts
@@ -32,10 +33,7 @@ public function __construct(
3233
*/
3334
public function jsonSerialize(): array
3435
{
35-
return [
36-
$this->baseContext,
37-
...$this->otherContexts,
38-
];
36+
return $this->getValue();
3937
}
4038

4139
public function getBaseContext(): string
@@ -50,4 +48,20 @@ public function getOtherContexts(): array
5048
{
5149
return $this->otherContexts;
5250
}
51+
52+
public function getName(): string
53+
{
54+
return ClaimsEnum::AtContext->name;
55+
}
56+
57+
/**
58+
* @return mixed[]
59+
*/
60+
public function getValue(): array
61+
{
62+
return[
63+
$this->baseContext,
64+
...$this->otherContexts,
65+
];
66+
}
5367
}

src/VerifiableCredentials/VcDataModel/Claims/VcClaimValue.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
namespace SimpleSAML\OpenID\VerifiableCredentials\VcDataModel\Claims;
66

77
use DateTimeImmutable;
8-
use JsonSerializable;
8+
use SimpleSAML\OpenID\Claims\ClaimInterface;
9+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
910

10-
class VcClaimValue implements JsonSerializable
11+
class VcClaimValue implements ClaimInterface
1112
{
1213
/**
1314
* @param null|non-empty-string $id
@@ -33,8 +34,7 @@ public function __construct(
3334
*/
3435
public function jsonSerialize(): array
3536
{
36-
// TODO: Implement jsonSerialize() method.
37-
return [];
37+
return $this->getValue();
3838
}
3939

4040
public function getAtContext(): VcAtContextClaimValue
@@ -87,4 +87,18 @@ public function getCredentialStatus(): ?VcCredentialStatusClaimValue
8787
{
8888
return $this->credentialStatusClaimValue;
8989
}
90+
91+
public function getName(): string
92+
{
93+
return ClaimsEnum::Vc->value;
94+
}
95+
96+
/**
97+
* @return mixed[]
98+
*/
99+
public function getValue(): array
100+
{
101+
// TODO: Implement getValue() method.
102+
return [];
103+
}
90104
}

src/VerifiableCredentials/VcDataModel/Claims/VcCredentialSubjectClaimBag.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace SimpleSAML\OpenID\VerifiableCredentials\VcDataModel\Claims;
66

7-
use JsonSerializable;
7+
use SimpleSAML\OpenID\Claims\ClaimInterface;
8+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
89

9-
class VcCredentialSubjectClaimBag implements JsonSerializable
10+
class VcCredentialSubjectClaimBag implements ClaimInterface
1011
{
1112
/** @var \SimpleSAML\OpenID\VerifiableCredentials\VcDataModel\Claims\VcCredentialSubjectClaimValue[] */
1213
protected array $vcCredentialSubjectClaimValueValues;
@@ -25,6 +26,19 @@ public function __construct(
2526
* @return mixed[]
2627
*/
2728
public function jsonSerialize(): array
29+
{
30+
return $this->getValue();
31+
}
32+
33+
public function getName(): string
34+
{
35+
return ClaimsEnum::Credential_Subject->value;
36+
}
37+
38+
/**
39+
* @return mixed[]
40+
*/
41+
public function getValue(): array
2842
{
2943
return array_map(
3044
fn(

src/VerifiableCredentials/VcDataModel/Claims/VcCredentialSubjectClaimValue.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace SimpleSAML\OpenID\VerifiableCredentials\VcDataModel\Claims;
66

7-
use JsonSerializable;
7+
use SimpleSAML\OpenID\Claims\ClaimInterface;
8+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
89

9-
class VcCredentialSubjectClaimValue implements JsonSerializable
10+
class VcCredentialSubjectClaimValue implements ClaimInterface
1011
{
1112
/**
1213
* @param non-empty-array<mixed> $data
@@ -24,6 +25,19 @@ public function get(int|string $key): mixed
2425
* @return non-empty-array<mixed>
2526
*/
2627
public function jsonSerialize(): array
28+
{
29+
return $this->getValue();
30+
}
31+
32+
public function getName(): string
33+
{
34+
return ClaimsEnum::Credential_Subject->value;
35+
}
36+
37+
/**
38+
* @return non-empty-array<mixed>
39+
*/
40+
public function getValue(): array
2741
{
2842
return $this->data;
2943
}

0 commit comments

Comments
 (0)