Skip to content

Commit c1d83ad

Browse files
Fixed minor issue in the response class
1 parent 7201362 commit c1d83ad

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Response.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public function getStatusCode(): int
109109
*/
110110
public function withStatus($code, $reasonPhrase = ''): self
111111
{
112+
if ($code < 100 || $code > 599) {
113+
throw new InvalidArgumentException(\sprintf('Response status code "%d" is not valid. It must be in 100..599 range.', $statusCode));
114+
}
115+
112116
$new = clone $this;
113117
$new->message = $this->message->setStatusCode($code, !empty($reasonPhrase) ? $reasonPhrase : null);
114118

@@ -285,10 +289,6 @@ private function getStream($stream): StreamInterface
285289
return $stream;
286290
}
287291

288-
if (!\is_string($stream) && !\is_resource($stream)) {
289-
throw new InvalidArgumentException('Stream must be a string stream resource identifier, an actual stream resource, or a Psr\Http\Message\StreamInterface implementation');
290-
}
291-
292292
return new Stream($stream);
293293
}
294294
}

0 commit comments

Comments
 (0)