1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Common\Adapter\HttpDiscovery;
use Http\Discovery\Psr17FactoryDiscovery;
use OpenTelemetry\SDK\Common\Http\Psr\Message\FactoryResolverInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
final class MessageFactoryResolver implements FactoryResolverInterface
{
private ?RequestFactoryInterface $requestFactory;
private ?ResponseFactoryInterface $responseFactory;
private ?ServerRequestFactoryInterface $serverRequestFactory;
private ?StreamFactoryInterface $streamFactory;
private ?UploadedFileFactoryInterface $uploadedFileFactory;
private ?UriFactoryInterface $uriFactory;
public function __construct(
?RequestFactoryInterface $requestFactory = null,
?ResponseFactoryInterface $responseFactory = null,
?ServerRequestFactoryInterface $serverRequestFactory = null,
?StreamFactoryInterface $streamFactory = null,
?UploadedFileFactoryInterface $uploadedFileFactory = null,
?UriFactoryInterface $uriFactory = null
) {
$this->requestFactory = $requestFactory;
$this->responseFactory = $responseFactory;
$this->serverRequestFactory = $serverRequestFactory;
$this->streamFactory = $streamFactory;
$this->uploadedFileFactory = $uploadedFileFactory;
$this->uriFactory = $uriFactory;
}
public static function create(
?RequestFactoryInterface $requestFactory = null,
?ResponseFactoryInterface $responseFactory = null,
?ServerRequestFactoryInterface $serverRequestFactory = null,
?StreamFactoryInterface $streamFactory = null,
?UploadedFileFactoryInterface $uploadedFileFactory = null,
?UriFactoryInterface $uriFactory = null
): self {
return new self(
$requestFactory,
$responseFactory,
$serverRequestFactory,
$streamFactory,
$uploadedFileFactory,
$uriFactory
);
}
public function resolveRequestFactory(): RequestFactoryInterface
{
return $this->requestFactory ??= Psr17FactoryDiscovery::findRequestFactory();
}
public function resolveResponseFactory(): ResponseFactoryInterface
{
return $this->responseFactory ??= Psr17FactoryDiscovery::findResponseFactory();
}
public function resolveServerRequestFactory(): ServerRequestFactoryInterface
{
return $this->serverRequestFactory ??= Psr17FactoryDiscovery::findServerRequestFactory();
}
public function resolveStreamFactory(): StreamFactoryInterface
{
return $this->streamFactory ??= Psr17FactoryDiscovery::findStreamFactory();
}
public function resolveUploadedFileFactory(): UploadedFileFactoryInterface
{
return $this->uploadedFileFactory ??= Psr17FactoryDiscovery::findUploadedFileFactory();
}
public function resolveUriFactory(): UriFactoryInterface
{
return $this->uriFactory ??= Psr17FactoryDiscovery::findUriFactory();
}
}
|