From b011094cd8908b0fdb29f43951d58a90a84831e8 Mon Sep 17 00:00:00 2001 From: denismacak Date: Mon, 1 Feb 2021 19:39:44 +0100 Subject: [PATCH] Decoupled managers from models, created interfaces for models --- Manager/AccessTokenManagerInterface.php | 6 +-- Manager/AuthorizationCodeManagerInterface.php | 6 +-- Manager/ClientFilter.php | 24 ++++++------ Manager/ClientManagerInterface.php | 8 ++-- Manager/Doctrine/AccessTokenManager.php | 5 ++- Manager/Doctrine/AuthorizationCodeManager.php | 5 ++- Manager/Doctrine/ClientManager.php | 7 ++-- Manager/Doctrine/RefreshTokenManager.php | 5 ++- Manager/InMemory/AccessTokenManager.php | 12 +++--- Manager/InMemory/AuthorizationCodeManager.php | 9 +++-- Manager/InMemory/ClientManager.php | 12 +++--- Manager/InMemory/RefreshTokenManager.php | 12 +++--- Manager/InMemory/ScopeManager.php | 8 ++-- Manager/RefreshTokenManagerInterface.php | 6 +-- Manager/ScopeManagerInterface.php | 6 +-- Model/AccessToken.php | 12 +++--- Model/AccessTokenInterface.php | 26 +++++++++++++ Model/AuthorizationCode.php | 12 +++--- Model/AuthorizationCodeInterface.php | 26 +++++++++++++ Model/Client.php | 26 ++++++------- Model/ClientInterface.php | 38 +++++++++++++++++++ Model/Grant.php | 2 +- Model/GrantInterface.php | 10 +++++ Model/RedirectUri.php | 2 +- Model/RedirectUriInterface.php | 10 +++++ Model/RefreshToken.php | 6 +-- Model/RefreshTokenInterface.php | 22 +++++++++++ Model/Scope.php | 2 +- Model/ScopeInterface.php | 10 +++++ Service/ClientFinderInterface.php | 4 +- 30 files changed, 243 insertions(+), 96 deletions(-) create mode 100644 Model/AccessTokenInterface.php create mode 100644 Model/AuthorizationCodeInterface.php create mode 100644 Model/ClientInterface.php create mode 100644 Model/GrantInterface.php create mode 100644 Model/RedirectUriInterface.php create mode 100644 Model/RefreshTokenInterface.php create mode 100644 Model/ScopeInterface.php diff --git a/Manager/AccessTokenManagerInterface.php b/Manager/AccessTokenManagerInterface.php index 31f1158b..60435d40 100644 --- a/Manager/AccessTokenManagerInterface.php +++ b/Manager/AccessTokenManagerInterface.php @@ -4,16 +4,16 @@ namespace Trikoder\Bundle\OAuth2Bundle\Manager; -use Trikoder\Bundle\OAuth2Bundle\Model\AccessToken; +use Trikoder\Bundle\OAuth2Bundle\Model\AccessTokenInterface; /** * @method int clearRevoked() not defining this method is deprecated since version 3.2 */ interface AccessTokenManagerInterface { - public function find(string $identifier): ?AccessToken; + public function find(string $identifier): ?AccessTokenInterface; - public function save(AccessToken $accessToken): void; + public function save(AccessTokenInterface $accessToken): void; public function clearExpired(): int; } diff --git a/Manager/AuthorizationCodeManagerInterface.php b/Manager/AuthorizationCodeManagerInterface.php index c39c78df..e9c895aa 100644 --- a/Manager/AuthorizationCodeManagerInterface.php +++ b/Manager/AuthorizationCodeManagerInterface.php @@ -4,16 +4,16 @@ namespace Trikoder\Bundle\OAuth2Bundle\Manager; -use Trikoder\Bundle\OAuth2Bundle\Model\AuthorizationCode; +use Trikoder\Bundle\OAuth2Bundle\Model\AuthorizationCodeInterface; /** * @method int clearRevoked() not defining this method is deprecated since version 3.2 */ interface AuthorizationCodeManagerInterface { - public function find(string $identifier): ?AuthorizationCode; + public function find(string $identifier): ?AuthorizationCodeInterface; - public function save(AuthorizationCode $authCode): void; + public function save(AuthorizationCodeInterface $authCode): void; public function clearExpired(): int; } diff --git a/Manager/ClientFilter.php b/Manager/ClientFilter.php index ad789009..4f3a3511 100644 --- a/Manager/ClientFilter.php +++ b/Manager/ClientFilter.php @@ -4,24 +4,24 @@ namespace Trikoder\Bundle\OAuth2Bundle\Manager; -use Trikoder\Bundle\OAuth2Bundle\Model\Grant; -use Trikoder\Bundle\OAuth2Bundle\Model\RedirectUri; -use Trikoder\Bundle\OAuth2Bundle\Model\Scope; +use Trikoder\Bundle\OAuth2Bundle\Model\GrantInterface; +use Trikoder\Bundle\OAuth2Bundle\Model\RedirectUriInterface; +use Trikoder\Bundle\OAuth2Bundle\Model\ScopeInterface; final class ClientFilter { /** - * @var Grant[] + * @var GrantInterface[] */ private $grants = []; /** - * @var RedirectUri[] + * @var RedirectUriInterface[] */ private $redirectUris = []; /** - * @var Scope[] + * @var ScopeInterface[] */ private $scopes = []; @@ -30,17 +30,17 @@ public static function create(): self return new static(); } - public function addGrantCriteria(Grant ...$grants): self + public function addGrantCriteria(GrantInterface ...$grants): self { return $this->addCriteria($this->grants, ...$grants); } - public function addRedirectUriCriteria(RedirectUri ...$redirectUris): self + public function addRedirectUriCriteria(RedirectUriInterface ...$redirectUris): self { return $this->addCriteria($this->redirectUris, ...$redirectUris); } - public function addScopeCriteria(Scope ...$scopes): self + public function addScopeCriteria(ScopeInterface ...$scopes): self { return $this->addCriteria($this->scopes, ...$scopes); } @@ -57,7 +57,7 @@ private function addCriteria(&$field, ...$values): self } /** - * @return Grant[] + * @return GrantInterface[] */ public function getGrants(): array { @@ -65,7 +65,7 @@ public function getGrants(): array } /** - * @return RedirectUri[] + * @return RedirectUriInterface[] */ public function getRedirectUris(): array { @@ -73,7 +73,7 @@ public function getRedirectUris(): array } /** - * @return Scope[] + * @return ScopeInterface[] */ public function getScopes(): array { diff --git a/Manager/ClientManagerInterface.php b/Manager/ClientManagerInterface.php index 35169386..833fa8e4 100644 --- a/Manager/ClientManagerInterface.php +++ b/Manager/ClientManagerInterface.php @@ -4,17 +4,17 @@ namespace Trikoder\Bundle\OAuth2Bundle\Manager; -use Trikoder\Bundle\OAuth2Bundle\Model\Client; +use Trikoder\Bundle\OAuth2Bundle\Model\ClientInterface; use Trikoder\Bundle\OAuth2Bundle\Service\ClientFinderInterface; interface ClientManagerInterface extends ClientFinderInterface { - public function save(Client $client): void; + public function save(ClientInterface $client): void; - public function remove(Client $client): void; + public function remove(ClientInterface $client): void; /** - * @return Client[] + * @return ClientInterface[] */ public function list(?ClientFilter $clientFilter): array; } diff --git a/Manager/Doctrine/AccessTokenManager.php b/Manager/Doctrine/AccessTokenManager.php index 40ab3f7d..970dad24 100644 --- a/Manager/Doctrine/AccessTokenManager.php +++ b/Manager/Doctrine/AccessTokenManager.php @@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Trikoder\Bundle\OAuth2Bundle\Manager\AccessTokenManagerInterface; use Trikoder\Bundle\OAuth2Bundle\Model\AccessToken; +use Trikoder\Bundle\OAuth2Bundle\Model\AccessTokenInterface; final class AccessTokenManager implements AccessTokenManagerInterface { @@ -24,7 +25,7 @@ public function __construct(EntityManagerInterface $entityManager) /** * {@inheritdoc} */ - public function find(string $identifier): ?AccessToken + public function find(string $identifier): ?AccessTokenInterface { return $this->entityManager->find(AccessToken::class, $identifier); } @@ -32,7 +33,7 @@ public function find(string $identifier): ?AccessToken /** * {@inheritdoc} */ - public function save(AccessToken $accessToken): void + public function save(AccessTokenInterface $accessToken): void { $this->entityManager->persist($accessToken); $this->entityManager->flush(); diff --git a/Manager/Doctrine/AuthorizationCodeManager.php b/Manager/Doctrine/AuthorizationCodeManager.php index 766800af..8136b04e 100644 --- a/Manager/Doctrine/AuthorizationCodeManager.php +++ b/Manager/Doctrine/AuthorizationCodeManager.php @@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Trikoder\Bundle\OAuth2Bundle\Manager\AuthorizationCodeManagerInterface; use Trikoder\Bundle\OAuth2Bundle\Model\AuthorizationCode; +use Trikoder\Bundle\OAuth2Bundle\Model\AuthorizationCodeInterface; final class AuthorizationCodeManager implements AuthorizationCodeManagerInterface { @@ -24,7 +25,7 @@ public function __construct(EntityManagerInterface $entityManager) /** * {@inheritdoc} */ - public function find(string $identifier): ?AuthorizationCode + public function find(string $identifier): ?AuthorizationCodeInterface { return $this->entityManager->find(AuthorizationCode::class, $identifier); } @@ -32,7 +33,7 @@ public function find(string $identifier): ?AuthorizationCode /** * {@inheritdoc} */ - public function save(AuthorizationCode $authorizationCode): void + public function save(AuthorizationCodeInterface $authorizationCode): void { $this->entityManager->persist($authorizationCode); $this->entityManager->flush(); diff --git a/Manager/Doctrine/ClientManager.php b/Manager/Doctrine/ClientManager.php index 797923b6..a5848219 100644 --- a/Manager/Doctrine/ClientManager.php +++ b/Manager/Doctrine/ClientManager.php @@ -8,6 +8,7 @@ use Trikoder\Bundle\OAuth2Bundle\Manager\ClientFilter; use Trikoder\Bundle\OAuth2Bundle\Manager\ClientManagerInterface; use Trikoder\Bundle\OAuth2Bundle\Model\Client; +use Trikoder\Bundle\OAuth2Bundle\Model\ClientInterface; final class ClientManager implements ClientManagerInterface { @@ -24,7 +25,7 @@ public function __construct(EntityManagerInterface $entityManager) /** * {@inheritdoc} */ - public function find(string $identifier): ?Client + public function find(string $identifier): ?ClientInterface { return $this->entityManager->find(Client::class, $identifier); } @@ -32,7 +33,7 @@ public function find(string $identifier): ?Client /** * {@inheritdoc} */ - public function save(Client $client): void + public function save(ClientInterface $client): void { $this->entityManager->persist($client); $this->entityManager->flush(); @@ -41,7 +42,7 @@ public function save(Client $client): void /** * {@inheritdoc} */ - public function remove(Client $client): void + public function remove(ClientInterface $client): void { $this->entityManager->remove($client); $this->entityManager->flush(); diff --git a/Manager/Doctrine/RefreshTokenManager.php b/Manager/Doctrine/RefreshTokenManager.php index 29e4b6ca..fcdd1d04 100644 --- a/Manager/Doctrine/RefreshTokenManager.php +++ b/Manager/Doctrine/RefreshTokenManager.php @@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Trikoder\Bundle\OAuth2Bundle\Manager\RefreshTokenManagerInterface; use Trikoder\Bundle\OAuth2Bundle\Model\RefreshToken; +use Trikoder\Bundle\OAuth2Bundle\Model\RefreshTokenInterface; final class RefreshTokenManager implements RefreshTokenManagerInterface { @@ -24,7 +25,7 @@ public function __construct(EntityManagerInterface $entityManager) /** * {@inheritdoc} */ - public function find(string $identifier): ?RefreshToken + public function find(string $identifier): ?RefreshTokenInterface { return $this->entityManager->find(RefreshToken::class, $identifier); } @@ -32,7 +33,7 @@ public function find(string $identifier): ?RefreshToken /** * {@inheritdoc} */ - public function save(RefreshToken $refreshToken): void + public function save(RefreshTokenInterface $refreshToken): void { $this->entityManager->persist($refreshToken); $this->entityManager->flush(); diff --git a/Manager/InMemory/AccessTokenManager.php b/Manager/InMemory/AccessTokenManager.php index 7a1f2cd8..eea81b64 100644 --- a/Manager/InMemory/AccessTokenManager.php +++ b/Manager/InMemory/AccessTokenManager.php @@ -6,19 +6,19 @@ use DateTimeImmutable; use Trikoder\Bundle\OAuth2Bundle\Manager\AccessTokenManagerInterface; -use Trikoder\Bundle\OAuth2Bundle\Model\AccessToken; +use Trikoder\Bundle\OAuth2Bundle\Model\AccessTokenInterface; final class AccessTokenManager implements AccessTokenManagerInterface { /** - * @var AccessToken[] + * @var AccessTokenInterface[] */ private $accessTokens = []; /** * {@inheritdoc} */ - public function find(string $identifier): ?AccessToken + public function find(string $identifier): ?AccessTokenInterface { return $this->accessTokens[$identifier] ?? null; } @@ -26,7 +26,7 @@ public function find(string $identifier): ?AccessToken /** * {@inheritdoc} */ - public function save(AccessToken $accessToken): void + public function save(AccessTokenInterface $accessToken): void { $this->accessTokens[$accessToken->getIdentifier()] = $accessToken; } @@ -36,7 +36,7 @@ public function clearExpired(): int $count = \count($this->accessTokens); $now = new DateTimeImmutable(); - $this->accessTokens = array_filter($this->accessTokens, static function (AccessToken $accessToken) use ($now): bool { + $this->accessTokens = array_filter($this->accessTokens, static function (AccessTokenInterface $accessToken) use ($now): bool { return $accessToken->getExpiry() >= $now; }); @@ -47,7 +47,7 @@ public function clearRevoked(): int { $count = \count($this->accessTokens); - $this->accessTokens = array_filter($this->accessTokens, static function (AccessToken $accessToken): bool { + $this->accessTokens = array_filter($this->accessTokens, static function (AccessTokenInterface $accessToken): bool { return !$accessToken->isRevoked(); }); diff --git a/Manager/InMemory/AuthorizationCodeManager.php b/Manager/InMemory/AuthorizationCodeManager.php index 8e0bff9c..82a51b21 100644 --- a/Manager/InMemory/AuthorizationCodeManager.php +++ b/Manager/InMemory/AuthorizationCodeManager.php @@ -7,6 +7,7 @@ use DateTimeImmutable; use Trikoder\Bundle\OAuth2Bundle\Manager\AuthorizationCodeManagerInterface; use Trikoder\Bundle\OAuth2Bundle\Model\AuthorizationCode; +use Trikoder\Bundle\OAuth2Bundle\Model\AuthorizationCodeInterface; final class AuthorizationCodeManager implements AuthorizationCodeManagerInterface { @@ -15,12 +16,12 @@ final class AuthorizationCodeManager implements AuthorizationCodeManagerInterfac */ private $authorizationCodes = []; - public function find(string $identifier): ?AuthorizationCode + public function find(string $identifier): ?AuthorizationCodeInterface { return $this->authorizationCodes[$identifier] ?? null; } - public function save(AuthorizationCode $authorizationCode): void + public function save(AuthorizationCodeInterface $authorizationCode): void { $this->authorizationCodes[$authorizationCode->getIdentifier()] = $authorizationCode; } @@ -30,7 +31,7 @@ public function clearExpired(): int $count = \count($this->authorizationCodes); $now = new DateTimeImmutable(); - $this->authorizationCodes = array_filter($this->authorizationCodes, static function (AuthorizationCode $authorizationCode) use ($now): bool { + $this->authorizationCodes = array_filter($this->authorizationCodes, static function (AuthorizationCodeInterface $authorizationCode) use ($now): bool { return $authorizationCode->getExpiryDateTime() >= $now; }); @@ -41,7 +42,7 @@ public function clearRevoked(): int { $count = \count($this->authorizationCodes); - $this->authorizationCodes = array_filter($this->authorizationCodes, static function (AuthorizationCode $authorizationCode): bool { + $this->authorizationCodes = array_filter($this->authorizationCodes, static function (AuthorizationCodeInterface $authorizationCode): bool { return !$authorizationCode->isRevoked(); }); diff --git a/Manager/InMemory/ClientManager.php b/Manager/InMemory/ClientManager.php index 10a5fbd9..1187c93c 100644 --- a/Manager/InMemory/ClientManager.php +++ b/Manager/InMemory/ClientManager.php @@ -6,19 +6,19 @@ use Trikoder\Bundle\OAuth2Bundle\Manager\ClientFilter; use Trikoder\Bundle\OAuth2Bundle\Manager\ClientManagerInterface; -use Trikoder\Bundle\OAuth2Bundle\Model\Client; +use Trikoder\Bundle\OAuth2Bundle\Model\ClientInterface; final class ClientManager implements ClientManagerInterface { /** - * @var Client[] + * @var ClientInterface[] */ private $clients = []; /** * {@inheritdoc} */ - public function find(string $identifier): ?Client + public function find(string $identifier): ?ClientInterface { return $this->clients[$identifier] ?? null; } @@ -26,7 +26,7 @@ public function find(string $identifier): ?Client /** * {@inheritdoc} */ - public function save(Client $client): void + public function save(ClientInterface $client): void { $this->clients[$client->getIdentifier()] = $client; } @@ -34,7 +34,7 @@ public function save(Client $client): void /** * {@inheritdoc} */ - public function remove(Client $client): void + public function remove(ClientInterface $client): void { unset($this->clients[$client->getIdentifier()]); } @@ -48,7 +48,7 @@ public function list(?ClientFilter $clientFilter): array return $this->clients; } - return array_filter($this->clients, static function (Client $client) use ($clientFilter): bool { + return array_filter($this->clients, static function (ClientInterface $client) use ($clientFilter): bool { $grantsPassed = self::passesFilter($client->getGrants(), $clientFilter->getGrants()); $scopesPassed = self::passesFilter($client->getScopes(), $clientFilter->getScopes()); $redirectUrisPassed = self::passesFilter($client->getRedirectUris(), $clientFilter->getRedirectUris()); diff --git a/Manager/InMemory/RefreshTokenManager.php b/Manager/InMemory/RefreshTokenManager.php index 864db995..d0e69c2f 100644 --- a/Manager/InMemory/RefreshTokenManager.php +++ b/Manager/InMemory/RefreshTokenManager.php @@ -6,19 +6,19 @@ use DateTimeImmutable; use Trikoder\Bundle\OAuth2Bundle\Manager\RefreshTokenManagerInterface; -use Trikoder\Bundle\OAuth2Bundle\Model\RefreshToken; +use Trikoder\Bundle\OAuth2Bundle\Model\RefreshTokenInterface; final class RefreshTokenManager implements RefreshTokenManagerInterface { /** - * @var RefreshToken[] + * @var RefreshTokenInterface[] */ private $refreshTokens = []; /** * {@inheritdoc} */ - public function find(string $identifier): ?RefreshToken + public function find(string $identifier): ?RefreshTokenInterface { return $this->refreshTokens[$identifier] ?? null; } @@ -26,7 +26,7 @@ public function find(string $identifier): ?RefreshToken /** * {@inheritdoc} */ - public function save(RefreshToken $refreshToken): void + public function save(RefreshTokenInterface $refreshToken): void { $this->refreshTokens[$refreshToken->getIdentifier()] = $refreshToken; } @@ -36,7 +36,7 @@ public function clearExpired(): int $count = \count($this->refreshTokens); $now = new DateTimeImmutable(); - $this->refreshTokens = array_filter($this->refreshTokens, static function (RefreshToken $refreshToken) use ($now): bool { + $this->refreshTokens = array_filter($this->refreshTokens, static function (RefreshTokenInterface $refreshToken) use ($now): bool { return $refreshToken->getExpiry() >= $now; }); @@ -47,7 +47,7 @@ public function clearRevoked(): int { $count = \count($this->refreshTokens); - $this->refreshTokens = array_filter($this->refreshTokens, static function (RefreshToken $refreshToken): bool { + $this->refreshTokens = array_filter($this->refreshTokens, static function (RefreshTokenInterface $refreshToken): bool { return !$refreshToken->isRevoked(); }); diff --git a/Manager/InMemory/ScopeManager.php b/Manager/InMemory/ScopeManager.php index 2c0233bb..e99f2050 100644 --- a/Manager/InMemory/ScopeManager.php +++ b/Manager/InMemory/ScopeManager.php @@ -5,19 +5,19 @@ namespace Trikoder\Bundle\OAuth2Bundle\Manager\InMemory; use Trikoder\Bundle\OAuth2Bundle\Manager\ScopeManagerInterface; -use Trikoder\Bundle\OAuth2Bundle\Model\Scope; +use Trikoder\Bundle\OAuth2Bundle\Model\ScopeInterface; final class ScopeManager implements ScopeManagerInterface { /** - * @var Scope[] + * @var ScopeInterface[] */ private $scopes = []; /** * {@inheritdoc} */ - public function find(string $identifier): ?Scope + public function find(string $identifier): ?ScopeInterface { return $this->scopes[$identifier] ?? null; } @@ -25,7 +25,7 @@ public function find(string $identifier): ?Scope /** * {@inheritdoc} */ - public function save(Scope $scope): void + public function save(ScopeInterface $scope): void { $this->scopes[(string) $scope] = $scope; } diff --git a/Manager/RefreshTokenManagerInterface.php b/Manager/RefreshTokenManagerInterface.php index b1025e2c..3b72488e 100644 --- a/Manager/RefreshTokenManagerInterface.php +++ b/Manager/RefreshTokenManagerInterface.php @@ -4,16 +4,16 @@ namespace Trikoder\Bundle\OAuth2Bundle\Manager; -use Trikoder\Bundle\OAuth2Bundle\Model\RefreshToken; +use Trikoder\Bundle\OAuth2Bundle\Model\RefreshTokenInterface; /** * @method int clearRevoked() not defining this method is deprecated since version 3.2 */ interface RefreshTokenManagerInterface { - public function find(string $identifier): ?RefreshToken; + public function find(string $identifier): ?RefreshTokenInterface; - public function save(RefreshToken $refreshToken): void; + public function save(RefreshTokenInterface $refreshToken): void; public function clearExpired(): int; } diff --git a/Manager/ScopeManagerInterface.php b/Manager/ScopeManagerInterface.php index 36815599..979af964 100644 --- a/Manager/ScopeManagerInterface.php +++ b/Manager/ScopeManagerInterface.php @@ -4,11 +4,11 @@ namespace Trikoder\Bundle\OAuth2Bundle\Manager; -use Trikoder\Bundle\OAuth2Bundle\Model\Scope; +use Trikoder\Bundle\OAuth2Bundle\Model\ScopeInterface; interface ScopeManagerInterface { - public function find(string $identifier): ?Scope; + public function find(string $identifier): ?ScopeInterface; - public function save(Scope $scope): void; + public function save(ScopeInterface $scope): void; } diff --git a/Model/AccessToken.php b/Model/AccessToken.php index f18a0a1e..4cfeab6a 100644 --- a/Model/AccessToken.php +++ b/Model/AccessToken.php @@ -6,7 +6,7 @@ use DateTimeInterface; -class AccessToken +class AccessToken implements AccessTokenInterface { /** * @var string @@ -24,12 +24,12 @@ class AccessToken private $userIdentifier; /** - * @var Client + * @var ClientInterface */ private $client; /** - * @var Scope[] + * @var ScopeInterface[] */ private $scopes = []; @@ -41,7 +41,7 @@ class AccessToken public function __construct( string $identifier, DateTimeInterface $expiry, - Client $client, + ClientInterface $client, ?string $userIdentifier, array $scopes ) { @@ -72,7 +72,7 @@ public function getUserIdentifier(): ?string return $this->userIdentifier; } - public function getClient(): Client + public function getClient(): ClientInterface { return $this->client; } @@ -90,7 +90,7 @@ public function isRevoked(): bool return $this->revoked; } - public function revoke(): self + public function revoke(): AccessTokenInterface { $this->revoked = true; diff --git a/Model/AccessTokenInterface.php b/Model/AccessTokenInterface.php new file mode 100644 index 00000000..92188fbc --- /dev/null +++ b/Model/AccessTokenInterface.php @@ -0,0 +1,26 @@ +userIdentifier; } - public function getClient(): Client + public function getClient(): ClientInterface { return $this->client; } @@ -90,7 +90,7 @@ public function isRevoked(): bool return $this->revoked; } - public function revoke(): self + public function revoke(): AuthorizationCodeInterface { $this->revoked = true; diff --git a/Model/AuthorizationCodeInterface.php b/Model/AuthorizationCodeInterface.php new file mode 100644 index 00000000..8b3c1cad --- /dev/null +++ b/Model/AuthorizationCodeInterface.php @@ -0,0 +1,26 @@ +secret; } - public function setSecret(?string $secret): self + public function setSecret(?string $secret): ClientInterface { $this->secret = $secret; @@ -70,14 +70,14 @@ public function setSecret(?string $secret): self } /** - * @return RedirectUri[] + * @return RedirectUriInterface[] */ public function getRedirectUris(): array { return $this->redirectUris; } - public function setRedirectUris(RedirectUri ...$redirectUris): self + public function setRedirectUris(RedirectUriInterface ...$redirectUris): ClientInterface { $this->redirectUris = $redirectUris; @@ -85,14 +85,14 @@ public function setRedirectUris(RedirectUri ...$redirectUris): self } /** - * @return Grant[] + * @return GrantInterface[] */ public function getGrants(): array { return $this->grants; } - public function setGrants(Grant ...$grants): self + public function setGrants(GrantInterface ...$grants): ClientInterface { $this->grants = $grants; @@ -100,14 +100,14 @@ public function setGrants(Grant ...$grants): self } /** - * @return Scope[] + * @return ScopeInterface[] */ public function getScopes(): array { return $this->scopes; } - public function setScopes(Scope ...$scopes): self + public function setScopes(ScopeInterface ...$scopes): ClientInterface { $this->scopes = $scopes; @@ -119,7 +119,7 @@ public function isActive(): bool return $this->active; } - public function setActive(bool $active): self + public function setActive(bool $active): ClientInterface { $this->active = $active; @@ -136,7 +136,7 @@ public function isPlainTextPkceAllowed(): bool return $this->allowPlainTextPkce; } - public function setAllowPlainTextPkce(bool $allowPlainTextPkce): self + public function setAllowPlainTextPkce(bool $allowPlainTextPkce): ClientInterface { $this->allowPlainTextPkce = $allowPlainTextPkce; diff --git a/Model/ClientInterface.php b/Model/ClientInterface.php new file mode 100644 index 00000000..854617a2 --- /dev/null +++ b/Model/ClientInterface.php @@ -0,0 +1,38 @@ +expiry; } - public function getAccessToken(): ?AccessToken + public function getAccessToken(): ?AccessTokenInterface { return $this->accessToken; } @@ -60,7 +60,7 @@ public function isRevoked(): bool return $this->revoked; } - public function revoke(): self + public function revoke(): RefreshTokenInterface { $this->revoked = true; diff --git a/Model/RefreshTokenInterface.php b/Model/RefreshTokenInterface.php new file mode 100644 index 00000000..50e9f497 --- /dev/null +++ b/Model/RefreshTokenInterface.php @@ -0,0 +1,22 @@ +