Finds a PSR-18 HTTP Client.
Methods
| Name | Description |
|---|---|
| Psr18ClientDiscovery::find | Finds a PSR-18 HTTP Client. |
Source
final class Psr18ClientDiscovery extends ClassDiscovery
{
/**
* Finds a PSR-18 HTTP Client.
*
* @return ClientInterface
*
* @throws RealNotFoundException
*/
public static function find()
{
try {
$client = static::findOneByType(ClientInterface::class);
} catch (DiscoveryFailedException $e) {
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);
}
return static::instantiateClass($client);
}
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.