Is.php 999 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace GuzzleHttp\Promise;
  3. final class Is
  4. {
  5. /**
  6. * Returns true if a promise is pending.
  7. *
  8. * @return bool
  9. */
  10. public static function pending(PromiseInterface $promise)
  11. {
  12. return $promise->getState() === PromiseInterface::PENDING;
  13. }
  14. /**
  15. * Returns true if a promise is fulfilled or rejected.
  16. *
  17. * @return bool
  18. */
  19. public static function settled(PromiseInterface $promise)
  20. {
  21. return $promise->getState() !== PromiseInterface::PENDING;
  22. }
  23. /**
  24. * Returns true if a promise is fulfilled.
  25. *
  26. * @return bool
  27. */
  28. public static function fulfilled(PromiseInterface $promise)
  29. {
  30. return $promise->getState() === PromiseInterface::FULFILLED;
  31. }
  32. /**
  33. * Returns true if a promise is rejected.
  34. *
  35. * @return bool
  36. */
  37. public static function rejected(PromiseInterface $promise)
  38. {
  39. return $promise->getState() === PromiseInterface::REJECTED;
  40. }
  41. }