1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-11-27 12:24:48 +01:00
byte-stream/docs/in-memory-stream.md

19 lines
475 B
Markdown
Raw Normal View History

2017-05-28 19:24:13 +02:00
---
title: InMemoryStream
permalink: /in-memory-stream
---
2017-05-22 10:20:55 +02:00
An `InMemoryStream` allows creating an `InputStream` from a single known string chunk. This is helpful if the complete stream contents are already known.
```php
$inputStream = new InMemoryStream("foobar");
```
It also allows creating a stream without any chunks by passing `null` as chunk.
```php
$inputStream = new InMemoryStream;
// The stream ends immediately
assert(null === yield $inputStream->read());
```