forked from laysense/laysense.cn
45 lines
1000 B
PHP
45 lines
1000 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace GuzzleHttp\Promise;
|
|
|
|
final class State
|
|
{
|
|
private function __construct()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Returns true if a promise is pending.
|
|
*/
|
|
public static function isPending(PromiseInterface $promise): bool
|
|
{
|
|
return $promise->getState() === PromiseInterface::PENDING;
|
|
}
|
|
|
|
/**
|
|
* Returns true if a promise is fulfilled or rejected.
|
|
*/
|
|
public static function isSettled(PromiseInterface $promise): bool
|
|
{
|
|
return $promise->getState() !== PromiseInterface::PENDING;
|
|
}
|
|
|
|
/**
|
|
* Returns true if a promise is fulfilled.
|
|
*/
|
|
public static function isFulfilled(PromiseInterface $promise): bool
|
|
{
|
|
return $promise->getState() === PromiseInterface::FULFILLED;
|
|
}
|
|
|
|
/**
|
|
* Returns true if a promise is rejected.
|
|
*/
|
|
public static function isRejected(PromiseInterface $promise): bool
|
|
{
|
|
return $promise->getState() === PromiseInterface::REJECTED;
|
|
}
|
|
}
|