Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 0d60343

Browse files
committed
#223 #224 minor CS fixes to reduce indentation/complexity of the code
1 parent df1b59a commit 0d60343

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/Response/SapiStreamEmitter.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,13 @@ private function emitBody(ResponseInterface $response, $maxBufferLength)
6262
$body->rewind();
6363
}
6464

65-
if ($body->isReadable()) {
66-
while (! $body->eof()) {
67-
echo $body->read($maxBufferLength);
68-
}
69-
return;
65+
if (! $body->isReadable()) {
66+
echo $body;
7067
}
7168

72-
echo $body;
69+
while (! $body->eof()) {
70+
echo $body->read($maxBufferLength);
71+
}
7372
}
7473

7574
/**
@@ -89,24 +88,26 @@ private function emitBodyRange(array $range, ResponseInterface $response, $maxBu
8988

9089
if ($body->isSeekable()) {
9190
$body->seek($first);
91+
9292
$first = 0;
9393
}
9494

95-
if ($body->isReadable()) {
96-
for ($remaining = $length; ($remaining >= $maxBufferLength)
97-
&& (! $body->eof()); $remaining -= strlen($contents)) {
98-
echo ($contents = $body->read($maxBufferLength));
99-
}
95+
if (! $body->isReadable()) {
96+
echo substr($body->getContents(), $first, $length);
97+
}
10098

101-
if (($remaining > 0) && (! $body->eof())) {
102-
echo $body->read($remaining);
103-
}
99+
$remaining = $length;
104100

105-
return;
101+
while ($remaining >= $maxBufferLength && ! $body->eof()) {
102+
$contents = $body->read($maxBufferLength);
103+
$remaining -= strlen($contents);
104+
105+
echo $contents;
106106
}
107107

108-
$contents = $body->getContents();
109-
echo substr($contents, $first, $length);
108+
if ($remaining > 0 && ! $body->eof()) {
109+
echo $body->read($remaining);
110+
}
110111
}
111112

112113
/**

0 commit comments

Comments
 (0)