GuzzleHttp\Psr7 stream decoder extension for UU-Encoded streams.
The size of the underlying stream and the position of bytes can't be determined because the number of encoded bytes is indeterminate without reading the entire stream.
- author Zaahid Bateson
- Implements
Psr\Http\Message\StreamInterface Stringable - Traits
Methods |
public __call(string $method, array $args) Allow decorators to implement custom methods
|
public __construct(Psr\Http\Message\StreamInterface $stream, ?string $filename = NULL)
|
public __get(string $name) Magic method used to create a new stream if streams are not added in the constructor of a decorator (e.g., LazyOpenStream).
|
public __toString() : string |
public close() : void
|
public detach()
|
public eof() : bool Returns true if the end of stream has been reached. |
public getContents() : string |
public getFilename() : string Returns the filename set in the UUEncoded header (or null) |
public getMetadata( $key = NULL)
|
public getSize() : ?int Returns null, getSize isn't supported
|
public isReadable() : bool |
public isSeekable() : bool Overridden to return false |
public isWritable() : bool |
public read( $length) : string Attempts to read $length bytes after decoding them, and returns them.
|
public rewind() : void |
public seek( $offset, $whence = 0ZBateson\StreamDecorators\SEEK_SET) : void Not supported.
|
public setFilename(string $filename) : void Sets the UUEncoded header file name written in the 'begin' header line. |
public tell() : int Overridden to return the position in the target encoding. |
public write( $string) : int Writes the passed string to the underlying stream after encoding it. Note that reading and writing to the same stream without rewinding is not supported. Also note that some bytes may not be written until close or detach are called. This happens if written data doesn't align to a complete uuencoded 'line' of 45 bytes. In addition, the UU footer is only written when closing or detaching as well.
|
Properties |
protected $filename = NULL
|
Methods |
protected createStream() : Psr\Http\Message\StreamInterface Implement in subclasses to dynamically create streams when requested.
|
Properties |
private $buffer = NULL
|
private $isWriting = false
|
private $position = 0
|
private $remainder = ''
|
private $stream = NULL
|
Methods |
private beforeClose() : void Writes out any remaining bytes and the UU footer. |
private fillBuffer(int $length) : void Buffers bytes into $this->buffer, removing uuencoding headers and footers and decoding them. |
private filterAndDecode(string $str) : string Removes invalid characters from a uuencoded string, and 'BEGIN' and 'END' line headers and footers from the passed string before returning it. |
private handleRemainder(string $string) : string Prepends any existing remainder to the passed string, then checks if the string fits into a uuencoded line, and removes and keeps any remainder from the string to write. Full lines ready for writing are returned. |
private readToEndOfLine(int $length) : string Finds the next end-of-line character to ensure a line isn't broken up while buffering. |
private writeEncoded(string $bytes) : void Writes the passed bytes to the underlying stream after encoding them. |
private writeUUFooter() : void Writes the '`' and 'end' UU footer lines. |
private writeUUHeader() : void Writes the 'begin' UU header line. |