vendor/guzzlehttp/guzzle/src/ClientTrait.php line 93

Open in your IDE?
  1. <?php
  2. namespace GuzzleHttp;
  3. use GuzzleHttp\Exception\GuzzleException;
  4. use GuzzleHttp\Promise\PromiseInterface;
  5. use Psr\Http\Message\ResponseInterface;
  6. use Psr\Http\Message\UriInterface;
  7. /**
  8.  * Client interface for sending HTTP requests.
  9.  */
  10. trait ClientTrait
  11. {
  12.     /**
  13.      * Create and send an HTTP request.
  14.      *
  15.      * Use an absolute path to override the base path of the client, or a
  16.      * relative path to append to the base path of the client. The URL can
  17.      * contain the query string as well.
  18.      *
  19.      * @param string              $method  HTTP method.
  20.      * @param string|UriInterface $uri     URI object or string.
  21.      * @param array               $options Request options to apply.
  22.      *
  23.      * @throws GuzzleException
  24.      */
  25.     abstract public function request(string $method$uri, array $options = []): ResponseInterface;
  26.     /**
  27.      * Create and send an HTTP GET request.
  28.      *
  29.      * Use an absolute path to override the base path of the client, or a
  30.      * relative path to append to the base path of the client. The URL can
  31.      * contain the query string as well.
  32.      *
  33.      * @param string|UriInterface $uri     URI object or string.
  34.      * @param array               $options Request options to apply.
  35.      *
  36.      * @throws GuzzleException
  37.      */
  38.     public function get($uri, array $options = []): ResponseInterface
  39.     {
  40.         return $this->request('GET'$uri$options);
  41.     }
  42.     /**
  43.      * Create and send an HTTP HEAD request.
  44.      *
  45.      * Use an absolute path to override the base path of the client, or a
  46.      * relative path to append to the base path of the client. The URL can
  47.      * contain the query string as well.
  48.      *
  49.      * @param string|UriInterface $uri     URI object or string.
  50.      * @param array               $options Request options to apply.
  51.      *
  52.      * @throws GuzzleException
  53.      */
  54.     public function head($uri, array $options = []): ResponseInterface
  55.     {
  56.         return $this->request('HEAD'$uri$options);
  57.     }
  58.     /**
  59.      * Create and send an HTTP PUT request.
  60.      *
  61.      * Use an absolute path to override the base path of the client, or a
  62.      * relative path to append to the base path of the client. The URL can
  63.      * contain the query string as well.
  64.      *
  65.      * @param string|UriInterface $uri     URI object or string.
  66.      * @param array               $options Request options to apply.
  67.      *
  68.      * @throws GuzzleException
  69.      */
  70.     public function put($uri, array $options = []): ResponseInterface
  71.     {
  72.         return $this->request('PUT'$uri$options);
  73.     }
  74.     /**
  75.      * Create and send an HTTP POST request.
  76.      *
  77.      * Use an absolute path to override the base path of the client, or a
  78.      * relative path to append to the base path of the client. The URL can
  79.      * contain the query string as well.
  80.      *
  81.      * @param string|UriInterface $uri     URI object or string.
  82.      * @param array               $options Request options to apply.
  83.      *
  84.      * @throws GuzzleException
  85.      */
  86.     public function post($uri, array $options = []): ResponseInterface
  87.     {
  88.         return $this->request('POST'$uri$options);
  89.     }
  90.     /**
  91.      * Create and send an HTTP PATCH request.
  92.      *
  93.      * Use an absolute path to override the base path of the client, or a
  94.      * relative path to append to the base path of the client. The URL can
  95.      * contain the query string as well.
  96.      *
  97.      * @param string|UriInterface $uri     URI object or string.
  98.      * @param array               $options Request options to apply.
  99.      *
  100.      * @throws GuzzleException
  101.      */
  102.     public function patch($uri, array $options = []): ResponseInterface
  103.     {
  104.         return $this->request('PATCH'$uri$options);
  105.     }
  106.     /**
  107.      * Create and send an HTTP DELETE request.
  108.      *
  109.      * Use an absolute path to override the base path of the client, or a
  110.      * relative path to append to the base path of the client. The URL can
  111.      * contain the query string as well.
  112.      *
  113.      * @param string|UriInterface $uri     URI object or string.
  114.      * @param array               $options Request options to apply.
  115.      *
  116.      * @throws GuzzleException
  117.      */
  118.     public function delete($uri, array $options = []): ResponseInterface
  119.     {
  120.         return $this->request('DELETE'$uri$options);
  121.     }
  122.     /**
  123.      * Create and send an asynchronous HTTP request.
  124.      *
  125.      * Use an absolute path to override the base path of the client, or a
  126.      * relative path to append to the base path of the client. The URL can
  127.      * contain the query string as well. Use an array to provide a URL
  128.      * template and additional variables to use in the URL template expansion.
  129.      *
  130.      * @param string              $method  HTTP method
  131.      * @param string|UriInterface $uri     URI object or string.
  132.      * @param array               $options Request options to apply.
  133.      */
  134.     abstract public function requestAsync(string $method$uri, array $options = []): PromiseInterface;
  135.     /**
  136.      * Create and send an asynchronous HTTP GET request.
  137.      *
  138.      * Use an absolute path to override the base path of the client, or a
  139.      * relative path to append to the base path of the client. The URL can
  140.      * contain the query string as well. Use an array to provide a URL
  141.      * template and additional variables to use in the URL template expansion.
  142.      *
  143.      * @param string|UriInterface $uri     URI object or string.
  144.      * @param array               $options Request options to apply.
  145.      */
  146.     public function getAsync($uri, array $options = []): PromiseInterface
  147.     {
  148.         return $this->requestAsync('GET'$uri$options);
  149.     }
  150.     /**
  151.      * Create and send an asynchronous HTTP HEAD request.
  152.      *
  153.      * Use an absolute path to override the base path of the client, or a
  154.      * relative path to append to the base path of the client. The URL can
  155.      * contain the query string as well. Use an array to provide a URL
  156.      * template and additional variables to use in the URL template expansion.
  157.      *
  158.      * @param string|UriInterface $uri     URI object or string.
  159.      * @param array               $options Request options to apply.
  160.      */
  161.     public function headAsync($uri, array $options = []): PromiseInterface
  162.     {
  163.         return $this->requestAsync('HEAD'$uri$options);
  164.     }
  165.     /**
  166.      * Create and send an asynchronous HTTP PUT request.
  167.      *
  168.      * Use an absolute path to override the base path of the client, or a
  169.      * relative path to append to the base path of the client. The URL can
  170.      * contain the query string as well. Use an array to provide a URL
  171.      * template and additional variables to use in the URL template expansion.
  172.      *
  173.      * @param string|UriInterface $uri     URI object or string.
  174.      * @param array               $options Request options to apply.
  175.      */
  176.     public function putAsync($uri, array $options = []): PromiseInterface
  177.     {
  178.         return $this->requestAsync('PUT'$uri$options);
  179.     }
  180.     /**
  181.      * Create and send an asynchronous HTTP POST request.
  182.      *
  183.      * Use an absolute path to override the base path of the client, or a
  184.      * relative path to append to the base path of the client. The URL can
  185.      * contain the query string as well. Use an array to provide a URL
  186.      * template and additional variables to use in the URL template expansion.
  187.      *
  188.      * @param string|UriInterface $uri     URI object or string.
  189.      * @param array               $options Request options to apply.
  190.      */
  191.     public function postAsync($uri, array $options = []): PromiseInterface
  192.     {
  193.         return $this->requestAsync('POST'$uri$options);
  194.     }
  195.     /**
  196.      * Create and send an asynchronous HTTP PATCH request.
  197.      *
  198.      * Use an absolute path to override the base path of the client, or a
  199.      * relative path to append to the base path of the client. The URL can
  200.      * contain the query string as well. Use an array to provide a URL
  201.      * template and additional variables to use in the URL template expansion.
  202.      *
  203.      * @param string|UriInterface $uri     URI object or string.
  204.      * @param array               $options Request options to apply.
  205.      */
  206.     public function patchAsync($uri, array $options = []): PromiseInterface
  207.     {
  208.         return $this->requestAsync('PATCH'$uri$options);
  209.     }
  210.     /**
  211.      * Create and send an asynchronous HTTP DELETE request.
  212.      *
  213.      * Use an absolute path to override the base path of the client, or a
  214.      * relative path to append to the base path of the client. The URL can
  215.      * contain the query string as well. Use an array to provide a URL
  216.      * template and additional variables to use in the URL template expansion.
  217.      *
  218.      * @param string|UriInterface $uri     URI object or string.
  219.      * @param array               $options Request options to apply.
  220.      */
  221.     public function deleteAsync($uri, array $options = []): PromiseInterface
  222.     {
  223.         return $this->requestAsync('DELETE'$uri$options);
  224.     }
  225. }