| 1 |
<?php |
| 2 |
|
| 3 |
namespace Http\Discovery; |
| 4 |
|
| 5 |
use Http\Discovery\Exception\DiscoveryFailedException; |
| 6 |
use Http\Discovery\Exception\NotFoundException as RealNotFoundException; |
| 7 |
use Psr\Http\Client\ClientInterface; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
final class Psr18ClientDiscovery extends ClassDiscovery |
| 15 |
{ |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
public static function find() |
| 24 |
{ |
| 25 |
try { |
| 26 |
$client = static::findOneByType(ClientInterface::class); |
| 27 |
} catch (DiscoveryFailedException $e) { |
| 28 |
throw new RealNotFoundException('No PSR-18 clients found. Make sure to install a package providing "psr/http-client-implementation". Example: "php-http/guzzle7-adapter".', 0, $e); |
| 29 |
} |
| 30 |
|
| 31 |
return static::instantiateClass($client); |
| 32 |
} |
| 33 |
} |