Phly\Http\UploadedFile::getStream PHP Метод

getStream() публичный Метод

public getStream ( )
    public function getStream()
    {
        if ($this->moved) {
            throw new RuntimeException('Cannot retrieve stream after it has already been moved');
        }
        if ($this->stream instanceof StreamInterface) {
            return $this->stream;
        }
        $this->stream = new Stream($this->file);
        return $this->stream;
    }

Usage Example

Пример #1
0
 public function testCannotRetrieveStreamAfterMove()
 {
     $stream = new Stream('php://temp', 'wb+');
     $stream->write('Foo bar!');
     $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK);
     $this->tmpFile = $to = tempnam(sys_get_temp_dir(), 'phly');
     $upload->moveTo($to);
     $this->assertTrue(file_exists($to));
     $this->setExpectedException('RuntimeException', 'moved');
     $upload->getStream();
 }