2626 */
2727class Client implements HttpClient, HttpAsyncClient
2828{
29- /**
30- * @access private
31- */
32- const DEPENDENCY_MSG = 'You should either provide $%s argument or install "php-http/discovery" ' ;
33-
3429 /**
3530 * cURL options
3631 *
@@ -73,7 +68,6 @@ class Client implements HttpClient, HttpAsyncClient
7368 * @param StreamFactory|null $streamFactory HTTP Stream factory
7469 * @param array $options cURL options (see http://php.net/curl_setopt)
7570 *
76- * @throws \LogicException If some factory not provided and php-http/discovery not installed
7771 * @throws \Http\Discovery\Exception\NotFoundException If factory discovery failed.
7872 *
7973 * @since 1.0
@@ -83,22 +77,8 @@ public function __construct(
8377 StreamFactory $ streamFactory = null ,
8478 array $ options = []
8579 ) {
86- if (null === $ messageFactory ) {
87- if (!class_exists (MessageFactoryDiscovery::class)) {
88- throw new \LogicException (sprintf (self ::DEPENDENCY_MSG , 'messageFactory ' ));
89- }
90- $ messageFactory = MessageFactoryDiscovery::find ();
91- }
92- $ this ->messageFactory = $ messageFactory ;
93-
94- if (null === $ streamFactory ) {
95- if (!class_exists (StreamFactoryDiscovery::class)) {
96- throw new \LogicException (sprintf (self ::DEPENDENCY_MSG , 'streamFactory ' ));
97- }
98- $ streamFactory = StreamFactoryDiscovery::find ();
99- }
100- $ this ->streamFactory = $ streamFactory ;
101-
80+ $ this ->messageFactory = $ messageFactory ?: MessageFactoryDiscovery::find ();
81+ $ this ->streamFactory = $ streamFactory ?: StreamFactoryDiscovery::find ();
10282 $ this ->options = $ options ;
10383 }
10484
0 commit comments