Skip to content

Commit 848815d

Browse files
authored
Merge pull request #1076 from b1rdex/pure-builder
Mark Builder methods as pure
2 parents aac4fd5 + 5012bc4 commit 848815d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/Token/Builder.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public function __construct(private readonly Encoder $encoder, private readonly
2929
{
3030
}
3131

32+
/**
33+
* @inheritDoc
34+
* @pure
35+
*/
3236
public function permittedFor(string ...$audiences): BuilderInterface
3337
{
3438
$configured = $this->claims[RegisteredClaims::AUDIENCE] ?? [];
@@ -37,36 +41,64 @@ public function permittedFor(string ...$audiences): BuilderInterface
3741
return $this->setClaim(RegisteredClaims::AUDIENCE, array_merge($configured, $toAppend));
3842
}
3943

44+
/**
45+
* @inheritDoc
46+
* @pure
47+
*/
4048
public function expiresAt(DateTimeImmutable $expiration): BuilderInterface
4149
{
4250
return $this->setClaim(RegisteredClaims::EXPIRATION_TIME, $expiration);
4351
}
4452

53+
/**
54+
* @inheritDoc
55+
* @pure
56+
*/
4557
public function identifiedBy(string $id): BuilderInterface
4658
{
4759
return $this->setClaim(RegisteredClaims::ID, $id);
4860
}
4961

62+
/**
63+
* @inheritDoc
64+
* @pure
65+
*/
5066
public function issuedAt(DateTimeImmutable $issuedAt): BuilderInterface
5167
{
5268
return $this->setClaim(RegisteredClaims::ISSUED_AT, $issuedAt);
5369
}
5470

71+
/**
72+
* @inheritDoc
73+
* @pure
74+
*/
5575
public function issuedBy(string $issuer): BuilderInterface
5676
{
5777
return $this->setClaim(RegisteredClaims::ISSUER, $issuer);
5878
}
5979

80+
/**
81+
* @inheritDoc
82+
* @pure
83+
*/
6084
public function canOnlyBeUsedAfter(DateTimeImmutable $notBefore): BuilderInterface
6185
{
6286
return $this->setClaim(RegisteredClaims::NOT_BEFORE, $notBefore);
6387
}
6488

89+
/**
90+
* @inheritDoc
91+
* @pure
92+
*/
6593
public function relatedTo(string $subject): BuilderInterface
6694
{
6795
return $this->setClaim(RegisteredClaims::SUBJECT, $subject);
6896
}
6997

98+
/**
99+
* @inheritDoc
100+
* @pure
101+
*/
70102
public function withHeader(string $name, mixed $value): BuilderInterface
71103
{
72104
$new = clone $this;
@@ -75,6 +107,10 @@ public function withHeader(string $name, mixed $value): BuilderInterface
75107
return $new;
76108
}
77109

110+
/**
111+
* @inheritDoc
112+
* @pure
113+
*/
78114
public function withClaim(string $name, mixed $value): BuilderInterface
79115
{
80116
if (in_array($name, RegisteredClaims::ALL, true)) {

0 commit comments

Comments
 (0)