Files
juipphp/vendor/guzzlehttp/promises/src/Is.php

47 lines
999 B
PHP
Raw Normal View History

2024-03-02 18:14:13 +08:00
<?php
namespace GuzzleHttp\Promise;
final class Is
{
/**
* Returns true if a promise is pending.
2024-05-28 17:04:50 +08:00
*
* @return bool
2024-03-02 18:14:13 +08:00
*/
2024-05-28 17:04:50 +08:00
public static function pending(PromiseInterface $promise)
2024-03-02 18:14:13 +08:00
{
return $promise->getState() === PromiseInterface::PENDING;
}
/**
* Returns true if a promise is fulfilled or rejected.
2024-05-28 17:04:50 +08:00
*
* @return bool
2024-03-02 18:14:13 +08:00
*/
2024-05-28 17:04:50 +08:00
public static function settled(PromiseInterface $promise)
2024-03-02 18:14:13 +08:00
{
return $promise->getState() !== PromiseInterface::PENDING;
}
/**
* Returns true if a promise is fulfilled.
2024-05-28 17:04:50 +08:00
*
* @return bool
2024-03-02 18:14:13 +08:00
*/
2024-05-28 17:04:50 +08:00
public static function fulfilled(PromiseInterface $promise)
2024-03-02 18:14:13 +08:00
{
return $promise->getState() === PromiseInterface::FULFILLED;
}
/**
* Returns true if a promise is rejected.
2024-05-28 17:04:50 +08:00
*
* @return bool
2024-03-02 18:14:13 +08:00
*/
2024-05-28 17:04:50 +08:00
public static function rejected(PromiseInterface $promise)
2024-03-02 18:14:13 +08:00
{
return $promise->getState() === PromiseInterface::REJECTED;
}
}