Is.php 941 B

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