Fork me on Github!
Boomerang!

Full Documentation

Application

Class: \Boomerang\Boomerang

Boomerang Application


Method: Boomerang::addValidator

function addValidator(\Boomerang\Interfaces\ValidatorInterface $validator)

Register a Validator with Boomerang

After creating an instance of a Validator, it needs to be registered with Boomerang in order for results to be
tallied and displayed.

Parameters:

Http

Class: \Boomerang\HttpRequest

Utility for generating HTTP Requests and receiving Responses into HttpResponse objects.

<?php
namespace Boomerang;

class HttpRequest {
	public const GET = "GET";
	public const POST = "POST";
	public const PUT = "PUT";
	public const PATCH = "PATCH";
	public const DELETE = "DELETE";
	public const TRACE = "TRACE";
	public const OPTIONS = "OPTIONS";
}

Method: HttpRequest->__construct

function __construct($endpoint [, \Boomerang\Factories\HttpResponseFactory $responseFactory = null])
Parameters:

Method: HttpRequest->getMethod

function getMethod()

Get the current request method.

Returns:

Method: HttpRequest->setMethod

function setMethod($method)

Set the request method.

Helper constants exist, for example
$req->setMethod(HttpRequest::POST);  
Parameters:

Method: HttpRequest->getUrlParam

function getUrlParam($param)

Retrieve a url param by name

Parameters:
Returns:

Method: HttpRequest->setUrlParam

function setUrlParam($param, $value)

Set a url param by name.

Parameters:

Method: HttpRequest->getUrlParams

function getUrlParams()

Get all url params.

Returns:

Method: HttpRequest->setUrlParams

function setUrlParams(array $params)

Set outgoing params as an array of ParamName => Value

Parameters:

Method: HttpRequest->getHeader

function getHeader($key)

Retrieve an outgoing header by name

Parameters:
Returns:

Method: HttpRequest->setHeader

function setHeader($key, $value)

Set an outgoing header by name.

Parameters:

Method: HttpRequest->getHeaders

function getHeaders()

Get all set headers.

Returns:

Method: HttpRequest->setHeaders

function setHeaders(array $headers)

Set outgoing headers as an array of HeaderName => Value

Parameters:

Method: HttpRequest->setBasicAuth

function setBasicAuth($username [, $password = ''])

Set outgoing basic auth header.

Parameters:

Method: HttpRequest->getPost

function getPost($key)

Retrieve an post value by name.

DEPRECATED

Use getFormValue instead

Parameters:
Returns:

Method: HttpRequest->setPost

function setPost($key, $value)

Set a named key of the post value

Note that this has the side effect of changing the HTTP Method to POST

DEPRECATED

Use setMethod and setFormValue instead

Parameters:

Method: HttpRequest->setFormValue

function setFormValue($key, $value)

Set a named key of the form values

Note that if there is a non-form body set, this will replace it.

Parameters:

Method: HttpRequest->getFormValue

function getFormValue($key)

Retrieve an form value by name.

Parameters:
Returns:

Method: HttpRequest->getPostData

function getPostData()

Retrieve all queued post-data as an array.

DEPRECATED

Use getBody instead

Returns:

Method: HttpRequest->setPostData

function setPostData(array $post)

Set all post data, whipping past values.

Note that this has the side effect of changing the HTTP Method to POST

DEPRECATED

Use setBody instead

Parameters:

Method: HttpRequest->getBody

function getBody()

Get the requests body

Returns:

Method: HttpRequest->setBody

function setBody($body)

Set the requests body

Parameters:

Method: HttpRequest->setCookiesFollowRedirects

function setCookiesFollowRedirects($bool)

Allows you to enable cookie’s set by server re-posting following a redirect.

Requires file system storage of a “cookie jar” file and is therefore disabled by default.

Parameters:

Method: HttpRequest->setCookies

function setCookies(array $cookies)

Set outgoing cookies as an array of CookieName => Value

Parameters:

Method: HttpRequest->setCookie

function setCookie($key, $value)

Set a named cookies outgoing value

Parameters:

Method: HttpRequest->getEndpoint

function getEndpoint()

Gets the request URI

Returns:

Method: HttpRequest->setEndpoint

function setEndpoint($endpoint)

Sets the request URI

Parameters:

Method: HttpRequest->makeRequest

function makeRequest()

Execute the request

Returns:

Method: HttpRequest->getCurlInfo

function getCurlInfo()
Returns:

Method: HttpRequest->getLastRequestTime

function getLastRequestTime()

Get the time the last request took in seconds a float

Returns:

Method: HttpRequest->getMaxRedirects

function getMaxRedirects()

Get the current maximum number of redirects(hops) a request should follow.

Returns:

Method: HttpRequest->setMaxRedirects

function setMaxRedirects($maxRedirects)

Set the maximum number of redirects(hops) a request should follow.

Parameters:

Class: \Boomerang\HttpResponse

Represents an HTTP Response.

Usually received from an HttpRequest object

Method: HttpResponse->__construct

function __construct($body, $headers [, \Boomerang\HttpRequest $request = null])
Parameters:

Method: HttpResponse->getHeader

function getHeader($header [, $hop = null])

Get a response header by name.

Parameters:
Returns:

Method: HttpResponse->getHeaders

function getHeaders([ $hop = null])

Get response headers as a HeaderName => Value array

Parameters:
Returns:

Method: HttpResponse->getAllHeaders

function getAllHeaders()

Get all response headers from all hops as a HopIndex => HeaderName => Value array.

Note: header key values are lower cased.

Returns:

Method: HttpResponse->getRawHeaders

function getRawHeaders()

Get the raw un-parsed Response header string.

Returns:

