Open Journal Systems  3.3.0
DiactorosStreamFactory.php
1 <?php
2 
4 
7 use Zend\Diactoros\Stream;
8 
14 final class DiactorosStreamFactory implements StreamFactory
15 {
19  public function createStream($body = null)
20  {
21  if ($body instanceof StreamInterface) {
22  return $body;
23  }
24 
25  if (is_resource($body)) {
26  return new Stream($body);
27  }
28 
29  $stream = new Stream('php://memory', 'rw');
30  if (null !== $body && '' !== $body) {
31  $stream->write((string) $body);
32  }
33 
34  return $stream;
35  }
36 }
Psr\Http\Message\StreamInterface
Definition: vendor/psr/http-message/src/StreamInterface.php:12
Http\Message\StreamFactory\DiactorosStreamFactory
Definition: DiactorosStreamFactory.php:14
Http\Message\StreamFactory
Definition: DiactorosStreamFactory.php:3
Http\Message\StreamFactory
Definition: StreamFactory.php:12
Http\Message\StreamFactory\DiactorosStreamFactory\createStream
createStream($body=null)
Definition: DiactorosStreamFactory.php:19