drain() public method

Remove and return all data from the buffer.
public drain ( ) : string
return string
Example #1
0
 public function testApiDrain_EmptiesBuffer()
 {
     $result = $this->buffer->drain();
     $this->assertSame($this->initialString, $result);
     $this->assertSame('', (string) $this->buffer);
     $this->assertTrue($this->buffer->isEmpty());
 }
Example #2
0
 /**
  * @override
  * @inheritDoc
  */
 public function readResponse(BufferInterface $buffer, $data)
 {
     $buffer->push($data);
     if (($position = $buffer->search(self::HTTP_EOM)) === false) {
         if ($buffer->length() > $this->maxFrameSize) {
             throw new ReadException(sprintf('Message start line exceeded maximum size of %d bytes.', $this->maxFrameSize));
         }
         return null;
     }
     try {
         return $this->parser->parseResponse($buffer->drain());
     } catch (Error $ex) {
     } catch (Exception $ex) {
     }
     throw new InvalidFormatException('Could not parse start line.');
 }