Total Complexity | 5 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class Response extends AbstractMessage implements ResponseInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var int The response code. |
||
20 | */ |
||
21 | protected $statusCode; |
||
22 | |||
23 | /** |
||
24 | * Constructs an HTTP response. |
||
25 | * |
||
26 | * @param int $code The status code. |
||
27 | * @param string $protocolVersion The HTTP version. |
||
28 | * @param StreamInterface $body The response body. |
||
29 | * @param array $headers The response headers. |
||
30 | */ |
||
31 | public function __construct(int $code, string $protocolVersion, StreamInterface $body, array $headers) |
||
32 | { |
||
33 | parent::__construct($protocolVersion, $body, $headers); |
||
34 | $this->setStatusCode($code); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @inheritDoc |
||
39 | */ |
||
40 | public function getStatusCode() |
||
41 | { |
||
42 | return $this->statusCode; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Sets the status code. |
||
47 | * |
||
48 | * @param int $code The status code. |
||
49 | * @return $this |
||
50 | */ |
||
51 | protected function setStatusCode(int $code): self |
||
52 | { |
||
53 | $this->statusCode = $code; |
||
54 | return $this; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @inheritDoc |
||
59 | */ |
||
60 | public function withStatus($code, $reasonPhrase = '') |
||
61 | { |
||
62 | return (clone $this)->setStatusCode($code); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @inheritDoc |
||
67 | */ |
||
68 | public function getReasonPhrase() |
||
71 | } |
||
72 | } |
||
73 |