* @author Alexander M. Turek */ final class PsrServerRequestResolver implements ArgumentValueResolverInterface { private const SUPPORTED_TYPES = [ ServerRequestInterface::class => true, RequestInterface::class => true, MessageInterface::class => true, ]; private $httpMessageFactory; public function __construct(HttpMessageFactoryInterface $httpMessageFactory) { $this->httpMessageFactory = $httpMessageFactory; } /** * {@inheritdoc} */ public function supports(Request $request, ArgumentMetadata $argument): bool { return self::SUPPORTED_TYPES[$argument->getType()] ?? false; } /** * {@inheritdoc} */ public function resolve(Request $request, ArgumentMetadata $argument): \Traversable { yield $this->httpMessageFactory->createRequest($request); } }