PHPackages                             rsaccani/stream-decorators - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. rsaccani/stream-decorators

AbandonedArchivedLibrary[Mail &amp; Notifications](/categories/mail)

rsaccani/stream-decorators
==========================

PHP psr7 stream decorators for mime message part streams

0.1.0(7y ago)0873[1 PRs](https://github.com/rsaccani/StreamDecorators/pulls)BSD-2-ClausePHPPHP &gt;=5.4

Since Aug 9Pushed 4y ago2 watchersCompare

[ Source](https://github.com/rsaccani/StreamDecorators)[ Packagist](https://packagist.org/packages/rsaccani/stream-decorators)[ Docs](https://github.com/zbateson/StreamDecorators)[ RSS](/packages/rsaccani-stream-decorators/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

zbateson/stream-decorators
==========================

[](#zbatesonstream-decorators)

Psr7 stream decorators for character set conversion and common mail format content encodings.

[![Build Status](https://camo.githubusercontent.com/cc9c71708b175079768160b8ef85602e08f40db1bb369dbf6d1156e8441b80e2/68747470733a2f2f7472617669732d63692e6f72672f7a62617465736f6e2f53747265616d4465636f7261746f72732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/zbateson/StreamDecorators)[![Code Coverage](https://camo.githubusercontent.com/723da7a63cdee35f5e40a2a20caecab6e0bf87fc4d7562edf793485e378cb899/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7a62617465736f6e2f53747265616d4465636f7261746f72732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/zbateson/StreamDecorators/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/601c17ff2a0a3d9f53236bfc7e48dc971255e9591e9f6e5a8b929e0f10affeae/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7a62617465736f6e2f53747265616d4465636f7261746f72732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/zbateson/StreamDecorators/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/1b4f0722f88a218272b1a0858be60b5399ee41d4290a71f183e250b3a19ad39e/68747470733a2f2f706f7365722e707567782e6f72672f7a62617465736f6e2f73747265616d2d6465636f7261746f72732f646f776e6c6f616473)](https://packagist.org/packages/zbateson/stream-decorators)[![Latest Stable Version](https://camo.githubusercontent.com/99d45292d375dafa01f337e019a1986371b3e4ad8466e96181758a94c3327bb7/68747470733a2f2f706f7365722e707567782e6f72672f7a62617465736f6e2f73747265616d2d6465636f7261746f72732f76657273696f6e)](https://packagist.org/packages/zbateson/stream-decorators)

The goals of this project are to be:

- Well written
- Standards-compliant but forgiving
- Includable via composer
- Tested where possible

To include it for use in your project, please install via composer:

```
composer require zbateson/stream-decorators

```

Requirements
------------

[](#requirements)

StreamDecorators requires PHP 5.4 or newer or HHVM. Tested on PHP 5.4, 5.5, 5.6, 7, 7.1 and 7.2 and HHVM 3.6, 3.12, 3.24 and 'current' on travis.

Usage
-----

[](#usage)

```
$stream = GuzzleHttp\Psr7\stream_for($handle);
$b64Stream = new ZBateson\StreamDecorators\Base64Stream($stream);
$charsetStream = new ZBateson\StreamDecorators\CharsetStream($b64Stream, 'UTF-32', 'UTF-8');

while (($line = GuzzleHttp\Psr7\readline()) !== false) {
    echo $line, "\r\n";
}

```

The library consists of the following Psr\\Http\\Message\\StreamInterface implementations:

- ZBateson\\StreamDecorators\\QuotedPrintableStream - decodes on read and encodes on write to quoted-printable
- ZBateson\\StreamDecorators\\Base64Stream - decodes on read and encodes on write to base64
- ZBateson\\StreamDecorators\\UUStream - decodes on read, encodes on write to uu-encoded
- ZBateson\\StreamDecorators\\CharsetStream - encodes from $streamCharset to $stringCharset on read, and vice-versa on write
- ZBateson\\StreamDecorators\\NonClosingStream - overrides close() and detach(), and simply unsets the attached stream without closing it
- ZBateson\\StreamDecorators\\ChunkSplitStream - splits written characters into lines of $lineLength long (stream implementation of php's chunk\_split)
- ZBateson\\StreamDecorators\\PregReplaceFilterStream - calls preg\_replace on with passed arguments on every read() call
- ZBateson\\StreamDecorators\\SeekingLimitStream - similar to GuzzleHttp's LimitStream, but maintains an internal current read position, seeking to it when read() is called, and seeking back to the wrapped stream's position after reading

QuotedPrintableStream, Base64Stream and UUStream's constructors take a single argument of a StreamInterface. CharsetStreams's constructor also takes $streamCharset and $stringCharset as arguments respectively, ChunkSplitStream optionally takes a $lineLength argument (defaults to 76) and a $lineEnding argument (defaults to CRLF). PregReplaceFilterStream takes a $pattern argument and a $replacement argument. SeekingLimitStream takes optional $limit and $offset parameters, similar to GuzzleHttp's LimitStream.

In addition, the library exposes a ZBateson\\StreamDecorators\\Util\\CharsetConverter class which provides the following:

- a map of supported charsets with different names (aliases)
- better charset lookup (by removing special chars during lookup, etc...) to catch more charsets that may be found in Content-Type headers
- abstraction of the following mb\_\* and iconv functions, preferring mb\_\* for supported charsets:
- mb\_convert\_encoding, iconv with CharsetConverter::convert
- mb\_substr, iconv\_substr with CharsetConverter::getSubstr
- mb\_strlen, iconv\_strlen with CharsetConverter::getLength

License
-------

[](#license)

BSD licensed - please see [license agreement](https://github.com/zbateson/StreamDecorator/blob/master/LICENSE).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2831d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d74cb65492886726c4e88e3533ef0572cb26932fbd5ac796da414c0813c5930f?d=identicon)[rsaccani](/maintainers/rsaccani)

---

Top Contributors

[![zbateson](https://avatars.githubusercontent.com/u/8356974?v=4)](https://github.com/zbateson "zbateson (60 commits)")[![pupaxxo](https://avatars.githubusercontent.com/u/2815664?v=4)](https://github.com/pupaxxo "pupaxxo (3 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

streampsr7mailmimedecorators

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rsaccani-stream-decorators/health.svg)

```
[![Health](https://phpackages.com/badges/rsaccani-stream-decorators/health.svg)](https://phpackages.com/packages/rsaccani-stream-decorators)
```

###  Alternatives

[zbateson/stream-decorators

PHP psr7 stream decorators for mime message part streams

4748.6M6](/packages/zbateson-stream-decorators)[zbateson/mail-mime-parser

MIME email message parser

53949.2M79](/packages/zbateson-mail-mime-parser)[symfony/mime

Allows manipulating MIME messages

2.8k668.8M909](/packages/symfony-mime)[php-mime-mail-parser/php-mime-mail-parser

A fully tested email parser for PHP 8.0+ (mailparse extension wrapper).

9979.6M27](/packages/php-mime-mail-parser-php-mime-mail-parser)[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M244](/packages/nette-mail)[goetas/to-swift-mime-parser

Parse a generic mail stream, and convert it to a SwiftMailer Message

1244.4k2](/packages/goetas-to-swift-mime-parser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
