Psr7Middlewares\Middleware::getStreamFactory PHP Method

getStreamFactory() public static method

Set the stream factory used by some middlewares.
public static getStreamFactory ( )
    public static function getStreamFactory()
    {
        return self::$streamFactory;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * 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);
 }