NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class AbstractEntityBodyDecorator

Abstract decorator used to wrap entity bodies

  Guzzle\Http\AbstractEntityBodyDecorator implements Guzzle\Http\EntityBodyInterface

### Direct known subclasses

`Guzzle\Http\CachingEntityBody`, `Guzzle\Http\IoEmittingEntityBody`, `Guzzle\Http\ReadLimitEntityBody`

Namespace: Guzzle\Http
Located at Guzzle/Http/AbstractEntityBodyDecorator.php

## Methods summary

- `public` `__construct ( Guzzle\Http\EntityBodyInterface $body )`
- `public` `__toString ( )`

  Convert the stream to a string if the stream is readable and the stream is seekable.

- `public` `__call ( string $method, array $args )`

  Allow decorators to implement custom methods

- `public` `close ( )`

  Close the underlying stream

- `public` `setRewindFunction ( mixed $callable )`

  Specify a custom callback used to rewind a non-seekable stream. This can be useful entity enclosing requests that are redirected.

- `public` `rewind ( )`

  Rewind to the beginning of the stream

- `public` `compress ( string $filter = 'zlib.deflate' )`

  If the stream is readable, compress the data in the stream using deflate compression. The uncompressed stream is then closed, and the compressed stream then becomes the wrapped stream.

- `public` `uncompress ( string $filter = 'zlib.inflate' )`

  Decompress a deflated string. Once uncompressed, the uncompressed string is then used as the wrapped stream.

- `public` `getContentLength ( )`

  Get the Content-Length of the entity body if possible (alias of getSize)

- `public` `getContentType ( )`

  Guess the Content-Type of a local stream

- `public` `getContentMd5 ( bool $rawOutput = false, bool $base64Encode = false )`

  Get an MD5 checksum of the stream's contents

- `public` `getContentEncoding ( )`

  Get the Content-Encoding of the EntityBody

- `public` `getMetaData ( string $key = null )`

  Get stream metadata

- `public` `getStream ( )`

  Get the stream resource

- `public` `setStream ( resource $stream, int $size = 0 )`

  Set the stream that is wrapped by the object

- `public` `detachStream ( )`

  Detach the current stream resource

- `public` `getWrapper ( )`

  Get the stream wrapper type

- `public` `getWrapperData ( )`

  Wrapper specific data attached to this stream.

- `public` `getStreamType ( )`

  Get a label describing the underlying implementation of the stream

- `public` `getUri ( )`

  Get the URI/filename associated with this stream

- `public` `getSize ( )`

  Get the size of the stream if able

- `public` `isReadable ( )`

  Check if the stream is readable

- `public` `isRepeatable ( )`

  Check if the stream is repeatable

- `public` `isWritable ( )`

  Check if the stream is writable

- `public` `isConsumed ( )`

  Check if the stream has been consumed

- `public` `feof ( )`

  Alias of isConsumed() Alias of isConsumed

- `public` `isLocal ( )`

  Check if the stream is a local stream vs a remote stream

- `public` `isSeekable ( )`

  Check if the string is repeatable

- `public` `setSize ( int $size )`

  Specify the size of the stream in bytes

- `public` `seek ( int $offset, int $whence = SEEK_SET )`

  Seek to a position in the stream

- `public` `read ( int $length )`

  Read data from the stream

- `public` `write ( string $string )`

  Write data to the stream

- `public` `readLine ( int $maxLength = null )`

  Read a line from the stream up to the maximum allowed buffer length

- `public` `ftell ( )`

  Returns the current position of the file read/write pointer

- `public` `getCustomData ( string $key )`

  Get custom data from the stream

- `public` `setCustomData ( string $key, mixed $value )`

  Set custom data on the stream

## Methods detail

# `public`
`__construct( `Guzzle\Http\EntityBodyInterface` $body )`

#### Parameters

$body
  ``Guzzle\Http\EntityBodyInterface``
  $body Entity body to decorate

# `public string`
`__toString( )`

Convert the stream to a string if the stream is readable and the stream is seekable.

#### Returns

`string`

#### Implementation of

`Guzzle\Stream\StreamInterface::__toString()`
# `public mixed`
`__call( string $method, array $args )`

Allow decorators to implement custom methods

#### Parameters

$method
  `string`
  $method Missing method name
$args
  `array`
  $args Method arguments

#### Returns

`mixed`
# `public`
`close( )`

Close the underlying stream

#### Implementation of

