Total Complexity | 4 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class ResourceResponse |
||
10 | { |
||
11 | private $resource; |
||
12 | private $statusCode; |
||
13 | private $headers; |
||
14 | |||
15 | 4 | public function __construct(object $resource, int $statusCode = Response::HTTP_OK, array $headers = []) |
|
16 | { |
||
17 | 4 | $this->resource = $resource; |
|
18 | 4 | $this->statusCode = $statusCode; |
|
19 | 4 | $this->headers = $headers; |
|
20 | 4 | } |
|
21 | |||
22 | /** |
||
23 | * Returns the resource to be send in the response. |
||
24 | * |
||
25 | * @return object |
||
26 | */ |
||
27 | 2 | public function getResource(): object |
|
28 | { |
||
29 | 2 | return $this->resource; |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * Returns the status code to be returned for the request given. |
||
34 | * |
||
35 | * @return int |
||
36 | */ |
||
37 | 3 | public function getStatusCode(): int |
|
38 | { |
||
39 | 3 | return $this->statusCode; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * Returns any additional headers to be send for the request. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | 3 | public function getHeaders(): array |
|
50 | } |
||
51 | } |
||
52 |