39 public function verify($input, $params =
null, $time =
null)
41 $input = (string)$input;
48 if (!preg_match(
'#^\d+$#D', $input))
53 [$userOffset, $lastTimeCode] = explode(
':', $params);
54 $userOffset = (int)$userOffset;
55 $lastTimeCode = (int)$lastTimeCode;
63 $timeCode = $this->
timecode((
int)$time);
68 $checkOffsets[] = $userOffset;
78 $checkOffsets = array_merge(
80 range($userOffset - $this->window, $userOffset + $this->window)
88 foreach ($checkOffsets as $offset)
90 $code = $timeCode + $offset;
92 if ($lastTimeCode && $code <= $lastTimeCode)
100 $resultOffset = $offset;
101 $resultTimeCode = $code;
106 if ($isSuccess ===
true)
108 return [
true, sprintf(
'%d:%d', $resultOffset, $resultTimeCode)];
111 return [
false,
null];