54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Otp;
|
|
|
|
use App\Models\OtpCode;
|
|
|
|
class OtpVerifyResult
|
|
{
|
|
public const STATUS_OK = 'ok';
|
|
|
|
public const STATUS_INVALID = 'invalid';
|
|
|
|
public const STATUS_EXPIRED = 'expired';
|
|
|
|
public const STATUS_EXHAUSTED = 'exhausted';
|
|
|
|
public const STATUS_NOT_FOUND = 'not_found';
|
|
|
|
public function __construct(
|
|
public readonly string $status,
|
|
public readonly ?OtpCode $otp = null,
|
|
) {}
|
|
|
|
public function isOk(): bool
|
|
{
|
|
return $this->status === self::STATUS_OK;
|
|
}
|
|
|
|
public static function ok(OtpCode $otp): self
|
|
{
|
|
return new self(self::STATUS_OK, $otp);
|
|
}
|
|
|
|
public static function invalid(?OtpCode $otp): self
|
|
{
|
|
return new self(self::STATUS_INVALID, $otp);
|
|
}
|
|
|
|
public static function expired(): self
|
|
{
|
|
return new self(self::STATUS_EXPIRED);
|
|
}
|
|
|
|
public static function exhausted(): self
|
|
{
|
|
return new self(self::STATUS_EXHAUSTED);
|
|
}
|
|
|
|
public static function notFound(): self
|
|
{
|
|
return new self(self::STATUS_NOT_FOUND);
|
|
}
|
|
}
|