26
26
*/
27
27
class Client implements HttpClient, HttpAsyncClient
28
28
{
29
- /**
30
- * @access private
31
- */
32
- const DEPENDENCY_MSG = 'You should either provide $%s argument or install "php-http/discovery" ' ;
33
-
34
29
/**
35
30
* cURL options
36
31
*
@@ -73,7 +68,6 @@ class Client implements HttpClient, HttpAsyncClient
73
68
* @param StreamFactory|null $streamFactory HTTP Stream factory
74
69
* @param array $options cURL options (see http://php.net/curl_setopt)
75
70
*
76
- * @throws \LogicException If some factory not provided and php-http/discovery not installed
77
71
* @throws \Http\Discovery\Exception\NotFoundException If factory discovery failed.
78
72
*
79
73
* @since 1.0
@@ -83,22 +77,8 @@ public function __construct(
83
77
StreamFactory $ streamFactory = null ,
84
78
array $ options = []
85
79
) {
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 ();
102
82
$ this ->options = $ options ;
103
83
}
104
84
0 commit comments