Skip to content

Commit aca53b9

Browse files
committed
Merge pull request #14 from ajgarlag/patch-1
Fix `Stream::read($length)` implementation
2 parents ea4b321 + bbfaa46 commit aca53b9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Stream.php

-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ public function read($length)
163163
return fread($this->socket, $length);
164164
}
165165

166-
if ($this->getSize() < ($this->readed + $length)) {
167-
throw new StreamException('Cannot read more than %s', $this->getSize() - $this->readed);
168-
}
169-
170166
if ($this->getSize() === $this->readed) {
171167
return '';
172168
}

tests/StreamTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,14 @@ public function testClose()
144144

145145
$this->assertFalse(is_resource($socket));
146146
}
147+
148+
public function testRead()
149+
{
150+
$stream = $this->createSocket("Body");
151+
152+
$this->assertEquals("Bod", $stream->read(3));
153+
$this->assertEquals("y", $stream->read(3));
154+
155+
$stream->close();
156+
}
147157
}

0 commit comments

Comments
 (0)