[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/laminas/laminas-diactoros/src/Response/ -> EmptyResponse.php (source)

   1  <?php
   2  
   3  /**
   4   * @see       https://github.com/laminas/laminas-diactoros for the canonical source repository
   5   * @copyright https://github.com/laminas/laminas-diactoros/blob/master/COPYRIGHT.md
   6   * @license   https://github.com/laminas/laminas-diactoros/blob/master/LICENSE.md New BSD License
   7   */
   8  
   9  declare(strict_types=1);
  10  
  11  namespace Laminas\Diactoros\Response;
  12  
  13  use Laminas\Diactoros\Response;
  14  use Laminas\Diactoros\Stream;
  15  
  16  /**
  17   * A class representing empty HTTP responses.
  18   */
  19  class EmptyResponse extends Response
  20  {
  21      /**
  22       * Create an empty response with the given status code.
  23       *
  24       * @param int $status Status code for the response, if any.
  25       * @param array $headers Headers for the response, if any.
  26       */
  27      public function __construct(int $status = 204, array $headers = [])
  28      {
  29          $body = new Stream('php://temp', 'r');
  30          parent::__construct($body, $status, $headers);
  31      }
  32  
  33      /**
  34       * Create an empty response with the given headers.
  35       *
  36       * @param array $headers Headers for the response.
  37       * @return EmptyResponse
  38       */
  39      public static function withHeaders(array $headers) : EmptyResponse
  40      {
  41          return new static(204, $headers);
  42      }
  43  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer