Bluz\Http\CacheControl::setEtag PHP Method

setEtag() public method

Sets the ETag value
public setEtag ( string $etag, boolean $weak = false ) : void
$etag string The ETag unique identifier
$weak boolean Whether you want a weak ETag or not
return void
    public function setEtag($etag, $weak = false)
    {
        $etag = trim($etag, '"');
        $this->response->setHeader('ETag', (true === $weak ? 'W/' : '') . '"' . $etag . '"');
    }

Usage Example

Example #1
0
 /**
  * Test Etag
  */
 public function testEtag()
 {
     $this->cacheControl->setEtag('"unique-content-id"');
     $this->assertEquals('"unique-content-id"', $this->cacheControl->getEtag());
     $this->assertEquals('"unique-content-id"', $this->response->getHeader('ETag'));
 }