Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

HttpFulfilledPromise.php

Namespace

Http\Client\Promise

File

vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php

View source
<?php

namespace Http\Client\Promise;

use Http\Client\Exception;
use Http\Promise\Promise;
use Psr\Http\Message\ResponseInterface;
final class HttpFulfilledPromise implements Promise {
    
    /**
     * @var ResponseInterface
     */
    private $response;
    public function __construct(ResponseInterface $response) {
        $this->response = $response;
    }
    public function then(?callable $onFulfilled = null, ?callable $onRejected = null) {
        if (null === $onFulfilled) {
            return $this;
        }
        try {
            return new self($onFulfilled($this->response));
        } catch (Exception $e) {
            return new HttpRejectedPromise($e);
        }
    }
    public function getState() {
        return Promise::FULFILLED;
    }
    public function wait($unwrap = true) {
        if ($unwrap) {
            return $this->response;
        }
    }

}

Classes

Title Deprecated Summary
HttpFulfilledPromise

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal