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 |
||
62 | |||
63 | /** |
||
64 | * @param array|null $data |
||
65 | * |
||
66 | * @return JSendResponseInterface |
||
67 | */ |
||
68 | public function success(array $data = null): JSendResponseInterface |
||
72 | |||
73 | /** |
||
74 | * @param array|null $data |
||
75 | * |
||
76 | * @return JSendResponseInterface |
||
77 | */ |
||
78 | public function fail(array $data = null): JSendResponseInterface |
||
82 | |||
83 | /** |
||
84 | * @param array $response |
||
85 | * @param int|null $code |
||
86 | * |
||
87 | * @return JSendResponseInterface |
||
88 | */ |
||
89 | public function error(array $response, int $code = null): JSendResponseInterface |
||
97 | } |