1 | <?php |
||
27 | class SuccessResponseBuilder extends ResponseBuilder |
||
28 | { |
||
29 | /** |
||
30 | * A builder for building transformed arrays. |
||
31 | * |
||
32 | * @var \Flugg\Responder\TransformBuilder |
||
33 | */ |
||
34 | protected $transformBuilder; |
||
35 | |||
36 | /** |
||
37 | * A HTTP status code for the response. |
||
38 | * |
||
39 | * @var int |
||
40 | */ |
||
41 | protected $status = 200; |
||
42 | |||
43 | /** |
||
44 | * Construct the builder class. |
||
45 | * |
||
46 | * @param \Flugg\Responder\Contracts\ResponseFactory $responseFactory |
||
47 | * @param \Flugg\Responder\TransformBuilder $transformBuilder |
||
48 | */ |
||
49 | 69 | public function __construct(ResponseFactory $responseFactory, TransformBuilder $transformBuilder) |
|
55 | |||
56 | /** |
||
57 | * Set resource data for the transformation. |
||
58 | * |
||
59 | * @param mixed $data |
||
60 | * @param \Flugg\Responder\Transformers\Transformer|callable|string|null $transformer |
||
61 | * @param string|null $resourceKey |
||
62 | * @return self |
||
63 | */ |
||
64 | 56 | public function transform($data = null, $transformer = null, string $resourceKey = null): SuccessResponseBuilder |
|
70 | |||
71 | /** |
||
72 | * Dynamically send calls to the transform builder. |
||
73 | * |
||
74 | * @param string $name |
||
75 | * @param array $arguments |
||
76 | * @return self|void |
||
77 | */ |
||
78 | 33 | public function __call($name, $arguments) |
|
88 | |||
89 | /** |
||
90 | * Get the serialized response output. |
||
91 | * |
||
92 | * @return mixed |
||
93 | */ |
||
94 | 60 | protected function getOutput(): array |
|
98 | |||
99 | /** |
||
100 | * Validate the HTTP status code for the response. |
||
101 | * |
||
102 | * @param int $status |
||
103 | * @return void |
||
104 | * @throws \InvalidArgumentException |
||
105 | */ |
||
106 | 3 | protected function validateStatusCode(int $status) |
|
112 | } |
||
113 |