Open Journal Systems  3.3.0
SlimStreamFactory.php
1 <?php
2 
4 
7 use Slim\Http\Stream;
8 
14 final class SlimStreamFactory 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  $resource = fopen('php://memory', 'r+');
30  $stream = new Stream($resource);
31  if (null !== $body && '' !== $body) {
32  $stream->write((string) $body);
33  }
34 
35  return $stream;
36  }
37 }
Psr\Http\Message\StreamInterface
Definition: vendor/psr/http-message/src/StreamInterface.php:12
Http\Message\StreamFactory
Definition: DiactorosStreamFactory.php:3
Http\Message\StreamFactory
Definition: StreamFactory.php:12
Http\Message\StreamFactory\SlimStreamFactory
Definition: SlimStreamFactory.php:14
Http\Message\StreamFactory\SlimStreamFactory\createStream
createStream($body=null)
Definition: SlimStreamFactory.php:19