src/Guzzle/Http/EntityBody.php
public static function factory($resource = '', $size = null)
    {
        if ($resource instanceof EntityBodyInterface) {
            return $resource;
        }

        switch (gettype($resource)) {
            case 'string':
                return self::fromString($resource);
            case 'resource':
                return new static($resource, $size);
            case 'object':
                if (method_exists($resource, '__toString')) {
                    return self::fromString((string) $resource);
                }
                break;
            case 'array':
                return self::fromString(http_build_query($resource));
        }

        throw new InvalidArgumentException('Invalid resource type');
    }
public static function factory($resource = '', $size = null)
    {
        if ($resource instanceof EntityBodyInterface) {
            return $resource;
        }

        switch (gettype($resource)) {
            case 'string':
                return self::fromString($resource);
            case 'resource':
                return new static($resource, $size);
            case 'object':
                if (method_exists($resource, '__toString')) {
                    return self::fromString((string) $resource);
                }
                break;
            case 'array':
                return self::fromString(http_build_query($resource));
        }

        throw new InvalidArgumentException('Invalid resource type');
    }
public static function factory ( $ resource = '' , $ size = null ) { if ( $ resource instanceof EntityBodyInterface ) { return $ resource ; } switch ( gettype ( $ resource ) ) { case 'string' : return self :: fromString ( $ resource ) ; case 'resource' : return new static ( $ resource , $ size ) ; case 'object' : if ( method_exists ( $ resource , '__toString' ) ) { return self :: fromString ( ( string ) $ resource ) ; } break ; case 'array' : return self :: fromString ( http_build_query ( $ resource ) ) ; } throw new InvalidArgumentException ( 'Invalid resource type' ) ; }
Create a new EntityBody based on the input type

@param resource|string|EntityBody $resource Entity body data
@param int                        $size     Size of the data contained in the resource

@return EntityBody
@throws InvalidArgumentException if the $resource arg is not a resource or string
Create a new EntityBody based on the input type