/** * @dataProvider providerParseTime */ public function testParseTime($expected, $value) { $time = Header::parseTime($value); $this->assertEquals($expected, $time); }
public function testSetAndGetLastModified() { $time = time(); $this->response->setLastModified($time); $header = $this->response->getHeader('Last-Modified'); $this->assertNotNull($header); $this->assertEquals(Header::parseTime($time), $header); $this->assertEquals($time, $this->response->getLastModified()); $this->response->setLastModified(); $header = $this->response->getHeader('Last-Modified'); $this->assertNull($header); $this->assertNull($this->response->getLastModified()); }
/** * Gets the timestamp of the conditional modified since header * @return integer|null The timestamp if the header was set, null otherwise */ public function getIfModifiedSince() { if (isset($this->ifModifiedSince)) { return $this->ifModifiedSince; } $header = $this->getHeader(Header::HEADER_IF_MODIFIED_SINCE); if (!$header) { return $this->ifModifiedSince = null; } return $this->ifModifiedSince = Header::parseTime($header); }
/** * Sets the date the content was last modified * @param integer $timestamp Timestamp of the date * @return null */ public function setLastModified($timestamp = null) { if ($timestamp === null) { $this->dateLastModified = null; $this->headers->removeHeader(Header::HEADER_LAST_MODIFIED); return; } if (!Number::isNumeric($timestamp, Number::NOT_NEGATIVE | Number::NOT_ZERO | Number::NOT_FLOAT)) { throw new ZiboException('Invalid date provided'); } $this->dateLastModified = $timestamp; $this->headers->setHeader(Header::HEADER_LAST_MODIFIED, Header::parseTime($timestamp)); }