Constants

STREAM_TYPE

STREAM_TYPE = 'stream_type'

WRAPPER_TYPE

WRAPPER_TYPE = 'wrapper_type'

IS_LOCAL

IS_LOCAL = 'is_local'

IS_READABLE

IS_READABLE = 'is_readable'

IS_WRITABLE

IS_WRITABLE = 'is_writable'

SEEKABLE

SEEKABLE = 'seekable'

Properties

$stream

$stream : resource

Type

resource — Stream resource

$size

$size : integer

Type

integer — Size of the stream contents in bytes

$cache

$cache : array

Type

array — Stream cached data

$customData

$customData : array

Type

array — Custom stream data

$readWriteHash

$readWriteHash : array

Type

array — Hash table of readable and writeable stream types for fast lookups

Methods

__construct()

__construct(resource  $stream, integer  $size = null) 

Parameters

resource $stream

Stream resource to wrap

integer $size

Size of the stream in bytes. Only pass if the size cannot be obtained from the stream.

Throws

\Guzzle\Common\Exception\InvalidArgumentException

if the stream is not a stream resource

__destruct()

__destruct() 

Closes the stream when the helper is destructed

__toString()

__toString() : string

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

Returns

string

close()

close() 

Close the underlying stream

getHash()

getHash(\Guzzle\Stream\StreamInterface  $stream, string  $algo, boolean  $rawOutput = false) : boolean|string

Calculate a hash of a Stream

Parameters

\Guzzle\Stream\StreamInterface $stream

Stream to calculate the hash for

string $algo

Hash algorithm (e.g. md5, crc32, etc)

boolean $rawOutput

Whether or not to use raw output

Returns

boolean|string —

Returns false on failure or a hash string on success

getMetaData()

getMetaData(string  $key = null) : array|mixed|null

Get stream metadata

Parameters

string $key

Specific metadata to retrieve

Returns

array|mixed|null

getStream()

getStream() : resource

Get the stream resource

Returns

resource

setStream()

setStream(resource  $stream, integer  $size = null) : self

Set the stream that is wrapped by the object

Parameters

resource $stream

Stream resource to wrap

integer $size

Size of the stream in bytes. Only pass if the size cannot be obtained from the stream.

Returns

self

detachStream()

detachStream() : self

Detach the current stream resource

Returns

self

getWrapper()

getWrapper() : string

Get the stream wrapper type

Returns

string

getWrapperData()

getWrapperData() : array

Wrapper specific data attached to this stream.

Returns

array

getStreamType()

getStreamType() : string

Get a label describing the underlying implementation of the stream

Returns

string

getUri()

getUri() : string

Get the URI/filename associated with this stream

Returns

string

getSize()

getSize() : integer|boolean

Get the size of the stream if able

Returns

integer|boolean

isReadable()

isReadable() : boolean

Check if the stream is readable

Returns

boolean

isRepeatable()

isRepeatable() : boolean

Check if the stream is repeatable

Returns

boolean

isWritable()

isWritable() : boolean

Check if the stream is writable

Returns

boolean

isConsumed()

isConsumed() : boolean

Check if the stream has been consumed

Returns

boolean

feof()

feof() : boolean

Alias of isConsumed

Returns

boolean

isLocal()

isLocal() : boolean

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

Returns

boolean

isSeekable()

isSeekable() : boolean

Check if the string is repeatable

Returns

boolean

setSize()

setSize(integer  $size) : self

Specify the size of the stream in bytes

Parameters

integer $size

Size of the stream contents in bytes

Returns

self

seek()

seek(integer  $offset, integer  $whence = SEEK_SET) : boolean

Seek to a position in the stream

Parameters

integer $offset

Stream offset

integer $whence

Where the offset is applied

Returns

boolean —

Returns TRUE on success or FALSE on failure

read()

read(integer  $length) : string|boolean

Read data from the stream

Parameters

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

write()

write(string  $string) : integer|boolean

Write data to the stream

Parameters

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.

ftell()

ftell() : integer|boolean

Returns the current position of the file read/write pointer

Returns

integer|boolean —

Returns the position of the file pointer or false on error

rewind()

rewind() : boolean

Rewind to the beginning of the stream

Returns

boolean —

Returns true on success or false on failure

readLine()

readLine(integer  $maxLength = null) : string|boolean

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

Parameters

integer $maxLength

Maximum buffer length

Returns

string|boolean

setCustomData()

setCustomData(string  $key, mixed  $value) : self

Set custom data on the stream

Parameters

string $key

Key to set

mixed $value

Value to set

Returns

self

getCustomData()

getCustomData(string  $key) : null|mixed

Get custom data from the stream

Parameters

string $key

Key to retrieve

Returns

null|mixed

rebuildCache()

rebuildCache() 

Reprocess stream metadata