1515 See the License for the specific language governing permissions and
1616 limitations under the License.
1717*/
18-
19- use Http \ Client \ HttpClient ;
18+ use GuzzleHttp \ Client ;
19+ use GuzzleHttp \ ClientInterface ;
2020
2121/**
2222 * Class Config
@@ -44,7 +44,6 @@ class Config {
4444 */
4545 public $ Datacenter = '' ;
4646
47-
4847 /**
4948 * HTTP authentication, if used
5049 *
@@ -59,7 +58,6 @@ class Config {
5958 */
6059 public $ WaitTime = 0 ;
6160
62-
6361 /**
6462 * ACL token to use by default
6563 *
@@ -84,7 +82,7 @@ class Config {
8482 /**
8583 * Your HttpClient of choice.
8684 *
87- * @var \Http\Client\HttpClient
85+ * @var \GuzzleHttp\ClientInterface
8886 */
8987 public $ HttpClient = null ;
9088
@@ -103,16 +101,14 @@ public function __construct(array $config = []) {
103101 }
104102
105103 /**
106- * Construct a configuration object from Environment Variables while using a specific HTTP Client
104+ * Construct a configuration object from Environment Variables and use bare guzzle client instance
107105 *
108- * @param \Http\Client\HttpClient $client
109106 * @return \DCarbone\PHPConsulAPI\Config
110107 */
111- public static function newDefaultConfigWithClient ( HttpClient $ client ) {
108+ public static function newDefaultConfig ( ) {
112109 $ conf = new static ([
113110 'Address ' => '127.0.0.1:8500 ' ,
114111 'Scheme ' => 'http ' ,
115- 'HttpClient ' => $ client
116112 ]);
117113
118114 $ envParams = static ::getEnvironmentConfig ();
@@ -136,32 +132,9 @@ public static function newDefaultConfigWithClient(HttpClient $client) {
136132 $ conf ->setInsecureSkipVerify (false );
137133 }
138134
139- return $ conf ;
140- }
141-
142- /**
143- * Construct a configuration object from Environment Variables and also attempt to locate an HTTP Client ot use.
144- *
145- * @return \DCarbone\PHPConsulAPI\Config
146- */
147- public static function newDefaultConfig () {
148- static $ knownClients = [
149- '\\Http \\Client \\Curl \\Client ' ,
150- '\\Http \\Adapter \\Guzzle6 \\Client ' ,
151- '\\Http \\Adapter \\Buzz \\Client ' ,
152- '\\Http \\Adapter \\React \\Client ' ,
153- ];
154-
155- foreach ($ knownClients as $ clientClass ) {
156- if (class_exists ($ clientClass , true )) {
157- return static ::newDefaultConfigWithClient (new $ clientClass );
158- }
159- }
135+ $ conf ->setHttpClient (new Client ());
160136
161- throw new \RuntimeException (sprintf (
162- '%s - Unable to determine HttpClient to use for default config ' ,
163- get_called_class ()
164- ));
137+ return $ conf ;
165138 }
166139
167140 /**
@@ -297,17 +270,17 @@ public function setHttpAuth($HttpAuth) {
297270 }
298271
299272 /**
300- * @return \Http\Client\HttpClient
273+ * @return \GuzzleHttp\ClientInterface
301274 */
302275 public function getHttpClient () {
303276 return $ this ->HttpClient ;
304277 }
305278
306279 /**
307- * @param \Http\Client\HttpClient $HttpClient
280+ * @param \GuzzleHttp\ClientInterface $HttpClient
308281 * @return \DCarbone\PHPConsulAPI\Config
309282 */
310- public function setHttpClient (HttpClient $ HttpClient ) {
283+ public function setHttpClient (ClientInterface $ HttpClient ) {
311284 $ this ->HttpClient = $ HttpClient ;
312285 return $ this ;
313286 }
0 commit comments