Skip to content

Commit

Permalink
add token deleter
Browse files Browse the repository at this point in the history
  • Loading branch information
HichemTab-tech committed Jul 29, 2023
1 parent f5f5585 commit ae0115a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Results/Authentication/AuthTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AuthTokenResponse extends BaseResults
*/
public function __construct(AuthTokenResponseBuilder $builder)
{
parent::__construct($builder->isValidationSucceed(), $builder->getCause());
parent::__construct($builder->isValidationSucceed(), $builder->getCause(), $builder->getTokenId());
$this->userId = $builder->getUserId();
$this->newToken = $builder->getNewToken();
}
Expand Down
28 changes: 14 additions & 14 deletions src/Results/BaseResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ class BaseResults
private ?string $cause;

/**
* @var Exception|null Contains an exception explaining why the validation process failed.
* @var string|null Contains the ID of the token that was validated.
*/
private ?Exception $exception;
private ?string $tokenId;

/**
* @var string|null Contains the ID of the token that was validated.
* @var Exception|null Contains an exception explaining why the validation process failed.
*/
private ?string $tokenId;
private ?Exception $exception;

/**
* BaseResults constructor.
*
* @param bool $validationSucceed Indicates if the validation process succeeded or not.
* @param string|null $cause Contains a message explaining why the validation process failed.
*/
public function __construct(bool $validationSucceed, ?string $cause = null, ?Exception $exception = null, ?string $tokenId = null)
public function __construct(bool $validationSucceed, ?string $cause = null, ?string $tokenId = null, ?Exception $exception = null)
{
$this->validationSucceed = $validationSucceed;
$this->cause = $cause;
$this->exception = $exception;
$this->tokenId = $tokenId;
$this->exception = $exception;
}

/**
Expand All @@ -66,23 +66,23 @@ public function getCause(): ?string
}

/**
* Getter method for the exception caused a validation failure.
* Getter method for the ID of the token that was validated.
*
* @return Exception|null Contains an exception explaining why the validation process failed.
* @return string|null Contains the ID of the token that was validated.
*/
public function getException(): ?Exception
public function getTokenId(): ?string
{
return $this->exception;
return $this->tokenId;
}

/**
* Getter method for the ID of the token that was validated.
* Getter method for the exception caused a validation failure.
*
* @return string|null Contains the ID of the token that was validated.
* @return Exception|null Contains an exception explaining why the validation process failed.
*/
public function getTokenId(): ?string
public function getException(): ?Exception
{
return $this->tokenId;
return $this->exception;
}

/**
Expand Down
30 changes: 19 additions & 11 deletions src/Results/BaseResultsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class BaseResultsBuilder
{
private bool $validationSucceed;
private ?string $cause;
private ?Exception $exception;
private ?string $tokenId;
private ?Exception $exception;

/**
* BaseResultsBuilder constructor.
Expand All @@ -23,8 +23,8 @@ public function __construct()
{
$this->validationSucceed = false;
$this->cause = null;
$this->exception = null;
$this->tokenId = null;
$this->exception = null;
}

/**
Expand Down Expand Up @@ -52,26 +52,26 @@ public function setCause(?string $cause): self
}

/**
* Sets the exception caused a validation failure.
* Sets the ID of the token that was validated.
*
* @param Exception|null $exception Contains an exception explaining why the validation process failed.
* @param string|null $tokenId Contains the ID of the token that was validated.
* @return $this This instance of the BaseResultsBuilder object.
*/
public function setException(?Exception $exception): self
public function setTokenId(?string $tokenId): self
{
$this->exception = $exception;
$this->tokenId = $tokenId;
return $this;
}

/**
* Sets the ID of the token that was validated.
* Sets the exception caused a validation failure.
*
* @param string|null $tokenId Contains the ID of the token that was validated.
* @param Exception|null $exception Contains an exception explaining why the validation process failed.
* @return $this This instance of the BaseResultsBuilder object.
*/
public function setTokenId(?string $tokenId): self
public function setException(?Exception $exception): self
{
$this->tokenId = $tokenId;
$this->exception = $exception;
return $this;
}

Expand All @@ -82,7 +82,7 @@ public function setTokenId(?string $tokenId): self
*/
public function build(): BaseResults
{
return new BaseResults($this->validationSucceed, $this->cause, $this->exception, $this->tokenId);
return new BaseResults($this->validationSucceed, $this->cause, $this->tokenId, $this->exception);
}

/**
Expand All @@ -100,4 +100,12 @@ public function getCause(): ?string
{
return $this->cause;
}

/**
* @return string|null
*/
public function getTokenId(): ?string
{
return $this->tokenId;
}
}
2 changes: 1 addition & 1 deletion src/Results/Confirmation/ConfirmationTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConfirmationTokenResponse extends BaseResults

public function __construct(ConfirmationTokenResponseBuilder $builder)
{
parent::__construct($builder->isValidationSucceed(), $builder->getCause());
parent::__construct($builder->isValidationSucceed(), $builder->getCause(), $builder->getTokenId());
$this->userId = $builder->getUserId();
$this->whatFor = $builder->getWhatFor();
}
Expand Down

0 comments on commit ae0115a

Please sign in to comment.