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

Commit

Permalink
#223 #224 minor CS fixes to reduce indentation/complexity of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jan 17, 2017
1 parent df1b59a commit 0d60343
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/Response/SapiStreamEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ private function emitBody(ResponseInterface $response, $maxBufferLength)
$body->rewind();
}

if ($body->isReadable()) {
while (! $body->eof()) {
echo $body->read($maxBufferLength);
}
return;
if (! $body->isReadable()) {
echo $body;
}

echo $body;
while (! $body->eof()) {
echo $body->read($maxBufferLength);
}
}

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

if ($body->isSeekable()) {
$body->seek($first);

$first = 0;
}

if ($body->isReadable()) {
for ($remaining = $length; ($remaining >= $maxBufferLength)
&& (! $body->eof()); $remaining -= strlen($contents)) {
echo ($contents = $body->read($maxBufferLength));
}
if (! $body->isReadable()) {
echo substr($body->getContents(), $first, $length);
}

if (($remaining > 0) && (! $body->eof())) {
echo $body->read($remaining);
}
$remaining = $length;

return;
while ($remaining >= $maxBufferLength && ! $body->eof()) {
$contents = $body->read($maxBufferLength);
$remaining -= strlen($contents);

echo $contents;
}

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

/**
Expand Down

0 comments on commit 0d60343

Please sign in to comment.