Copied!

GuzzleHttp\Psr7 stream decoder decorator for quoted printable streams.

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

Allow decorators to implement custom methods

  • return mixed
public __construct(Psr\Http\Message\StreamInterface $stream)
 
  • param \StreamInterface $stream Stream to decorate
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
public getContents() : string
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
 

Reads up to $length decoded bytes from the underlying quoted-printable encoded stream 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 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 as quoted-printable.

Note that reading and writing to the same stream without rewinding is not supported.

  • param string $string
  • return int the number of bytes written
Methods
protected createStream() : Psr\Http\Message\StreamInterface
 

Implement in subclasses to dynamically create streams when requested.

  • throws \BadMethodCallException
Properties
private string $lastLine = ''
 
  • var string Last line of written text (used to maintain good line-breaks)
private int $position = 0
 
  • var int current read/write position
private Psr\Http\Message\StreamInterface $stream
 
  • var \StreamInterface $stream
  • phpstan-ignore-next-line
Methods
private beforeClose() : void
 

Writes out a final CRLF if the current line isn't empty.

private decodeBlock(string $block) : string
 

Decodes the passed $block of text.

If the last or before last character is an '=' char, indicating the beginning of a quoted-printable encoded char, 1 or 2 additional bytes are read from the underlying stream respectively.

  • return string The decoded string
private readEncodedChars(int $length, string $pre = '') : string
 

Reads $length chars from the underlying stream, prepending the past $pre to it first.

If the characters read (including the prepended $pre) contain invalid quoted-printable characters, the underlying stream is rewound by the total number of characters ($length + strlen($pre)).

The quoted-printable encoded characters are returned. If the characters read are invalid, '3D' is returned indicating an '=' character.

private readRawDecodeAndAppend(int $length, string $str) : int
 

Reads up to $length characters, appends them to the passed $str string, and returns the total number of characters read.

-1 is returned if there are no more bytes to read.

© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration