1 | <?php |
||
12 | class ResponseFactory implements ResponseFactoryContract |
||
13 | { |
||
14 | /** |
||
15 | * @param string $content |
||
16 | * @param int $status |
||
17 | * @param array $headers |
||
18 | * |
||
19 | * @return ResponseContract |
||
20 | */ |
||
21 | 6 | public function html(string $content = null, int $status = 200, array $headers = []) |
|
22 | { |
||
23 | 6 | if ($content === null || $content == '') { |
|
24 | 1 | return $this->emptyResponse($status, $headers); |
|
25 | } |
||
26 | |||
27 | 5 | return new Response( |
|
28 | 5 | new HtmlResponse($content, $status, $headers) |
|
29 | ); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param mixed $content |
||
34 | * @param int $status |
||
35 | * @param array $headers |
||
36 | * |
||
37 | * @return ResponseContract |
||
38 | */ |
||
39 | 6 | public function make($content = '', int $status = 200, array $headers = []) |
|
51 | |||
52 | /** |
||
53 | * @param array|Arrayable $content |
||
54 | * @param int $status |
||
55 | * @param array $headers |
||
56 | * @param int $option |
||
57 | * |
||
58 | * @return ResponseContract |
||
59 | */ |
||
60 | 3 | public function json($content = [], int $status = 200, array $headers = [], int $option = 79) |
|
70 | |||
71 | /** |
||
72 | * @param $status |
||
73 | * @param $headers |
||
74 | * |
||
75 | * @return ResponseContract |
||
76 | */ |
||
77 | 1 | private function emptyResponse(int $status = 200, array $headers = []) |
|
83 | } |
||
84 |