src/Stream.php
public static function wrap($resource = '', $size = null)
    {
        if ($resource instanceof Stream) {
            return $resource;
        }

        $type = gettype($resource);

        if ($type == 'string') {
            return self::fromString($resource, $size);
        }

        if ($type == 'resource') {
            return new self($resource, $size);
        }

        throw new InvalidArgumentException('Invalid resource type: ' . $type);
    }
public static function wrap($resource = '', $size = null)
    {
        if ($resource instanceof Stream) {
            return $resource;
        }

        $type = gettype($resource);

        if ($type == 'string') {
            return self::fromString($resource, $size);
        }

        if ($type == 'resource') {
            return new self($resource, $size);
        }

        throw new InvalidArgumentException('Invalid resource type: ' . $type);
    }
public static function wrap ( $ resource = '' , $ size = null ) { if ( $ resource instanceof Stream ) { return $ resource ; } $ type = gettype ( $ resource ) ; if ( $ type == 'string' ) { return self :: fromString ( $ resource , $ size ) ; } if ( $ type == 'resource' ) { return new self ( $ resource , $ size ) ; } throw new InvalidArgumentException ( 'Invalid resource type: ' . $ type ) ; }
Wrap the input resource in a stream object.

@param \Protobuf\Stream|resource|string $resource
@param integer                          $size

@return \Protobuf\Stream

@throws \InvalidArgumentException if the $resource arg is not valid.
Wrap the input resource in a stream object .