1 | <?php |
||
12 | final class ResponseFactory |
||
13 | { |
||
14 | /** |
||
15 | * @var ResponseFactory |
||
16 | */ |
||
17 | private static $instance; |
||
18 | |||
19 | /** |
||
20 | * ResponseFactory constructor. |
||
21 | */ |
||
22 | private function __construct() |
||
25 | |||
26 | /** |
||
27 | * @return ResponseFactory |
||
28 | */ |
||
29 | public static function instance(): self |
||
37 | |||
38 | /** |
||
39 | * @param ResponseInterface $response |
||
40 | * |
||
41 | * @return JSendResponseInterface |
||
42 | * @throws \Seld\JsonLint\ParsingException |
||
43 | */ |
||
44 | public function convert(ResponseInterface $response): JSendResponseInterface |
||
54 | |||
55 | /** |
||
56 | * @param array|null $data |
||
57 | * |
||
58 | * @return JSendResponseInterface |
||
59 | */ |
||
60 | public function success(array $data = null): JSendResponseInterface |
||
64 | |||
65 | /** |
||
66 | * @param array|null $data |
||
67 | * |
||
68 | * @return JSendResponseInterface |
||
69 | */ |
||
70 | public function fail(array $data = null): JSendResponseInterface |
||
74 | |||
75 | /** |
||
76 | * @param array $response |
||
77 | * @param int|null $code |
||
78 | * |
||
79 | * @return JSendResponseInterface |
||
80 | */ |
||
81 | public function error(array $response, int $code = null): JSendResponseInterface |
||
89 | } |
||
90 |