Ejemplo n.º 1
0
 /**
  * Return the contents of the file
  *
  * @return string
  */
 public function getContents()
 {
     // If an offset is provided
     if ($this->offset !== -1) {
         // Seek to the offset
         $this->stream->seek($this->offset);
     }
     // If a max length is provided
     if ($this->maxLength !== -1) {
         // Read from the offset till the maxLength
         return $this->stream->read($this->maxLength);
     }
     return $this->stream->getContents();
 }
Ejemplo n.º 2
0
 public function testProvidesStreamPosition()
 {
     $handle = fopen('php://temp', 'w+');
     $stream = new Stream($handle);
     $this->assertEquals(0, $stream->tell());
     $stream->write('foo');
     $this->assertEquals(3, $stream->tell());
     $stream->seek(1);
     $this->assertEquals(1, $stream->tell());
     $this->assertSame(ftell($handle), $stream->tell());
     $stream->close();
 }