Skip to content

Commit 6c5694a

Browse files
Addded PHPDoc blocks
1 parent 105d890 commit 6c5694a

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

src/ResponseBuilder.php

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
class ResponseBuilder extends ResponseBuilderBase
2626
{
27-
2827
/** @var bool */
2928
protected $success = false;
3029

@@ -123,13 +122,23 @@ public static function error(int $api_code, array $placeholders = null, $data =
123122
->build();
124123
}
125124

126-
// -----------------------------------------------------------------------------------------------------------
125+
// -----------------------------------------------------------------------------------------------------------
127126

127+
/**
128+
* @param int|null $api_code
129+
*
130+
* @return \MarcinOrlowski\ResponseBuilder\ResponseBuilder
131+
*/
128132
public static function asSuccess(int $api_code = null): self
129133
{
130134
return new self(true, $api_code ?? BaseApiCodes::OK());
131135
}
132136

137+
/**
138+
* @param int $api_code
139+
*
140+
* @return \MarcinOrlowski\ResponseBuilder\ResponseBuilder
141+
*/
133142
public static function asError(int $api_code): self
134143
{
135144
$code_ok = BaseApiCodes::OK();
@@ -144,6 +153,11 @@ public static function asError(int $api_code): self
144153
return new self(false, $api_code);
145154
}
146155

156+
/**
157+
* @param int|null $http_code
158+
*
159+
* @return $this
160+
*/
147161
public function withHttpCode(int $http_code = null): self
148162
{
149163
Validator::assertIsType('http_code', $http_code, [Validator::TYPE_INTEGER,
@@ -153,6 +167,11 @@ public function withHttpCode(int $http_code = null): self
153167
return $this;
154168
}
155169

170+
/**
171+
* @param null $data
172+
*
173+
* @return $this
174+
*/
156175
public function withData($data = null): self
157176
{
158177
Validator::assertIsType('data', $data, [Validator::TYPE_ARRAY,
@@ -163,6 +182,11 @@ public function withData($data = null): self
163182
return $this;
164183
}
165184

185+
/**
186+
* @param int|null $json_opts
187+
*
188+
* @return $this
189+
*/
166190
public function withJsonOptions(int $json_opts = null): self
167191
{
168192
Validator::assertIsType('json_opts', $json_opts, [Validator::TYPE_INTEGER,
@@ -172,6 +196,11 @@ public function withJsonOptions(int $json_opts = null): self
172196
return $this;
173197
}
174198

199+
/**
200+
* @param array|null $debug_data
201+
*
202+
* @return $this
203+
*/
175204
public function withDebugData(array $debug_data = null): self
176205
{
177206
Validator::assertIsType('$debug_data', $debug_data, [Validator::TYPE_ARRAY,
@@ -181,6 +210,11 @@ public function withDebugData(array $debug_data = null): self
181210
return $this;
182211
}
183212

213+
/**
214+
* @param string|null $msg
215+
*
216+
* @return $this
217+
*/
184218
public function withMessage(string $msg = null): self
185219
{
186220
Validator::assertIsType('message', $msg, [Validator::TYPE_STRING,
@@ -190,20 +224,37 @@ public function withMessage(string $msg = null): self
190224
return $this;
191225
}
192226

227+
/**
228+
* @param array|null $placeholders
229+
*
230+
* @return $this
231+
*/
193232
public function withPlaceholders(array $placeholders = null): self
194233
{
195234
$this->placeholders = $placeholders;
196235

197236
return $this;
198237
}
199238

239+
/**
240+
* @param array|null $http_headers
241+
*
242+
* @return $this
243+
*/
200244
public function withHttpHeaders(array $http_headers = null): self
201245
{
202246
$this->http_headers = $http_headers ?? [];
203247

204248
return $this;
205249
}
206250

251+
/**
252+
* Builds and returns final HttpResponse. It's safe to call build() as many times as needed, as no
253+
* internal state is changed. It's also safe to alter any parameter set previously and call build()
254+
* again to get new response object that includes new changes.
255+
*
256+
* @return \Symfony\Component\HttpFoundation\Response
257+
*/
207258
public function build(): HttpResponse
208259
{
209260
$api_code = $this->api_code;

0 commit comments

Comments
 (0)