OTPHP\TOTP::verify PHP Метод

verify() публичный Метод

If no timestamp is provided, the OTP is verified at the actual timestamp {@inheritdoc}
public verify ( $otp, $timestamp = null, $window = null )
    public function verify($otp, $timestamp = null, $window = null)
    {
        Assertion::string($otp, 'The OTP must be a string');
        Assertion::nullOrInteger($timestamp, 'The timestamp must be null or an integer');
        Assertion::nullOrInteger($window, 'The window parameter must be null or an integer');
        $timestamp = $this->getTimestamp($timestamp);
        if (null === $window) {
            return $this->compareOTP($this->at($timestamp), $otp);
        }
        return $this->verifyOtpWithWindow($otp, $timestamp, $window);
    }

Usage Example

 /**
  * @dataProvider testVerifyData
  */
 public function testVerify($secret, $input, $output, $expectedResult)
 {
     $totp = new TOTP($secret);
     $this->assertEquals($expectedResult, $totp->verify($output, $input));
 }
All Usage Examples Of OTPHP\TOTP::verify