refactored code

Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
2025-04-28 04:47:50 +02:00
parent 05e8cca347
commit 7f908f4e6a
33 changed files with 1577 additions and 463 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace Anikeen\Id;
use stdClass;
trait HasAnikeenTokens
{
/**
* The current access token for the authentication user.
*/
protected ?stdClass $accessToken = null;
/**
* Get the current access token being used by the user.
*
* @return stdClass|null
*/
public function anikeenToken(): ?stdClass
{
return $this->accessToken;
}
/**
* Determine if the current API token has a given scope.
*/
public function anikeenTokenCan(string $scope): bool
{
$scopes = $this->accessToken ? $this->accessToken->scopes : [];
return in_array('*', $scopes) || in_array($scope, $this->accessToken->scopes);
}
/**
* Set the current access token for the user.
*/
public function withAnikeenAccessToken(stdClass $accessToken): self
{
$this->accessToken = $accessToken;
return $this;
}
}