Documentation

HeaderComparison
in package

Class used to compare HTTP headers using a custom DSL

Table of Contents

compare()  : array<string|int, mixed>|bool
Compare HTTP headers and use special markup to filter values A header prefixed with '!' means it must not exist A header prefixed with '_' means it must be ignored A header value of '*' means anything after the * will be ignored
compareArray()  : array<string|int, mixed>|bool
Check if an array of HTTP headers matches another array of HTTP headers while taking * into account as a wildcard
hasKey()  : bool
Case insensitive check if an array have a key

Methods

compare()

Compare HTTP headers and use special markup to filter values A header prefixed with '!' means it must not exist A header prefixed with '_' means it must be ignored A header value of '*' means anything after the * will be ignored

public compare(array<string|int, mixed> $filteredHeaders, array<string|int, mixed> $actualHeaders) : array<string|int, mixed>|bool
Parameters
$filteredHeaders : array<string|int, mixed>

Array of special headers

$actualHeaders : array<string|int, mixed>

Array of headers to check against

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

Returns an array of the differences or FALSE if none

compareArray()

Check if an array of HTTP headers matches another array of HTTP headers while taking * into account as a wildcard

public compareArray(array<string|int, mixed> $expected, array<string|int, mixed>|Collection $actual[, array<string|int, mixed> $ignore = array() ][, array<string|int, mixed> $absent = array() ]) : array<string|int, mixed>|bool
Parameters
$expected : array<string|int, mixed>

Expected HTTP headers (allows wildcard values)

$actual : array<string|int, mixed>|Collection

Actual HTTP header array

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

Headers to ignore from the comparison

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

Array of headers that must not be present

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

Returns an array of the differences or FALSE if none

hasKey()

Case insensitive check if an array have a key

protected hasKey(string $key, array<string|int, mixed> $array) : bool
Parameters
$key : string

Key to check

$array : array<string|int, mixed>

Array to check

Return values
bool

Search results