| 1 |
<?php |
| 2 |
|
| 3 |
namespace Http\Discovery; |
| 4 |
|
| 5 |
use Http\Client\HttpAsyncClient; |
| 6 |
use Http\Discovery\Exception\DiscoveryFailedException; |
| 7 |
|
| 8 |
/** |
| 9 |
* Finds an HTTP Asynchronous Client. |
| 10 |
* |
| 11 |
* @author Joel Wurtz <joel.wurtz@gmail.com> |
| 12 |
*/ |
| 13 |
final class HttpAsyncClientDiscovery extends ClassDiscovery |
| 14 |
{ |
| 15 |
/** |
| 16 |
* Finds an HTTP Async Client. |
| 17 |
* |
| 18 |
* @return HttpAsyncClient |
| 19 |
* |
| 20 |
* @throws Exception\NotFoundException |
| 21 |
*/ |
| 22 |
public static function find() |
| 23 |
{ |
| 24 |
try { |
| 25 |
$asyncClient = static::findOneByType(HttpAsyncClient::class); |
| 26 |
} catch (DiscoveryFailedException $e) { |
| 27 |
throw new NotFoundException('No HTTPlug async clients found. Make sure to install a package providing "php-http/async-client-implementation". Example: "php-http/guzzle6-adapter".', 0, $e); |
| 28 |
} |
| 29 |
|
| 30 |
return static::instantiateClass($asyncClient); |
| 31 |
} |
| 32 |
} |
| 33 |
|