summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Common/Http/Psr/Message/MessageFactory.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/open-telemetry/sdk/Common/Http/Psr/Message/MessageFactory.php')
-rw-r--r--vendor/open-telemetry/sdk/Common/Http/Psr/Message/MessageFactory.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Common/Http/Psr/Message/MessageFactory.php b/vendor/open-telemetry/sdk/Common/Http/Psr/Message/MessageFactory.php
new file mode 100644
index 000000000..8e99d64c0
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Common/Http/Psr/Message/MessageFactory.php
@@ -0,0 +1,52 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Common\Http\Psr\Message;
+
+use Psr\Http\Message\RequestFactoryInterface;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseFactoryInterface;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestFactoryInterface;
+use Psr\Http\Message\ServerRequestInterface;
+
+final class MessageFactory implements MessageFactoryInterface
+{
+ private RequestFactoryInterface $requestFactory;
+ private ResponseFactoryInterface $responseFactory;
+ private ServerRequestFactoryInterface $serverRequestFactory;
+
+ public function __construct(
+ RequestFactoryInterface $requestFactory,
+ ResponseFactoryInterface $responseFactory,
+ ServerRequestFactoryInterface $serverRequestFactory
+ ) {
+ $this->requestFactory = $requestFactory;
+ $this->responseFactory = $responseFactory;
+ $this->serverRequestFactory = $serverRequestFactory;
+ }
+
+ public static function create(
+ RequestFactoryInterface $requestFactory,
+ ResponseFactoryInterface $responseFactory,
+ ServerRequestFactoryInterface $serverRequestFactory
+ ): self {
+ return new self($requestFactory, $responseFactory, $serverRequestFactory);
+ }
+
+ public function createRequest(string $method, $uri): RequestInterface
+ {
+ return $this->requestFactory->createRequest($method, $uri);
+ }
+
+ public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
+ {
+ return $this->responseFactory->createResponse($code, $reasonPhrase);
+ }
+
+ public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
+ {
+ return $this->serverRequestFactory->createServerRequest($method, $uri, $serverParams);
+ }
+}