PHP Class Kraken\Promise\Promise

Inheritance: implements Kraken\Promise\PromiseInterface, use trait Kraken\Promise\Partial\PromiseTrait
Show file Open project: kraken-php/framework Class Usage Examples

Protected Properties

Property Type Description
$canceller callable
$currentCancellations integer
$handlers callable[]
$requiredCancellations integer
$result Kraken\Promise\PromiseInterface | null

Public Methods

Method Description
__construct ( callable $resolver = null, callable $canceller = null )
__destruct ( )
abort ( callable $onCancel )
always ( callable $onFulfilledOrRejected )
cancel ( $reason = null )
done ( callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null )
failure ( callable $onFailure )
getPromise ( )
isCancelled ( )
isFulfilled ( )
isPending ( )
isRejected ( )
reject ( $reason = null )
resolve ( $value = null )
spread ( callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null )
success ( callable $onSuccess )
then ( callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null )

Protected Methods

Method Description
getReason ( ) : Erro\Error | Exceptio\Exception | string | null Return rejection or cancellation reason for Promise.
getResult ( ) : Kraken\Promise\PromiseInterface | null Get Promise result. Returns fulfilled, rejected or cancelled Promise for settled Promises or null for pending.
getValue ( ) : mixed | null Return primitive value associated with Promise.
mutate ( callable $resolver = null ) Mutate resolver.
settle ( Kraken\Promise\PromiseInterface $promise ) : Kraken\Promise\PromiseInterface Settle Promise with another Promise.

Method Details

__construct() public method

public __construct ( callable $resolver = null, callable $canceller = null )
$resolver callable
$canceller callable

__destruct() public method

public __destruct ( )

abort() public method

public abort ( callable $onCancel )
$onCancel callable

always() public method

public always ( callable $onFulfilledOrRejected )
$onFulfilledOrRejected callable

cancel() public method

public cancel ( $reason = null )

done() public method

public done ( callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null )
$onFulfilled callable
$onRejected callable
$onCancel callable

failure() public method

public failure ( callable $onFailure )
$onFailure callable

getPromise() public method

public getPromise ( )

getReason() protected method

Return rejection or cancellation reason for Promise.
protected getReason ( ) : Erro\Error | Exceptio\Exception | string | null
return Erro\Error | Exceptio\Exception | string | null

getResult() protected method

Get Promise result. Returns fulfilled, rejected or cancelled Promise for settled Promises or null for pending.
protected getResult ( ) : Kraken\Promise\PromiseInterface | null
return Kraken\Promise\PromiseInterface | null

getValue() protected method

Return primitive value associated with Promise.
protected getValue ( ) : mixed | null
return mixed | null

isCancelled() public method

public isCancelled ( )

isFulfilled() public method

public isFulfilled ( )

isPending() public method

public isPending ( )

isRejected() public method

public isRejected ( )

mutate() protected method

Mutate resolver.
protected mutate ( callable $resolver = null )
$resolver callable

reject() public method

public reject ( $reason = null )

resolve() public method

public resolve ( $value = null )

settle() protected method

Settle Promise with another Promise.
See also: PromiseInterface::resolve
See also: PromiseInterface::reject
See also: PromiseInterface::cancel
protected settle ( Kraken\Promise\PromiseInterface $promise ) : Kraken\Promise\PromiseInterface
$promise Kraken\Promise\PromiseInterface
return Kraken\Promise\PromiseInterface

spread() public method

public spread ( callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null )
$onFulfilled callable
$onRejected callable
$onCancel callable

success() public method

public success ( callable $onSuccess )
$onSuccess callable

then() public method

public then ( callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null )
$onFulfilled callable
$onRejected callable
$onCancel callable

Property Details

$canceller protected property

protected callable $canceller
return callable

$currentCancellations protected property

protected int $currentCancellations
return integer

$handlers protected property

protected callable[] $handlers
return callable[]

$requiredCancellations protected property

protected int $requiredCancellations
return integer

$result protected property

protected PromiseInterface,Kraken\Promise|null $result
return Kraken\Promise\PromiseInterface | null