public function setCacheControlDirective($name, $value = null)
{
switch ($name) {
case 'public':
$this->cacheDirectives['visibility'] = 'public';
break;
case 'private':
case 'no-cache':
$this->cacheDirectives['visibility'] = $name . (!empty($value) ? '="' . $value . '"' : '');
break;
case 'no-store':
case 'no-transform':
case 'must-revalidate':
case 'proxy-revalidate':
$this->cacheDirectives[$name] = $name;
break;
case 'max-age':
case 's-maxage':
$this->cacheDirectives[$name] = $name . '=' . $value;
break;
}
}
/** * @dataProvider cacheDirectivesAndExampleValues * @test */ public function getCacheControlDirectiveReturnsTheSpecifiedDirectiveValueIfPresent($name, $value) { $headers = new Headers(); $this->assertNull($headers->getCacheControlDirective($name)); if ($value === true) { $headers->setCacheControlDirective($name); } else { $headers->setCacheControlDirective($name, $value); } $this->assertEquals($value, $headers->getCacheControlDirective($name)); }