public static function EntityBody::factory

Create a new EntityBody based on the input type

Parameters

resource|string|EntityBody $resource Entity body data:

int $size Size of the data contained in the resource:

Return value

EntityBody

Throws

InvalidArgumentException if the $resource arg is not a resource or string

6 calls to EntityBody::factory()
EntityEnclosingRequest::setBody in drupal/core/vendor/guzzle/http/Guzzle/Http/Message/EntityEnclosingRequest.php
Set the body of the request
Request::getResponseBody in drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Request.php
Request::receiveResponseHeader in drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Request.php
Method to receive HTTP response headers as they are retrieved
RequestFactory::create in drupal/core/vendor/guzzle/http/Guzzle/Http/Message/RequestFactory.php
Create a new request based on the HTTP method
Response::setBody in drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Response.php
Set the response entity body

... See full list

File

drupal/core/vendor/guzzle/http/Guzzle/Http/EntityBody.php, line 33

Class

EntityBody
Entity body used with an HTTP request or response

Namespace

Guzzle\Http

Code

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');
}