HashingStream
in package
implements
StreamInterface
Uses
StreamDecoratorTrait
Stream decorator that calculates a rolling hash of the stream as it is read.
Interfaces, Classes and Traits
- StreamInterface
- Describes a data stream.
Table of Contents
- $callback : callable|null
- $hash : HashInterface
- __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() : mixed
- getContents() : mixed
- getMetadata() : mixed
- getSize() : mixed
- isReadable() : mixed
- isSeekable() : mixed
- isWritable() : mixed
- read() : string
- Read data from the stream.
- rewind() : mixed
- seek() : mixed
- Seek to a position in the stream.
- tell() : mixed
- write() : mixed
- createStream() : StreamInterface
- Implement in subclasses to dynamically create streams when requested.
Properties
$callback
private
callable|null
$callback
$hash
private
HashInterface
$hash
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, HashInterface $hash[, callable $onComplete = null ]) : mixed
Parameters
- $stream : StreamInterface
-
Stream that is being read.
- $hash : HashInterface
-
Hash used to calculate checksum.
- $onComplete : callable = null
-
Optional function invoked when the hash calculation is completed.
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 —__toString()
public
__toString() : mixed
Return values
mixed —close()
public
close() : mixed
Return values
mixed —detach()
public
detach() : mixed
Return values
mixed —eof()
public
eof() : mixed
Return values
mixed —getContents()
public
getContents() : mixed
Return values
mixed —getMetadata()
public
getMetadata([mixed $key = null ]) : mixed
Parameters
- $key : mixed = null
Return values
mixed —getSize()
public
getSize() : mixed
Return values
mixed —isReadable()
public
isReadable() : mixed
Return values
mixed —isSeekable()
public
isSeekable() : mixed
Return values
mixed —isWritable()
public
isWritable() : mixed
Return values
mixed —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.
rewind()
public
rewind() : mixed
Return values
mixed —seek()
Seek to a position in the stream.
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 —tell()
public
tell() : mixed
Return values
mixed —write()
public
write(mixed $string) : mixed
Parameters
- $string : mixed
Return values
mixed —createStream()
Implement in subclasses to dynamically create streams when requested.
protected
createStream() : StreamInterface