Psr7Middlewares\Middleware\FormTimestamp::isValid PHP Метод

isValid() приватный Метод

Check whether the request is valid.
private isValid ( Psr\Http\Message\ServerRequestInterface $request ) : boolean
$request Psr\Http\Message\ServerRequestInterface
Результат boolean
    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;
    }