class Client

Methods

__construct($destination, null|string|ResponseHandler $responseHandler = null)

Client constructor

$this
addHeaders(array $headers)

Add Http headers to the request

$this|mixed
delete(string $page, array|string $data = array())

A DELETE request

$this|mixed
get(string $page, array|string $data = array(), string $body = '')

A GET request

$this|mixed
head(string $page)

A HEAD request

insecure($isInsecure = true)

No description

$this
onAny(mixed $callback)

Register a callback (or anything but null) for any request result - acts as a catch-all for missing handlers

$this
onError(mixed $callback)

Register a callback (or anything but null) for an errored response

$this
onFailure(mixed $callback)

Register a callback (or anything but null) for a failed response

$this
onSuccess(mixed $callback)

Register a callback (or anything but null) for a successful response

$this|mixed
options(string $page)

An OPTIONS request

$this|mixed
patch(string $page, array|string $data = array(), array $files = array())

A PATCH request

$this|mixed
post(string $page, array|string $data = array(), array $files = array())

A POST request

$this|mixed
put(string $page, array|string $data = array(), array $files = array())

A PUT request

$this
resetHandlersAfterRequest($reset)

Set the resetHandlers property

$this
saveCall($cliCall)

Save the cliCall into the provided variable

$this
saveRawResponse($rawResponse)

Save the raw response into the provided variable

$this
saveResponseCode($code)

Save the Http code into the provided variable

$this
saveResponseHandler(ResponseHandler $responseHandler)

Save the response handler into the provided variable

$this
saveResponseHeaders($responseHeaders)

Save the response headers into the provided variable

$this
setDestination($destination)

Set the destination

$this
setHeaders(array $headers)

Set the Http headers for the request

$this
setMultipart(bool $multipart = true)

Set whether POST data is multipart/form-data

$this
setResponseHandler(null|string|ResponseHandler $responseHandler = null)

Set the response handler

$this
setUserAgent($userAgent)

Set the user agent string for all requests

$this|mixed
trace(string $page, array|string $data = array(), array $files = array())

A TRACE request

Details

at line line 78
__construct($destination, null|string|ResponseHandler $responseHandler = null)

Client constructor

The scheme for the destination defaults to https:// if it is not provided

Parameters

$destination
null|string|ResponseHandler $responseHandler

Exceptions

DiplomaticException

at line line 93
$this addHeaders(array $headers)

Add Http headers to the request

Parameters

array $headers

Return Value

$this

at line line 109
$this|mixed delete(string $page, array|string $data = array())

A DELETE request

Parameters

string $page
array|string $data

Return Value

$this|mixed

at line line 128
$this|mixed get(string $page, array|string $data = array(), string $body = '')

A GET request

To send query string parameters, $data must be an associative array. To send only a body, $data can be a string, and the $body argument will be ignored. Of course, to use both, send an array and a string.

Parameters

string $page
array|string $data
string $body

Return Value

$this|mixed

at line line 147
$this|mixed head(string $page)

A HEAD request

Parameters

string $page

Return Value

$this|mixed

at line line 152
insecure($isInsecure = true)

Parameters

$isInsecure

at line line 169
$this onAny(mixed $callback)

Register a callback (or anything but null) for any request result - acts as a catch-all for missing handlers

The callback will receive the response handler as the first argument. Optional extra arguments may be passed here that will also be provided to the callback when invoked.

Parameters

mixed $callback

Return Value

$this

at line line 189
$this onError(mixed $callback)

Register a callback (or anything but null) for an errored response

The callback will receive the response handler as the first argument. Optional extra arguments may be passed here that will also be provided to the callback when invoked.

Parameters

mixed $callback

Return Value

$this

at line line 209
$this onFailure(mixed $callback)

Register a callback (or anything but null) for a failed response

The callback will receive the response handler as the first argument. Optional extra arguments may be passed here that will also be provided to the callback when invoked.

Parameters

mixed $callback

Return Value

$this

at line line 229
$this onSuccess(mixed $callback)

Register a callback (or anything but null) for a successful response

The callback will receive the response handler as the first argument Optional extra arguments may be passed here that will also be provided to the callback when invoked.

Parameters

mixed $callback

Return Value

$this

at line line 246
$this|mixed options(string $page)

An OPTIONS request

Parameters

string $page

Return Value

$this|mixed

at line line 261
$this|mixed patch(string $page, array|string $data = array(), array $files = array())

A PATCH request

Parameters

string $page
array|string $data
array $files

Return Value

$this|mixed

at line line 276
$this|mixed post(string $page, array|string $data = array(), array $files = array())

A POST request

Parameters

string $page
array|string $data
array $files

Return Value

$this|mixed

at line line 291
$this|mixed put(string $page, array|string $data = array(), array $files = array())

A PUT request

Parameters

string $page
array|string $data
array $files

Return Value

$this|mixed

at line line 304
$this resetHandlersAfterRequest($reset)

Set the resetHandlers property

Parameters

$reset

Return Value

$this

at line line 318
$this saveCall($cliCall)

Save the cliCall into the provided variable

Parameters

$cliCall

Return Value

$this

at line line 330
$this saveRawResponse($rawResponse)

Save the raw response into the provided variable

Parameters

$rawResponse

Return Value

$this

at line line 344
$this saveResponseCode($code)

Save the Http code into the provided variable

Parameters

$code

Return Value

$this

at line line 358
$this saveResponseHandler(ResponseHandler $responseHandler)

Save the response handler into the provided variable

Parameters

ResponseHandler $responseHandler

Return Value

$this

at line line 371
$this saveResponseHeaders($responseHeaders)

Save the response headers into the provided variable

Parameters

$responseHeaders

Return Value

$this

at line line 387
$this setDestination($destination)

Set the destination

Parameters

$destination

Return Value

$this

Exceptions

DiplomaticException

at line line 410
$this setHeaders(array $headers)

Set the Http headers for the request

Parameters

array $headers

Return Value

$this

at line line 422
$this setMultipart(bool $multipart = true)

Set whether POST data is multipart/form-data

Parameters

bool $multipart

Return Value

$this

at line line 436
$this setResponseHandler(null|string|ResponseHandler $responseHandler = null)

Set the response handler

Parameters

null|string|ResponseHandler $responseHandler

Return Value

$this

Exceptions

DiplomaticException

at line line 460
$this setUserAgent($userAgent)

Set the user agent string for all requests

Parameters

$userAgent

Return Value

$this

at line line 476
$this|mixed trace(string $page, array|string $data = array(), array $files = array())

A TRACE request

Parameters

string $page
array|string $data
array $files

Return Value

$this|mixed