src/AbstractStream.php
public static function make($resource = '', $mode = 'w+b')
    {
        switch (gettype($resource)) {
            case 'resource':
                return (new static(false))->setResource($resource, $mode);
            case 'string':
                $stream = fopen('php://temp', $mode);
                if ($resource !== '') {
                    fwrite($stream, $resource);
                    fseek($stream, 0);
                }

                return (new static(false))->setResource($stream, $mode);
            case 'object':
                if ($resource instanceof self) {
                    return $resource;
                } elseif (method_exists($resource, '__toString')) {
                    $resource = (string) $resource;

                    return static::make($resource, $mode);
                }
            default:
                throw new InvalidArgumentException(sprintf(
                    'Invalid resource "%s" provided.',
                    is_object($resource) ? get_class($resource)
                                         : gettype($resource)
                ));
        }
    }
public static function make($resource = '', $mode = 'w+b')
    {
        switch (gettype($resource)) {
            case 'resource':
                return (new static(false))->setResource($resource, $mode);
            case 'string':
                $stream = fopen('php://temp', $mode);
                if ($resource !== '') {
                    fwrite($stream, $resource);
                    fseek($stream, 0);
                }

                return (new static(false))->setResource($stream, $mode);
            case 'object':
                if ($resource instanceof self) {
                    return $resource;
                } elseif (method_exists($resource, '__toString')) {
                    $resource = (string) $resource;

                    return static::make($resource, $mode);
                }
            default:
                throw new InvalidArgumentException(sprintf(
                    'Invalid resource "%s" provided.',
                    is_object($resource) ? get_class($resource)
                                         : gettype($resource)
                ));
        }
    }
public static function make ( $ resource = '' , $ mode = 'w+b' ) { switch ( gettype ( $ resource ) ) { case 'resource' : return ( new static ( false ) ) -> setResource ( $ resource , $ mode ) ; case 'string' : $ stream = fopen ( 'php://temp' , $ mode ) ; if ( $ resource !== '' ) { fwrite ( $ stream , $ resource ) ; fseek ( $ stream , 0 ) ; } return ( new static ( false ) ) -> setResource ( $ stream , $ mode ) ; case 'object' : if ( $ resource instanceof self ) { return $ resource ; } elseif ( method_exists ( $ resource , '__toString' ) ) { $ resource = ( string ) $ resource ; return static :: make ( $ resource , $ mode ) ; } default : throw new InvalidArgumentException ( sprintf ( 'Invalid resource "%s" provided.' , is_object ( $ resource ) ? get_class ( $ resource ) : gettype ( $ resource ) ) ) ; } }
Makes new stream instance of current stream class.

@param string|object|resource $resource Optional;

- the string as a body of new resource
- or an object which can be converted to a string (the instance of
AbstractStream returns without changes)
- or the resource to wrap
@param string $mode Optional; "w+b" by default. The type of access to
the stream if the access type is not specified
for a resource

@throws \InvalidArgumentException If the type of the specified resource
is not acceptable

@return self
Makes new stream instance of current stream class .