Update php doc and properties types

This commit is contained in:
Artem Vasilev 2024-03-12 23:08:37 +03:00
parent bd90a550f2
commit fb8f2fa9f2

View File

@ -41,31 +41,31 @@ class AuthCodeRepository implements AuthCodeRepositoryInterface
return new AuthCode(); return new AuthCode();
} }
public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity) /**
{ * @param AuthCodeEntityInterface $authCodeEntity
$found = false; *
try * @return void
* @throws UniqueTokenIdentifierConstraintViolationException
* @throws \Exception
* @since version
*/
public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity): void
{ {
$authCode = $this->authCodeModel->getItemByIdentifier($authCodeEntity->getIdentifier()); $authCode = $this->authCodeModel->getItemByIdentifier($authCodeEntity->getIdentifier());
if ($authCode->id > 0) if ($authCode !== false)
{
$found = true;
}
}
catch (\Throwable $e)
{
}
if ($found)
{ {
throw UniqueTokenIdentifierConstraintViolationException::create(); throw UniqueTokenIdentifierConstraintViolationException::create();
} }
$data = $authCodeEntity->getData(); $data = $authCodeEntity->getData();
$client = $this->clientModel->getItemByIdentifier($authCodeEntity->getClient()->getIdentifier()); $client = $this->clientModel->getItemByIdentifier($data['client_identifier']);
if ($client === false)
{
throw new \RuntimeException($this->clientModel->getError());
}
$data['client_id'] = $client->id; $data['client_id'] = $client->id;
unset($data['client_identifier']); unset($data['client_identifier']);
@ -73,20 +73,27 @@ class AuthCodeRepository implements AuthCodeRepositoryInterface
$this->authCodeModel->save($data); $this->authCodeModel->save($data);
} }
public function revokeAuthCode($codeId) public function revokeAuthCode($codeId): void
{ {
$this->authCodeModel->revoke($codeId); $this->authCodeModel->revoke($codeId);
} }
public function isAuthCodeRevoked($codeId) /**
* @param string $codeId
*
* @throws \Exception
* @since version
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
public function isAuthCodeRevoked($codeId): bool
{ {
$authCode = $this->authCodeModel->getItemByIdentifier($codeId); $authCode = $this->authCodeModel->getItemByIdentifier($codeId);
if (empty($authCode->id)) if ($authCode === false)
{ {
return true; return true;
} }
return !!$authCode->revoked; return (bool) $authCode->revoked;
} }
} }