YoastSEO_Vendor\GuzzleHttp\Promise
promise_for() Yoast 1.0
Creates a promise for a value if the value is not a promise.
Хуков нет.
Возвращает
PromiseInterface.
Использование
promise_for( $value );
- $value(смешанный) (обязательный)
- Promise or value.
Код promise_for() promise for Yoast 15.6.2
function promise_for($value)
{
if ($value instanceof \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface) {
return $value;
}
// Return a Guzzle promise that shadows the given promise.
if (\method_exists($value, 'then')) {
$wfn = \method_exists($value, 'wait') ? [$value, 'wait'] : null;
$cfn = \method_exists($value, 'cancel') ? [$value, 'cancel'] : null;
$promise = new \YoastSEO_Vendor\GuzzleHttp\Promise\Promise($wfn, $cfn);
$value->then([$promise, 'resolve'], [$promise, 'reject']);
return $promise;
}
return new \YoastSEO_Vendor\GuzzleHttp\Promise\FulfilledPromise($value);
}