Phly\Http\Stream::__toString PHP Method

__toString() public method

public __toString ( )
    public function __toString()
    {
        if (!$this->isReadable()) {
            return '';
        }
        try {
            $this->rewind();
            return $this->getContents();
        } catch (RuntimeException $e) {
            return '';
        }
    }

Usage Example

Exemplo n.º 1
0
 public function testStringSerializationReturnsEmptyStringWhenStreamIsNotReadable()
 {
     $this->tmpnam = tempnam(sys_get_temp_dir(), 'phly');
     file_put_contents($this->tmpnam, 'FOO BAR');
     $stream = new Stream($this->tmpnam, 'w');
     $this->assertEquals('', $stream->__toString());
 }
All Usage Examples Of Phly\Http\Stream::__toString