Documentation

Link extends Header
in package

Provides helpful functionality for link headers

Table of Contents

Properties

$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
addLink()  : self
Add a link to the header
count()  : mixed
getGlue()  : string
Get the glue used to implode multiple values into a string
getIterator()  : mixed
getLink()  : array<string|int, mixed>|null
Get a specific link for a given rel attribute
getLinks()  : array<string|int, mixed>
Get an associative array of links
getName()  : string
Get the name of the header
hasExactHeader()  : mixed
hasLink()  : bool
Check if a specific link exists for a given rel attribute
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
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

Properties

$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
string

add()

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
self

Add a link to the header

public addLink(string $url, string $rel[, array<string|int, mixed> $params = array() ]) : self
Parameters
$url : string

Link URL

$rel : string

Link rel

$params : array<string|int, mixed> = array()

Other link parameters

Return values
self

count()

public count() : mixed
Attributes
#[ReturnTypeWillChange]

getGlue()

Get the glue used to implode multiple values into a string

public getGlue() : string
Return values
string

getIterator()

public getIterator() : mixed
Attributes
#[ReturnTypeWillChange]

Get a specific link for a given rel attribute

public getLink(string $rel) : array<string|int, mixed>|null
Parameters
$rel : string

Rel value

Return values
array<string|int, mixed>|null

Get an associative array of links

public getLinks() : array<string|int, mixed>

For example: Link: http:/.../front.jpeg; rel=front; type="image/jpeg", http://.../back.jpeg; rel=back; type="image/jpeg"

var_export($response->getLinks()); array( array( 'url' => 'http:/.../front.jpeg', 'rel' => 'back', 'type' => 'image/jpeg', ) )
Return values
array<string|int, mixed>

getName()

Get the name of the header

public getName() : string
Return values
string

hasExactHeader()

public hasExactHeader(mixed $header) : mixed
Parameters
$header : mixed
Tags
codeCoverageIgnore

Check if a specific link exists for a given rel attribute

public hasLink(string $rel) : bool
Parameters
$rel : string

rel value

Return values
bool

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
bool

normalize()

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
self

parseParams()

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
codeCoverageIgnore

removeValue()

Remove a specific value from the header

public removeValue(mixed $searchValue) : self
Parameters
$searchValue : mixed

Value to remove

Return values
self

setGlue()

Change the glue used to implode the values

public setGlue(mixed $glue) : self
Parameters
$glue : mixed

Glue used to implode multiple values

Return values
self

setName()

Change the name of the header

public setName(mixed $name) : self
Parameters
$name : mixed

Name to change to

Return values
self

toArray()

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
string

        
On this page

Search results