Copied!

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.

CloneableInstantiable
Methods
public __call(string $method, array $args)
 

Allow decorators to implement custom methods

  • return mixed
public __construct(Psr\Http\Message\StreamInterface $stream, ?string $filename = NULL)
 
  • param \StreamInterface $stream Stream to decorate
  • param string $filename optional file name
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).

  • return \StreamInterface
public __toString() : string
public close() : void
 
  • inheritDoc
public detach()
 
  • inheritDoc
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)
 
  • return mixed
public getSize() : ?int
 

Returns null, getSize isn't supported

  • return null
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.

  • param int $length
public rewind() : void
public seek( $offset, $whence = 0ZBateson\StreamDecorators\SEEK_SET) : void
 

Not supported.

  • param int $offset
  • param int $whence
  • throws \RuntimeException
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.

  • param string $string
  • return int the number of bytes written
Properties
protected $filename = NULL
 
  • var string name of the UUEncoded file
Methods
protected createStream() : Psr\Http\Message\StreamInterface
 

Implement in subclasses to dynamically create streams when requested.

  • throws \BadMethodCallException
Properties
private $buffer = NULL
 
  • var \BufferStream of read and decoded bytes
private $isWriting = false
 
  • var bool set to true when 'write' is called
private $position = 0
 
  • var int read/write position
private $remainder = ''
 
  • var string remainder of write operation if the bytes didn't align to 3 bytes
private $stream = NULL
 
  • var \StreamInterface $stream
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.

© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration