public function testSetTimeoutAsObject() { $this->lock->setTimeout(TimeoutHeader::getInfinite()); $this->assertEquals(TimeoutHeader::INFINITE, $this->lock->getTimeout()); }
/** * Refresh an existing lock by resetting its timeout. * * Performs a <tt>LOCK</tt> request as defined in the * {@link http://tools.ietf.org/html/rfc4918#section-9.10.2 Section 9.10.2 of RFC-4918}. * * Note that the timeout value may be suggested when refreshing the lock, but that the server * ultimately chooses the timeout value. * * @param string $uri * Resource URI * @param string $lockToken * The lock token identifying the lock to be refreshed * @param int $timeout * Number of seconds remaining until lock expiration * * @return Lock Returns the refreshed lock on success, or <tt>null</tt> on failure */ public function refreshLock($uri, $lockToken, $timeout = null) { $headers = array('If' => "(<{$lockToken}>)"); if ($timeout) { $headers['Timeout'] = (string) TimeoutHeader::parse($timeout); } $request = $this->createRequest('LOCK', $uri, $headers); $response = $this->doRequest($request); return $response->isSuccessful() ? Lock::parse($this, $response->getBody()) : null; }
/** * @param string|int|TimeoutHeader $timeout Number of seconds until the lock is expiring */ public function setTimeout($timeout) { if ($timeout instanceof TimeoutHeader) { $this->timeout = $timeout; } elseif (is_int($timeout)) { $this->timeout = new TimeoutHeader($timeout); } else { $this->timeout = TimeoutHeader::parse($timeout); } }