src/Stream.php
protected function _initResource($config)
    {
        if (!empty($config['data']) && !empty($config['filename'])) {
            throw new InvalidArgumentException("The `'data'` or `'filename'` option must be defined.");
        }
        if ($config['filename']) {
            $this->_filename = $config['filename'];
            if ($this->_filename === 'php://input') {
                $this->_mode = 'r';
            }
            $this->_resource = fopen($this->_filename, $this->_mode);
            return;
        }
        if (is_resource($config['data'])) {
            $this->_resource = $config['data'];
            return;
        } elseif (is_scalar($config['data'])) {
            $this->_resource = fopen('php://temp', 'r+');
            fwrite($this->_resource, (string) $config['data']);
            rewind($this->_resource);
        }
    }
protected function _initResource($config)
    {
        if (!empty($config['data']) && !empty($config['filename'])) {
            throw new InvalidArgumentException("The `'data'` or `'filename'` option must be defined.");
        }
        if ($config['filename']) {
            $this->_filename = $config['filename'];
            if ($this->_filename === 'php://input') {
                $this->_mode = 'r';
            }
            $this->_resource = fopen($this->_filename, $this->_mode);
            return;
        }
        if (is_resource($config['data'])) {
            $this->_resource = $config['data'];
            return;
        } elseif (is_scalar($config['data'])) {
            $this->_resource = fopen('php://temp', 'r+');
            fwrite($this->_resource, (string) $config['data']);
            rewind($this->_resource);
        }
    }
protected function _initResource ( $ config ) { if ( ! empty ( $ config [ 'data' ] ) && ! empty ( $ config [ 'filename' ] ) ) { throw new InvalidArgumentException ( "The `'data'` or `'filename'` option must be defined." ) ; } if ( $ config [ 'filename' ] ) { $ this -> _filename = $ config [ 'filename' ] ; if ( $ this -> _filename === 'php://input' ) { $ this -> _mode = 'r' ; } $ this -> _resource = fopen ( $ this -> _filename , $ this -> _mode ) ; return ; } if ( is_resource ( $ config [ 'data' ] ) ) { $ this -> _resource = $ config [ 'data' ] ; return ; } elseif ( is_scalar ( $ config [ 'data' ] ) ) { $ this -> _resource = fopen ( 'php://temp' , 'r+' ) ; fwrite ( $ this -> _resource , ( string ) $ config [ 'data' ] ) ; rewind ( $ this -> _resource ) ; } }
Init the stream resource.

@param array $config The constructor configuration array.
Init the stream resource .