Method: HttpResponse->getBody

function getBody()

Get the body of the Response.

Returns:

Method: HttpResponse->getRequest

function getRequest()

Get the HttpRequest object that made the Response object.

Returns:

Method: HttpResponse->getHopCount

function getHopCount()

Get the number of hops(redirects) the request took

Returns:

Method: HttpResponse->getStatus

function getStatus([ $hop = null])

Get the HTTP status of a hop

Parameters:
Returns:

Validators

Class: \Boomerang\HttpResponseValidator

HTTP Validation

Used to validate expected responses, headers and HTTP statues

Method: HttpResponseValidator->__construct

function __construct(\Boomerang\Interfaces\HttpResponseInterface $response)
Parameters:

Method: HttpResponseValidator->getResponse

function getResponse()
Returns:

Method: HttpResponseValidator->expectStatus

function expectStatus([ $expected_status = 200 [, $hop = null]])

Verify that the HTTP response code is as expected.

Parameters:
Returns:

Method: HttpResponseValidator->expectHeader

function expectHeader($key, $value [, $hop = null])

Verify that a header field equals an expected value.

Parameters:
Returns:

Method: HttpResponseValidator->expectHeaderContains

function expectHeaderContains($key, $value [, $hop = null])

Verify that a header field contains an expected value.

For example, checking the header Content-Type for “json” would match a response of “application/json”

Parameters:
Returns:

Method: HttpResponseValidator->expectBody

function expectBody($expectedContent)

Verify that the content body equals an expected value.

Parameters:
Returns:

Method: HttpResponseValidator->expectBodyContains

function expectBodyContains($expectedContent)

Verify that the content body contains an expected value.

Parameters:
Returns:

Method: HttpResponseValidator->expectHopCount

function expectHopCount($expectedCount)

Verify the number of redirection hops is as expected.

Parameters:
Returns:

Class: \Boomerang\JSONValidator

JSON Validator

Used to validate JSON encoding and structure.

Method: JSONValidator->__construct

function __construct(\Boomerang\Interfaces\ResponseInterface $response)
Parameters:

Method: JSONValidator->inspectJSON

function inspectJSON()

Log the JSON response as an InfoResult in the output.

Returns:

Type Expectations

Class: \Boomerang\TypeExpectations\AllEx

All Expectation

Defines a requirement to match all structure definitions expectations.

Example:

new AllEx(
    array(1,2,3),
    function($data) { return count($data) == 3; }
);

Method: AllEx->__construct

function __construct($structure)
Parameters:

Undocumented Method: AllEx->match($data)


Undocumented Method: AllEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\AnyEx

Any Expectation

Defines a requirement to match any structure definitions expectations.

Example:

new AllEx(
    array(1,2,3),
    function($data) { return count($data) == 4; }
);

Undocumented Method: AnyEx->match($data)


Undocumented Method: AnyEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\IntEx

Integer Expectation

Defines a placeholder expectation of an integer with an optional minimum/maximum range.

Passes: int Fails: float/numeric string

Undocumented Method: IntEx->match($data)


Undocumented Method: IntEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\Iterate\IterateArrayEx

Iterating Array Expectation

Iterates over every element of an array, ensuring it is an array, and matching against passed structure expectations.

Undocumented Method: IterateArrayEx->match($data)


Undocumented Method: IterateArrayEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\Iterate\IterateObjectEx

Iterating Object Expectation

Iterates over every element of an object, ensuring it is an object, and matching against passed structure expectations.


Undocumented Method: IterateObjectEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\Iterate\IterateStructureEx

Iterating Structure (object/array) Expectation

Iterates over every element of a iterable structure (object/array), ensuring it iterable, and matching against passed structure expectations.

Undocumented Method: IterateStructureEx->match($data)


Undocumented Method: IterateStructureEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\NullEx

Null Expectation

Defines a placeholder expectation of a NULL value.

Passes: null

Undocumented Method: NullEx->match($data)


Undocumented Method: NullEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\NumberEx

Number Expectation

Defines a placeholder expectation of a “number” (int/float) with an optional minimum/maximum range.

Passes: int / float Fails: numeric string

Undocumented Method: NumberEx->match($data)


Undocumented Method: NumberEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\NumericEx

Numeric Expectation

Defines a placeholder expectation of a “numeric” (int/float/numeric string) with an optional minimum/maximum range.

See: php.net/is_numeric

Passes: numeric string / int / float

Method: NumericEx->__construct

function __construct([ $min = null [, $max = null]])
Parameters:

Undocumented Method: NumericEx->match($data)


Undocumented Method: NumericEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\NumericStringEx

Numeric String Expectation

Defines a placeholder expectation of a “numeric string” with an optional minimum/maximum range.

Passes: numeric string eg: “1.2” Fails: int / float

Undocumented Method: NumericStringEx->match($data)


Undocumented Method: NumericStringEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\RegexEx

Regex Match Expectation

Define a regex matching placeholder

Method: RegexEx->__construct

function __construct($pattern)
Parameters:

Undocumented Method: RegexEx->match($data)


Undocumented Method: RegexEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\StringEx

String Expectation

Define a string matching placeholder expectation

Method: StringEx->__construct

function __construct([ $minLength = null [, $maxLength = null]])
Parameters:

Undocumented Method: StringEx->match($data)


Undocumented Method: StringEx->getMatchingTypeName()

Class: \Boomerang\TypeExpectations\StructureEx

Structure Expectation

Used to define rules about structure.

Method: StructureEx->__construct

function __construct($structure)
Parameters:

Method: StructureEx->getValidator

function getValidator()
Returns:

Undocumented Method: StructureEx->getMatchingTypeName()