コード例 #1
0
ファイル: Otp.php プロジェクト: surfnet/stepup-bundle
 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);
 }
コード例 #2
0
 /**
  * @param string $userOtp
  * @return OtpVerification
  */
 public function verify($userOtp)
 {
     if ($this->verificationAttemptsMade >= self::MAXIMUM_VERIFICATION_ATTEMPTS) {
         return OtpVerification::tooManyAttempts();
     }
     $this->verificationAttemptsMade++;
     if (!is_string($userOtp)) {
         throw InvalidArgumentException::invalidType('string', 'userOtp', $userOtp);
     }
     foreach ($this->otps as $otp) {
         $verification = $otp->verify($userOtp);
         if ($verification->didOtpMatch()) {
             return $verification;
         }
     }
     return OtpVerification::noMatch();
 }