Exemple #1
0
 public function verify($userOtp)
 {
     if (!is_string($userOtp)) {
         throw InvalidArgumentException::invalidType('string', 'userOtp', $userOtp);
     }
     if (strtoupper($userOtp) !== strtoupper($this->otp)) {
         return OtpVerification::noMatch();
     }
     $expiryTime = clone $this->issuedAt;
     $expiryTime->add($this->expiryInterval);
     if ($expiryTime <= DateTime::now()) {
         return OtpVerification::matchExpired();
     }
     return OtpVerification::foundMatch($this->phoneNumber);
 }