Skip to content

Commit

Permalink
Merge pull request #1077 from lcobucci/5.4.x-merge-up-into-5.5.x_BziV…
Browse files Browse the repository at this point in the history
…bmf6

Merge release 5.4.1 into 5.5.x
  • Loading branch information
lcobucci authored Nov 6, 2024
2 parents 9b13780 + 848815d commit 15bbe92
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Token/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public function __construct(private readonly Encoder $encoder, private readonly
{
}

/**
* @inheritDoc
* @pure
*/
public function permittedFor(string ...$audiences): BuilderInterface
{
$configured = $this->claims[RegisteredClaims::AUDIENCE] ?? [];
Expand All @@ -37,36 +41,64 @@ public function permittedFor(string ...$audiences): BuilderInterface
return $this->setClaim(RegisteredClaims::AUDIENCE, array_merge($configured, $toAppend));
}

/**
* @inheritDoc
* @pure
*/
public function expiresAt(DateTimeImmutable $expiration): BuilderInterface
{
return $this->setClaim(RegisteredClaims::EXPIRATION_TIME, $expiration);
}

/**
* @inheritDoc
* @pure
*/
public function identifiedBy(string $id): BuilderInterface
{
return $this->setClaim(RegisteredClaims::ID, $id);
}

/**
* @inheritDoc
* @pure
*/
public function issuedAt(DateTimeImmutable $issuedAt): BuilderInterface
{
return $this->setClaim(RegisteredClaims::ISSUED_AT, $issuedAt);
}

/**
* @inheritDoc
* @pure
*/
public function issuedBy(string $issuer): BuilderInterface
{
return $this->setClaim(RegisteredClaims::ISSUER, $issuer);
}

/**
* @inheritDoc
* @pure
*/
public function canOnlyBeUsedAfter(DateTimeImmutable $notBefore): BuilderInterface
{
return $this->setClaim(RegisteredClaims::NOT_BEFORE, $notBefore);
}

/**
* @inheritDoc
* @pure
*/
public function relatedTo(string $subject): BuilderInterface
{
return $this->setClaim(RegisteredClaims::SUBJECT, $subject);
}

/**
* @inheritDoc
* @pure
*/
public function withHeader(string $name, mixed $value): BuilderInterface
{
$new = clone $this;
Expand All @@ -75,6 +107,10 @@ public function withHeader(string $name, mixed $value): BuilderInterface
return $new;
}

/**
* @inheritDoc
* @pure
*/
public function withClaim(string $name, mixed $value): BuilderInterface
{
if (in_array($name, RegisteredClaims::ALL, true)) {
Expand Down

0 comments on commit 15bbe92

Please sign in to comment.