6 use Psr\Http\Message\RequestFactoryInterface;
7 use Psr\Http\Message\ResponseFactoryInterface;
8 use Psr\Http\Message\ServerRequestFactoryInterface;
9 use Psr\Http\Message\StreamFactoryInterface;
10 use Psr\Http\Message\UploadedFileFactoryInterface;
11 use Psr\Http\Message\UriFactoryInterface;
20 private static function createException($type,
Exception $e)
22 return new \Http\Discovery\Exception\NotFoundException(
23 'No PSR-17 '.$type.
' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation',
37 $messageFactory = static::findOneByType(RequestFactoryInterface::class);
39 throw self::createException(
'request factory', $e);
42 return static::instantiateClass($messageFactory);
53 $messageFactory = static::findOneByType(ResponseFactoryInterface::class);
55 throw self::createException(
'response factory', $e);
58 return static::instantiateClass($messageFactory);
69 $messageFactory = static::findOneByType(ServerRequestFactoryInterface::class);
71 throw self::createException(
'server request factory', $e);
74 return static::instantiateClass($messageFactory);
85 $messageFactory = static::findOneByType(StreamFactoryInterface::class);
87 throw self::createException(
'stream factory', $e);
90 return static::instantiateClass($messageFactory);
101 $messageFactory = static::findOneByType(UploadedFileFactoryInterface::class);
103 throw self::createException(
'uploaded file factory', $e);
106 return static::instantiateClass($messageFactory);
117 $messageFactory = static::findOneByType(UriFactoryInterface::class);
119 throw self::createException(
'url factory', $e);
122 return static::instantiateClass($messageFactory);