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);
}
/** * @dataProvider testVerifyData */ public function testVerify($secret, $input, $output, $expectedResult) { $totp = new TOTP($secret); $this->assertEquals($expectedResult, $totp->verify($output, $input)); }