Jackalope\Transport\Jackrabbit\Client::parseTimeout PHP Method

parseTimeout() protected method

The timeout value follows the syntax defined in RFC2518: Timeout Header. Here we just parse the values in the form "Second-XXXX" or "Infinite". Any other value will produce an error. The function returns the unix epoch timestamp for the second when this lock will expire in case of normal timeout, or PHP_INT_MAX in case of an "Infinite" timeout.
protected parseTimeout ( string $timeoutValue ) : integer
$timeoutValue string The timeout in seconds or PHP_INT_MAX for infinite
return integer the expire timestamp to be used with Lock::setExpireTime, that is when this lock expires in seconds since 1970 or null for inifinite
    protected function parseTimeout($timeoutValue)
    {
        if (self::JCR_INFINITE == $timeoutValue) {
            return null;
        }
        if (!preg_match('/Second\\-([\\d]+)/', $timeoutValue, $matches)) {
            throw new RepositoryException("Unexpected response on lock from the backend, could not parse seconds out of '{$timeoutValue}'");
        }
        $time = $matches[1];
        // keep this hack for jackrabbit 2.3.7 for now. it reported a bogous value for the timeout
        if (self::JCR_INFINITE_LOCK_TIMEOUT == $time || self::JCR_INFINITE_LOCK_TIMEOUT - 1 == $time) {
            // prevent glitches due to second boundary during request
            return null;
        }
        return time() + $time;
    }