vendor/guzzlehttp/promises/src/State.php

44 lines · 1000 bytes

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