本文整理汇总了PHP中Psr7Middlewares\Middleware::getStreamFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP Middleware::getStreamFactory方法的具体用法?PHP Middleware::getStreamFactory怎么用?PHP Middleware::getStreamFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr7Middlewares\Middleware
的用法示例。
在下文中一共展示了Middleware::getStreamFactory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createStream
/**
* Get the stream factory.
*
* @param string|StreamInterface $file Filename or stream it's replacing
* @param string $mode
*
* @return StreamInterface
*/
private static function createStream($file = 'php://temp', $mode = 'r+')
{
$factory = Middleware::getStreamFactory();
$replacing = null;
if ($file instanceof StreamInterface) {
$replacing = $file;
$file = 'php://temp';
}
if ($factory === null) {
if (class_exists('Zend\\Diactoros\\Stream')) {
return new \Zend\Diactoros\Stream($file, $mode);
}
throw new \RuntimeException('Unable to create a stream. No stream factory defined');
}
return call_user_func($factory, $file, $mode, $replacing);
}