47 lines
999 B
PHP
Raw Normal View History

2023-07-15 10:16:32 +08:00
<?php
namespace GuzzleHttp\Promise;
final class Is
{
/**
* Returns true if a promise is pending.
2023-07-18 11:17:17 +08:00
*
* @return bool
2023-07-15 10:16:32 +08:00
*/
2023-07-18 11:17:17 +08:00
public static function pending(PromiseInterface $promise)
2023-07-15 10:16:32 +08:00
{
return $promise->getState() === PromiseInterface::PENDING;
}
/**
* Returns true if a promise is fulfilled or rejected.
2023-07-18 11:17:17 +08:00
*
* @return bool
2023-07-15 10:16:32 +08:00
*/
2023-07-18 11:17:17 +08:00
public static function settled(PromiseInterface $promise)
2023-07-15 10:16:32 +08:00
{
return $promise->getState() !== PromiseInterface::PENDING;
}
/**
* Returns true if a promise is fulfilled.
2023-07-18 11:17:17 +08:00
*
* @return bool
2023-07-15 10:16:32 +08:00
*/
2023-07-18 11:17:17 +08:00
public static function fulfilled(PromiseInterface $promise)
2023-07-15 10:16:32 +08:00
{
return $promise->getState() === PromiseInterface::FULFILLED;
}
/**
* Returns true if a promise is rejected.
2023-07-18 11:17:17 +08:00
*
* @return bool
2023-07-15 10:16:32 +08:00
*/
2023-07-18 11:17:17 +08:00
public static function rejected(PromiseInterface $promise)
2023-07-15 10:16:32 +08:00
{
return $promise->getState() === PromiseInterface::REJECTED;
}
}