CacheControl
extends Header
in package
Provides helpful functionality for Cache-Control headers
Table of Contents
Properties
- $directives : array<string|int, mixed>
- $glue : mixed
- $header : mixed
- $values : mixed
Methods
- __construct() : mixed
- __toString() : string
- Convert the header to a string
- add() : self
- Add a value to the list of header values
- addDirective() : self
- Add a cache control directive
- count() : mixed
- getDirective() : string|bool|null
- Get a specific cache control directive
- getDirectives() : array<string|int, mixed>
- Get an associative array of cache control directives
- getGlue() : string
- Get the glue used to implode multiple values into a string
- getIterator() : mixed
- getName() : string
- Get the name of the header
- hasDirective() : bool
- Check if a specific cache control directive exists
- hasExactHeader() : mixed
- hasValue() : bool
- Check if the collection of headers has a particular value
- normalize() : self
- Normalize the header to be a single header with an array of values.
- parseParams() : array<string|int, mixed>
- Parse a header containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.
- raw() : mixed
- removeDirective() : self
- Remove a cache control directive by name
- removeValue() : self
- Remove a specific value from the header
- setGlue() : self
- Change the glue used to implode the values
- setName() : self
- Change the name of the header
- toArray() : array<string|int, mixed>
- Get the array representation of an object
- trimHeader() : string
- Trim a header by removing excess spaces and wrapping quotes
- updateFromDirectives() : mixed
- Updates the header value based on the parsed directives
Properties
$directives
protected
array<string|int, mixed>
$directives
$glue
protected
mixed
$glue
$header
protected
mixed
$header
$values
protected
mixed
$values
= array()
Methods
__construct()
public
__construct(string $header[, array<string|int, mixed>|string $values = array() ][, string $glue = ',' ]) : mixed
Parameters
- $header : string
-
Name of the header
- $values : array<string|int, mixed>|string = array()
-
Values of the header as an array or a scalar
- $glue : string = ','
-
Glue used to combine multiple values into a string
__toString()
Convert the header to a string
public
__toString() : string
Return values
stringadd()
Add a value to the list of header values
public
add(mixed $value) : self
Parameters
- $value : mixed
-
Value to add to the header
Return values
selfaddDirective()
Add a cache control directive
public
addDirective(string $param, string $value) : self
Parameters
- $param : string
-
Directive to add
- $value : string
-
Value to set
Return values
selfcount()
public
count() : mixed
Attributes
- #[ReturnTypeWillChange]
getDirective()
Get a specific cache control directive
public
getDirective(string $param) : string|bool|null
Parameters
- $param : string
-
Directive to retrieve
Return values
string|bool|nullgetDirectives()
Get an associative array of cache control directives
public
getDirectives() : array<string|int, mixed>
Return values
array<string|int, mixed>getGlue()
Get the glue used to implode multiple values into a string
public
getGlue() : string
Return values
stringgetIterator()
public
getIterator() : mixed
Attributes
- #[ReturnTypeWillChange]
getName()
Get the name of the header
public
getName() : string
Return values
stringhasDirective()
Check if a specific cache control directive exists
public
hasDirective(string $param) : bool
Parameters
- $param : string
-
Directive to retrieve
Return values
boolhasExactHeader()
public
hasExactHeader(mixed $header) : mixed
Parameters
- $header : mixed
Tags
hasValue()
Check if the collection of headers has a particular value
public
hasValue(mixed $searchValue) : bool
Parameters
- $searchValue : mixed
-
Value to search for
Return values
boolnormalize()
Normalize the header to be a single header with an array of values.
public
normalize() : self
If any values of the header contains the glue string value (e.g. ","), then the value will be exploded into multiple entries in the header.
Return values
selfparseParams()
Parse a header containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.
public
parseParams() : array<string|int, mixed>
Return values
array<string|int, mixed>raw()
public
raw() : mixed
Tags
removeDirective()
Remove a cache control directive by name
public
removeDirective(string $param) : self
Parameters
- $param : string
-
Directive to remove
Return values
selfremoveValue()
Remove a specific value from the header
public
removeValue(mixed $searchValue) : self
Parameters
- $searchValue : mixed
-
Value to remove
Return values
selfsetGlue()
Change the glue used to implode the values
public
setGlue(mixed $glue) : self
Parameters
- $glue : mixed
-
Glue used to implode multiple values
Return values
selfsetName()
Change the name of the header
public
setName(mixed $name) : self
Parameters
- $name : mixed
-
Name to change to
Return values
selftoArray()
Get the array representation of an object
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>trimHeader()
Trim a header by removing excess spaces and wrapping quotes
protected
trimHeader(mixed $str) : string
Parameters
- $str : mixed
Return values
stringupdateFromDirectives()
Updates the header value based on the parsed directives
protected
updateFromDirectives(array<string|int, mixed> $directives) : mixed
Parameters
- $directives : array<string|int, mixed>
-
Array of cache control directives