*/ final class ProtectedResourceMetadataHandler implements RequestHandlerInterface { private ResponseFactoryInterface $responseFactory; private StreamFactoryInterface $streamFactory; public function __construct( private readonly ProtectedResourceMetadata $metadata, ?ResponseFactoryInterface $responseFactory = null, ?StreamFactoryInterface $streamFactory = null, ) { $this->responseFactory = $responseFactory ?? Psr17FactoryDiscovery::findResponseFactory(); $this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory(); } public function handle(ServerRequestInterface $request): ResponseInterface { return $this->responseFactory ->createResponse(200) ->withHeader('Content-Type', 'application/json') ->withBody($this->streamFactory->createStream(json_encode($this->metadata, \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES))); } }