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