`Guzzle\Stream\StreamInterface::close()`
# `public `Guzzle\Http\AbstractEntityBodyDecorator``
`setRewindFunction( mixed $callable )`

Specify a custom callback used to rewind a non-seekable stream. This can be useful entity enclosing requests that are redirected.

#### Parameters

$callable
  `mixed`
  $callable Callable to invoke to rewind a non-seekable stream. The callback must accept an EntityBodyInterface object, perform the rewind if possible, and return a boolean representing whether or not the rewind was successful.

#### Returns

``Guzzle\Http\AbstractEntityBodyDecorator``

#### Implementation of

`Guzzle\Http\EntityBodyInterface::setRewindFunction()`
# `public boolean`
`rewind( )`

Rewind to the beginning of the stream

#### Returns

`boolean`
Returns true on success or false on failure

#### Implementation of

`Guzzle\Stream\StreamInterface::rewind()`
# `public boolean`
`compress( string $filter = 'zlib.deflate' )`

If the stream is readable, compress the data in the stream using deflate compression. The uncompressed stream is then closed, and the compressed stream then becomes the wrapped stream.

#### Parameters

$filter
  `string`
  $filter Compression filter

#### Returns

`boolean`
Returns TRUE on success or FALSE on failure

#### Implementation of

`Guzzle\Http\EntityBodyInterface::compress()`
# `public boolean`
`uncompress( string $filter = 'zlib.inflate' )`

Decompress a deflated string. Once uncompressed, the uncompressed string is then used as the wrapped stream.

#### Parameters

$filter
  `string`
  $filter De-compression filter

#### Returns

`boolean`
Returns TRUE on success or FALSE on failure

#### Implementation of

`Guzzle\Http\EntityBodyInterface::uncompress()`
# `public integer|boolean`
`getContentLength( )`

Get the Content-Length of the entity body if possible (alias of getSize)

#### Returns

`integer|boolean`
Returns the Content-Length or false on failure

#### Implementation of

`Guzzle\Http\EntityBodyInterface::getContentLength()`
# `public string|null`
`getContentType( )`

Guess the Content-Type of a local stream

#### Returns

`string|null`

#### See

http://www.php.net/manual/en/function.finfo-open.php

#### Implementation of

`Guzzle\Http\EntityBodyInterface::getContentType()`
# `public boolean|string`
`getContentMd5( boolean $rawOutput = false, boolean $base64Encode = false )`

Get an MD5 checksum of the stream's contents

#### Parameters

$rawOutput
  `boolean`
  $rawOutput Whether or not to use raw output
$base64Encode
  `boolean`
  $base64Encode Whether or not to base64 encode raw output (only if raw output is true)

#### Returns

`boolean|string`
Returns an MD5 string on success or FALSE on failure

#### Implementation of

`Guzzle\Http\EntityBodyInterface::getContentMd5()`
# `public boolean|string`
`getContentEncoding( )`

Get the Content-Encoding of the EntityBody

#### Returns

`boolean|string`

#### Implementation of

`Guzzle\Http\EntityBodyInterface::getContentEncoding()`
# `public array|mixed|null`
`getMetaData( string $key = null )`

Get stream metadata

#### Parameters

$key
  `string`
  $key Specific metadata to retrieve

#### Returns

`array|mixed|null`

#### Implementation of

`Guzzle\Stream\StreamInterface::getMetaData()`
# `public resource`
`getStream( )`

Get the stream resource

#### Returns

`resource`

#### Implementation of

`Guzzle\Stream\StreamInterface::getStream()`
# `public `Guzzle\Http\AbstractEntityBodyDecorator``
`setStream( resource $stream, integer $size = 0 )`

Set the stream that is wrapped by the object

#### Parameters

$stream
  `resource`
  $stream Stream resource to wrap
$size
  `integer`
  $size Size of the stream in bytes. Only pass if the size cannot be obtained from the stream.

#### Returns

``Guzzle\Http\AbstractEntityBodyDecorator``

#### Implementation of

`Guzzle\Stream\StreamInterface::setStream()`
# `public `Guzzle\Http\AbstractEntityBodyDecorator``
`detachStream( )`

Detach the current stream resource

#### Returns

``Guzzle\Http\AbstractEntityBodyDecorator``

#### Implementation of

`Guzzle\Stream\StreamInterface::detachStream()`
# `public string`
`getWrapper( )`

Get the stream wrapper type

#### Returns

`string`

#### Implementation of

