private function isValid(ServerRequestInterface $request)
{
$data = $request->getParsedBody();
//value does not exists
if (empty($data[$this->inputName])) {
return false;
}
try {
$time = $this->decrypt($data[$this->inputName]);
} catch (Exception $e) {
return false;
}
//value is not valid
if (!is_numeric($time)) {
return false;
}
$now = time();
//sent from future
if ($now < $time) {
return false;
}
$diff = $now - $time;
//check min
if ($diff < $this->min) {
return false;
}
//check max
if ($this->max && $diff > $this->max) {
return false;
}
return true;
}