protected function validateTimestamps(array $payload)
    {
        $timestamp = $this->timestamp ?: \time();
        $checks    = [
            ['exp', $this->leeway /*          */ , static::ERROR_TOKEN_EXPIRED, 'Expired'],
            ['iat', $this->maxAge - $this->leeway, static::ERROR_TOKEN_EXPIRED, 'Expired'],
            ['nbf', $this->maxAge - $this->leeway, static::ERROR_TOKEN_NOT_NOW, 'Not now'],
        ];

        foreach ($checks as list($key, $offset, $code, $error)) {
            if (isset($payload[$key])) {
                $offset += $payload[$key];
                $fail    = $key === 'nbf' ? $timestamp <= $offset : $timestamp >= $offset;

                if ($fail) {
                    throw new JWTException('Invalid token: ' . $error, $code);
                }
            }
        }
    }
protected function validateTimestamps(array $payload)
    {
        $timestamp = $this->timestamp ?: \time();
        $checks    = [
            ['exp', $this->leeway /*          */ , static::ERROR_TOKEN_EXPIRED, 'Expired'],
            ['iat', $this->maxAge - $this->leeway, static::ERROR_TOKEN_EXPIRED, 'Expired'],
            ['nbf', $this->maxAge - $this->leeway, static::ERROR_TOKEN_NOT_NOW, 'Not now'],
        ];

        foreach ($checks as list($key, $offset, $code, $error)) {
            if (isset($payload[$key])) {
                $offset += $payload[$key];
                $fail    = $key === 'nbf' ? $timestamp <= $offset : $timestamp >= $offset;

                if ($fail) {
                    throw new JWTException('Invalid token: ' . $error, $code);
                }
            }
        }
    }
protected function validateTimestamps ( array $ payload ) { $ timestamp = $ this -> timestamp ? : \ time ( ) ; $ checks = [ [ 'exp' , $ this -> leeway /*          */ , static :: ERROR_TOKEN_EXPIRED , 'Expired' ] , [ 'iat' , $ this -> maxAge - $ this -> leeway , static :: ERROR_TOKEN_EXPIRED , 'Expired' ] , [ 'nbf' , $ this -> maxAge - $ this -> leeway , static :: ERROR_TOKEN_NOT_NOW , 'Not now' ] , ] ; foreach ( $ checks as list ( $ key , $ offset , $ code , $ error ) ) { if ( isset ( $ payload [ $ key ] ) ) { $ offset += $ payload [ $ key ] ; $ fail = $ key === 'nbf' ? $ timestamp <= $ offset : $ timestamp >= $ offset ; if ( $ fail ) { throw new JWTException ( 'Invalid token: ' . $ error , $ code ) ; } } } }
Throw up if timestamp claims like iat, exp, nbf are invalid.
Throw up if timestamp claims like iat exp nbf are invalid .