1 | <?php |
||
14 | abstract class ResponseFactory |
||
15 | { |
||
16 | /** |
||
17 | * @var bool |
||
18 | */ |
||
19 | protected $includeStatusCode = true; |
||
20 | |||
21 | /** |
||
22 | * Constructor. |
||
23 | * |
||
24 | * @param bool $includeStatusCode |
||
25 | */ |
||
26 | public function __construct( bool $includeStatusCode ) |
||
30 | |||
31 | /** |
||
32 | * Generate a JSON response. |
||
33 | * |
||
34 | * @param array $data |
||
35 | * @param int $statusCode |
||
36 | * @return JsonResponse |
||
37 | */ |
||
38 | public function make( $data, $statusCode ):JsonResponse |
||
44 | |||
45 | /** |
||
46 | * Prepend a status code to the response data if status codes are enabled. |
||
47 | * |
||
48 | * @param int $statusCode |
||
49 | * @param array $data |
||
50 | * @return array |
||
51 | */ |
||
52 | protected function includeStatusCode( int $statusCode, array $data ):array |
||
62 | } |