mirror of
https://github.com/danog/byte-stream.git
synced 2024-12-12 09:29:57 +01:00
19 lines
475 B
Markdown
19 lines
475 B
Markdown
---
|
|
title: InMemoryStream
|
|
permalink: /in-memory-stream
|
|
---
|
|
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());
|
|
```
|