for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DevOp\Core\Http;
use DevOp\Core\Http\Stream;
use Psr\Http\Message\StreamInterface;
use Interop\Http\Factory\StreamFactoryInterface;
class StreamFactory implements StreamFactoryInterface
{
/**
* @param string $content
* @return StreamInterface
*/
public function createStream($content = '')
$resource = fopen("php://temp", "w+b");
if (!is_resource($resource)) {
throw new \InvalidArgumentException('Error while creating PHP stream');
}
fwrite($resource, $content);
rewind($resource);
return $this->createStreamFromResource($resource);
* @param string $filename
* @param string $mode
public function createStreamFromFile($filename, $mode = 'r')
$resource = fopen($filename, $mode);
* @param resource $resource
public function createStreamFromResource($resource)
return new Stream($resource);