Documentation

PromiseCore
in package

Shared promises core.

Tags
license

http://opensource.org/licenses/MIT MIT

author

Михаил Красильников m.krasilnikov@yandex.ru

Table of Contents

Properties

$exception  : Exception|null
Exception.
$handle  : resource
cURL handle.
$onFulfilled  : array<string|int, callable>
Functions to call when a response will be available.
$onRejected  : array<string|int, callable>
Functions to call when an error happens.
$request  : RequestInterface
HTTP request.
$responseBuilder  : ResponseBuilder
Response builder.
$state  : string
Promise state.

Methods

__construct()  : mixed
Create shared core.
addOnFulfilled()  : void
Add on fulfilled callback.
addOnRejected()  : void
Add on rejected callback.
fulfill()  : void
Fulfill promise.
getException()  : Throwable
Get the reason why the promise was rejected.
getHandle()  : resource|CurlHandle
Return cURL handle.
getRequest()  : RequestInterface
Return request.
getResponse()  : ResponseInterface
Return the value of the promise (fulfilled).
getState()  : string
Get the state of the promise, one of PENDING, FULFILLED or REJECTED.
reject()  : void
Reject promise.

Properties

$onFulfilled

Functions to call when a response will be available.

private array<string|int, callable> $onFulfilled = []

$onRejected

Functions to call when an error happens.

private array<string|int, callable> $onRejected = []

Methods

__construct()

Create shared core.

public __construct(RequestInterface $request, resource|CurlHandle $handle, ResponseBuilder $responseBuilder) : mixed
Parameters
$request : RequestInterface

HTTP request.

$handle : resource|CurlHandle

cURL handle.

$responseBuilder : ResponseBuilder

Response builder.

Tags
throws
InvalidArgumentException

If $handle is not a cURL resource.

addOnFulfilled()

Add on fulfilled callback.

public addOnFulfilled(callable $callback) : void
Parameters
$callback : callable

addOnRejected()

Add on rejected callback.

public addOnRejected(callable $callback) : void
Parameters
$callback : callable

getException()

Get the reason why the promise was rejected.

public getException() : Throwable

If the exception is an instance of Http\Client\Exception\HttpException it will contain the response object with the status code and the http reason.

Tags
throws
LogicException

When the promise is not rejected

Return values
Throwable

Exception Object only when the Promise is rejected

getHandle()

Return cURL handle.

public getHandle() : resource|CurlHandle
Return values
resource|CurlHandle

getState()

Get the state of the promise, one of PENDING, FULFILLED or REJECTED.

public getState() : string
Return values
string

        
On this page

Search results