`Guzzle\Stream\StreamInterface::getWrapper()`
# `public array`
`getWrapperData( )`

Wrapper specific data attached to this stream.

#### Returns

`array`

#### Implementation of

`Guzzle\Stream\StreamInterface::getWrapperData()`
# `public string`
`getStreamType( )`

Get a label describing the underlying implementation of the stream

#### Returns

`string`

#### Implementation of

`Guzzle\Stream\StreamInterface::getStreamType()`
# `public string`
`getUri( )`

Get the URI/filename associated with this stream

#### Returns

`string`

#### Implementation of

`Guzzle\Stream\StreamInterface::getUri()`
# `public integer|boolean`
`getSize( )`

Get the size of the stream if able

#### Returns

`integer|boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::getSize()`
# `public boolean`
`isReadable( )`

Check if the stream is readable

#### Returns

`boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::isReadable()`
# `public boolean`
`isRepeatable( )`

Check if the stream is repeatable

#### Returns

`boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::isRepeatable()`
# `public boolean`
`isWritable( )`

Check if the stream is writable

#### Returns

`boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::isWritable()`
# `public boolean`
`isConsumed( )`

Check if the stream has been consumed

#### Returns

`boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::isConsumed()`
# `public boolean`
`feof( )`

Alias of isConsumed() Alias of isConsumed

#### Returns

`boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::feof()`
# `public boolean`
`isLocal( )`

Check if the stream is a local stream vs a remote stream

#### Returns

`boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::isLocal()`
# `public boolean`
`isSeekable( )`

Check if the string is repeatable

#### Returns

`boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::isSeekable()`
# `public `Guzzle\Http\AbstractEntityBodyDecorator``
`setSize( integer $size )`

Specify the size of the stream in bytes

#### Parameters

$size
  `integer`
  $size Size of the stream contents in bytes

#### Returns

``Guzzle\Http\AbstractEntityBodyDecorator``

#### Implementation of

`Guzzle\Stream\StreamInterface::setSize()`
# `public boolean`
`seek( integer $offset, integer $whence = SEEK_SET )`

Seek to a position in the stream

#### Parameters

$offset
  `integer`
  $offset Stream offset
$whence
  `integer`
  $whence Where the offset is applied

#### Returns

`boolean`
Returns TRUE on success or FALSE on failure

#### Link

http://www.php.net/manual/en/function.fseek.php

#### Implementation of

`Guzzle\Stream\StreamInterface::seek()`
# `public string|boolean`
`read( integer $length )`

Read data from the stream

#### Parameters

$length
  `integer`
  $length Up to length number of bytes read.

#### Returns

`string|boolean`
Returns the data read from the stream or FALSE on failure or EOF

#### Implementation of

`Guzzle\Stream\StreamInterface::read()`
# `public integer|boolean`
`write( string $string )`

Write data to the stream

#### Parameters

$string
  `string`
  $string The string that is to be written.

#### Returns

`integer|boolean`
Returns the number of bytes written to the stream on success or FALSE on failure.

#### Implementation of

`Guzzle\Stream\StreamInterface::write()`
# `public string|boolean`
`readLine( integer $maxLength = null )`

Read a line from the stream up to the maximum allowed buffer length

#### Parameters

$maxLength
  `integer`
  $maxLength Maximum buffer length

#### Returns

`string|boolean`

#### Implementation of

`Guzzle\Stream\StreamInterface::readLine()`
# `public integer|boolean`
`ftell( )`

Returns the current position of the file read/write pointer

#### Returns

`integer|boolean`
Returns the position of the file pointer or false on error

#### Implementation of

`Guzzle\Stream\StreamInterface::ftell()`
# `public null|mixed`
`getCustomData( string $key )`

Get custom data from the stream

#### Parameters

$key
  `string`
  $key Key to retrieve

#### Returns

`null|mixed`

#### Implementation of

`Guzzle\Stream\StreamInterface::getCustomData()`
# `public `Guzzle\Http\AbstractEntityBodyDecorator``
`setCustomData( string $key, mixed $value )`

Set custom data on the stream

#### Parameters

$key
  `string`
  $key Key to set
$value
  `mixed`
  $value Value to set

#### Returns

``Guzzle\Http\AbstractEntityBodyDecorator``

#### Implementation of

`Guzzle\Stream\StreamInterface::setCustomData()`

### Magic methods summary

## Properties summary

`protected `Guzzle\Http\EntityBodyInterface`` | $body | # Decorated entity body