peek() public method

Return the given number of characters (at most) from the buffer without removing them from the buffer.
public peek ( integer $length, integer $offset ) : string
$length integer
$offset integer
return string
Example #1
0
 public function testApiPeek_ReturnsWholeData_WhenLengthGreaterThanBufferLengthIsPassed()
 {
     $length = 100;
     $result = $this->buffer->peek($length);
     $this->assertSame($this->initialString, $result);
     $this->assertSame($this->initialString, (string) $this->buffer);
 }
 /**
  *
  */
 private function writeEnd()
 {
     do {
         try {
             $sent = fwrite($this->resource, $this->buffer->peek());
             $this->buffer->remove($sent);
         } catch (Error $ex) {
             $sent = 0;
         } catch (Exception $ex) {
             $sent = 0;
         }
     } while (is_resource($this->resource) && $sent > 0 && !$this->buffer->isEmpty());
 }