for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace IQParts\Content\Object;
final class CacheControl
{
public const MUST_REVALIDATE = 0;
public const NO_TRANSFORM = 1;
public const NO_CACHE = 2;
public const NO_STORE = 3;
public const PUBLIC = 4;
public const PRIVATE = 5;
public const PROXY = 6;
public const MAX_AGE = 7;
public const S_MAX_AGE = 8;
/**
* @var array
*/
private $modes = [
'must-revalidate',
'no-transform',
'no-cache',
'no-store',
'public',
'private',
'proxy-revalidate',
'max-age',
's-max-age'
];
* @var int
private $mode;
private $seconds;
* CacheControl constructor.
* @param int $mode
* @param int $seconds
public function __construct(int $mode, int $seconds = -1)
if ($mode < 0 || $mode > 7) {
throw new \InvalidArgumentException('Invalid mode.');
}
if ($mode >= 7 && $seconds < 0) {
throw new \InvalidArgumentException('Invalid number of seconds.');
$this->mode = $mode;
$this->seconds = $seconds;
* @return int|string
public function __toString()
$mode = $this->modes[$this->mode];
if ($this->mode >= 7) {
return $mode . '=' . (string)$this->seconds;
return $mode;