4
4
5
5
namespace Setono \MetaConversionsApi \Client ;
6
6
7
- use Buzz \Client \Curl ;
8
7
use FacebookAds \ApiConfig ;
9
- use Nyholm \Psr7 \Factory \Psr17Factory ;
8
+ use Http \Discovery \Psr17FactoryDiscovery ;
9
+ use Http \Discovery \Psr18ClientDiscovery ;
10
10
use Psr \Http \Client \ClientInterface as HttpClientInterface ;
11
11
use Psr \Http \Message \RequestFactoryInterface ;
12
12
use Psr \Http \Message \ResponseFactoryInterface ;
@@ -76,14 +76,7 @@ public function sendEvent(Event $event): void
76
76
private function getHttpClient (): HttpClientInterface
77
77
{
78
78
if (null === $ this ->httpClient ) {
79
- if (!class_exists (Curl::class)) {
80
- throw ClientException::missingDependency (
81
- Curl::class,
82
- sprintf ('Either set the http client with %s or run composer require kriswallsmith/buzz ' , self ::class . '::setHttpClient() ' ),
83
- );
84
- }
85
-
86
- $ this ->httpClient = new Curl ($ this ->getResponseFactory ());
79
+ $ this ->httpClient = Psr18ClientDiscovery::find ();
87
80
}
88
81
89
82
return $ this ->httpClient ;
@@ -97,14 +90,7 @@ public function setHttpClient(HttpClientInterface $httpClient): void
97
90
private function getRequestFactory (): RequestFactoryInterface
98
91
{
99
92
if (null === $ this ->requestFactory ) {
100
- if (!class_exists (Psr17Factory::class)) {
101
- throw ClientException::missingDependency (
102
- Psr17Factory::class,
103
- sprintf ('Either set the request factory with %s or run composer require nyholm/psr7 ' , self ::class . '::setRequestFactory() ' ),
104
- );
105
- }
106
-
107
- $ this ->requestFactory = new Psr17Factory ();
93
+ $ this ->requestFactory = Psr17FactoryDiscovery::findRequestFactory ();
108
94
}
109
95
110
96
return $ this ->requestFactory ;
@@ -118,14 +104,7 @@ public function setRequestFactory(RequestFactoryInterface $requestFactory): void
118
104
private function getResponseFactory (): ResponseFactoryInterface
119
105
{
120
106
if (null === $ this ->responseFactory ) {
121
- if (!class_exists (Psr17Factory::class)) {
122
- throw ClientException::missingDependency (
123
- Psr17Factory::class,
124
- sprintf ('Either set the response factory with %s or run composer require nyholm/psr7 ' , self ::class . '::setResponseFactory() ' ),
125
- );
126
- }
127
-
128
- $ this ->responseFactory = new Psr17Factory ();
107
+ $ this ->responseFactory = Psr17FactoryDiscovery::findResponseFactory ();
129
108
}
130
109
131
110
return $ this ->responseFactory ;
@@ -139,14 +118,7 @@ public function setResponseFactory(ResponseFactoryInterface $responseFactory): v
139
118
private function getStreamFactory (): StreamFactoryInterface
140
119
{
141
120
if (null === $ this ->streamFactory ) {
142
- if (!class_exists (Psr17Factory::class)) {
143
- throw ClientException::missingDependency (
144
- Psr17Factory::class,
145
- sprintf ('Either set the stream factory with %s or run composer require nyholm/psr7 ' , self ::class . '::setStreamFactory() ' ),
146
- );
147
- }
148
-
149
- $ this ->streamFactory = new Psr17Factory ();
121
+ $ this ->streamFactory = Psr17FactoryDiscovery::findStreamFactory ();
150
122
}
151
123
152
124
return $ this ->streamFactory ;
0 commit comments