18
18
* @phpstan-type ResponseArrayShape array{
19
19
* statusCode: int,
20
20
* headers: array<string, list<string>>,
21
- * body?: string|null,
22
- * reasonPhrase: string
21
+ * body?: string|null
23
22
* }
24
23
*
25
24
* @extends AbstractDataTransferObject<ResponseArrayShape>
@@ -29,7 +28,6 @@ class Response extends AbstractDataTransferObject
29
28
public const KEY_STATUS_CODE = 'statusCode ' ;
30
29
public const KEY_HEADERS = 'headers ' ;
31
30
public const KEY_BODY = 'body ' ;
32
- public const KEY_REASON_PHRASE = 'reasonPhrase ' ;
33
31
34
32
/**
35
33
* @var int The HTTP status code.
@@ -51,11 +49,6 @@ class Response extends AbstractDataTransferObject
51
49
*/
52
50
protected ?string $ body ;
53
51
54
- /**
55
- * @var string The reason phrase.
56
- */
57
- protected string $ reasonPhrase ;
58
-
59
52
/**
60
53
* Constructor.
61
54
*
@@ -64,11 +57,10 @@ class Response extends AbstractDataTransferObject
64
57
* @param int $statusCode The HTTP status code.
65
58
* @param array<string, string|list<string>> $headers The response headers.
66
59
* @param string|null $body The response body.
67
- * @param string $reasonPhrase The reason phrase.
68
60
*
69
61
* @throws InvalidArgumentException If the status code is invalid.
70
62
*/
71
- public function __construct (int $ statusCode , array $ headers , ?string $ body = null , string $ reasonPhrase = '' )
63
+ public function __construct (int $ statusCode , array $ headers , ?string $ body = null )
72
64
{
73
65
if ($ statusCode < 100 || $ statusCode >= 600 ) {
74
66
throw new InvalidArgumentException ('Invalid HTTP status code: ' . $ statusCode );
@@ -78,7 +70,6 @@ public function __construct(int $statusCode, array $headers, ?string $body = nul
78
70
$ this ->headers = $ this ->normalizeHeaderValues ($ headers );
79
71
$ this ->headersMap = $ this ->buildHeadersMap ($ this ->headers );
80
72
$ this ->body = $ body ;
81
- $ this ->reasonPhrase = $ reasonPhrase ;
82
73
}
83
74
84
75
/**
@@ -148,18 +139,6 @@ public function getBody(): ?string
148
139
return $ this ->body ;
149
140
}
150
141
151
- /**
152
- * Gets the reason phrase.
153
- *
154
- * @since n.e.x.t
155
- *
156
- * @return string The reason phrase.
157
- */
158
- public function getReasonPhrase (): string
159
- {
160
- return $ this ->reasonPhrase ;
161
- }
162
-
163
142
/**
164
143
* Checks if the response indicates success.
165
144
*
@@ -260,12 +239,8 @@ public static function getJsonSchema(): array
260
239
'type ' => ['string ' , 'null ' ],
261
240
'description ' => 'The response body. ' ,
262
241
],
263
- self ::KEY_REASON_PHRASE => [
264
- 'type ' => 'string ' ,
265
- 'description ' => 'The reason phrase. ' ,
266
- ],
267
242
],
268
- 'required ' => [self ::KEY_STATUS_CODE , self ::KEY_HEADERS , self :: KEY_REASON_PHRASE ],
243
+ 'required ' => [self ::KEY_STATUS_CODE , self ::KEY_HEADERS ],
269
244
];
270
245
}
271
246
@@ -281,7 +256,6 @@ public function toArray(): array
281
256
$ data = [
282
257
self ::KEY_STATUS_CODE => $ this ->statusCode ,
283
258
self ::KEY_HEADERS => $ this ->headers ,
284
- self ::KEY_REASON_PHRASE => $ this ->reasonPhrase ,
285
259
];
286
260
287
261
if ($ this ->body !== null ) {
@@ -301,14 +275,12 @@ public static function fromArray(array $array): self
301
275
static ::validateFromArrayData ($ array , [
302
276
self ::KEY_STATUS_CODE ,
303
277
self ::KEY_HEADERS ,
304
- self ::KEY_REASON_PHRASE ,
305
278
]);
306
279
307
280
return new self (
308
281
$ array [self ::KEY_STATUS_CODE ],
309
282
$ array [self ::KEY_HEADERS ],
310
- $ array [self ::KEY_BODY ] ?? null ,
311
- $ array [self ::KEY_REASON_PHRASE ]
283
+ $ array [self ::KEY_BODY ] ?? null
312
284
);
313
285
}
314
286
}
0 commit comments