Phly\Http\Stream::isReadable PHP Method

isReadable() public method

public isReadable ( )
    public function isReadable()
    {
        if (!$this->resource) {
            return false;
        }
        $meta = stream_get_meta_data($this->resource);
        $mode = $meta['mode'];
        return strstr($mode, 'r') || strstr($mode, '+');
    }

Usage Example

Example #1
0
 public function testIsReadableReturnsFalseWhenStreamIsDetached()
 {
     $this->tmpnam = tempnam(sys_get_temp_dir(), 'phly');
     file_put_contents($this->tmpnam, 'FOO BAR');
     $resource = fopen($this->tmpnam, 'wb+');
     $stream = new Stream($resource);
     $stream->detach();
     $this->assertFalse($stream->isReadable());
 }