FileAccess Orion

LimitStream
in package
implements StreamInterface Uses StreamDecoratorTrait

Decorator used to return only a subset of a stream

Interfaces, Classes, Traits and Enums

StreamInterface
Describes a data stream.

Table of Contents

$limit  : int
$offset  : int
__call()  : mixed
Allow decorators to implement custom methods
__construct()  : mixed
__get()  : StreamInterface
Magic method used to create a new stream if streams are not added in the constructor of a decorator (e.g., LazyOpenStream).
__toString()  : mixed
close()  : mixed
detach()  : mixed
eof()  : bool
Returns true if the stream is at the end of the stream.
getContents()  : mixed
getMetadata()  : mixed
getSize()  : int|null
Returns the size of the limited subset of data {@inheritdoc}
isReadable()  : mixed
isSeekable()  : mixed
isWritable()  : mixed
read()  : string
Read data from the stream.
rewind()  : mixed
seek()  : mixed
Allow for a bounded seek on the read limited stream {@inheritdoc}
setLimit()  : mixed
Set the limit of bytes that the decorator allows to be read from the stream.
setOffset()  : mixed
Set the offset to start limiting from
tell()  : int
Give a relative tell() {@inheritdoc}
write()  : mixed
createStream()  : StreamInterface
Implement in subclasses to dynamically create streams when requested.

Properties

$limit

private int $limit

Limit the number of bytes that can be read

$offset

private int $offset

Offset to start reading from

Methods

__call()

Allow decorators to implement custom methods

public __call(string $method, array<string|int, mixed> $args) : mixed
Parameters
$method : string

Missing method name

$args : array<string|int, mixed>

Method arguments

Return values
mixed —

__construct()

public __construct(StreamInterface $stream[, int $limit = -1 ], int $offset) : mixed
Parameters
$stream : StreamInterface

Stream to wrap

$limit : int = -1

Total number of bytes to allow to be read from the stream. Pass -1 for no limit.

$offset : int

Position to seek to before reading (only works on seekable streams).

Return values
mixed —

__get()

Magic method used to create a new stream if streams are not added in the constructor of a decorator (e.g., LazyOpenStream).

public __get(string $name) : StreamInterface
Parameters
$name : string

Name of the property (allows "stream" only).

Return values
StreamInterface —

eof()

Returns true if the stream is at the end of the stream.

public eof() : bool
Return values
bool —

getMetadata()

public getMetadata([mixed $key = null ]) : mixed
Parameters
$key : mixed = null
Return values
mixed —

getSize()

Returns the size of the limited subset of data {@inheritdoc}

public getSize() : int|null
Return values
int|null —

Returns the size in bytes if known, or null if unknown.

read()

Read data from the stream.

public read(mixed $length) : string
Parameters
$length : mixed

Read up to $length bytes from the object and return them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes.

Return values
string —

Returns the data read from the stream, or an empty string if no bytes are available.

seek()

Allow for a bounded seek on the read limited stream {@inheritdoc}

public seek(mixed $offset[, mixed $whence = SEEK_SET ]) : mixed
Parameters
$offset : mixed

Stream offset

$whence : mixed = SEEK_SET

Specifies how the cursor position will be calculated based on the seek offset. Valid values are identical to the built-in PHP $whence values for fseek(). SEEK_SET: Set position equal to offset bytes SEEK_CUR: Set position to current location plus offset SEEK_END: Set position to end-of-stream plus offset.

Return values
mixed —

setLimit()

Set the limit of bytes that the decorator allows to be read from the stream.

public setLimit(int $limit) : mixed
Parameters
$limit : int

Number of bytes to allow to be read from the stream. Use -1 for no limit.

Return values
mixed —

setOffset()

Set the offset to start limiting from

public setOffset(int $offset) : mixed
Parameters
$offset : int

Offset to seek to and begin byte limiting from

Tags
throws
RuntimeException

if the stream cannot be seeked.

Return values
mixed —

tell()

Give a relative tell() {@inheritdoc}

public tell() : int
Return values
int —

Position of the file pointer

write()

public write(mixed $string) : mixed
Parameters
$string : mixed
Return values
mixed —

Search results