1 | <?php |
||
21 | final class OtpVerification |
||
22 | { |
||
23 | const STATUS_NO_MATCH = 0; |
||
24 | const STATUS_MATCH_EXPIRED = 1; |
||
25 | const STATUS_FOUND_MATCH = 2; |
||
26 | const STATUS_TOO_MANY_ATTEMPTS = 3; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | private $status; |
||
32 | |||
33 | /** |
||
34 | * @var null|string |
||
35 | */ |
||
36 | private $phoneNumber; |
||
37 | |||
38 | public static function noMatch() |
||
42 | |||
43 | public static function matchExpired() |
||
47 | |||
48 | public static function foundMatch($phoneNumber) |
||
52 | |||
53 | public static function tooManyAttempts() |
||
57 | |||
58 | /** |
||
59 | * @param int $status |
||
60 | * @param string|null $phoneNumber |
||
61 | */ |
||
62 | private function __construct($status, $phoneNumber = null) |
||
67 | |||
68 | /** |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function wasSuccessful() |
||
75 | |||
76 | /** |
||
77 | * @return bool |
||
78 | */ |
||
79 | public function didOtpMatch() |
||
83 | /** |
||
84 | * @return bool |
||
85 | */ |
||
86 | public function didOtpExpire() |
||
90 | |||
91 | /** |
||
92 | * @return bool |
||
93 | */ |
||
94 | public function wasAttemptedTooManyTimes() |
||
98 | |||
99 | /** |
||
100 | * @return null|string Only guaranteed to be a string when status is successful. |
||
101 | */ |
||
102 | public function getPhoneNumber() |
||
106 | } |
||
107 |