vendor/php-http/discovery/src/Psr18ClientDiscovery.php line 22

Open in your IDE?
  1. <?php
  2. namespace Http\Discovery;
  3. use Http\Discovery\Exception\DiscoveryFailedException;
  4. use Psr\Http\Client\ClientInterface;
  5. /**
  6.  * Finds a PSR-18 HTTP Client.
  7.  *
  8.  * @author Tobias Nyholm <tobias.nyholm@gmail.com>
  9.  */
  10. final class Psr18ClientDiscovery extends ClassDiscovery
  11. {
  12.     /**
  13.      * Finds a PSR-18 HTTP Client.
  14.      *
  15.      * @return ClientInterface
  16.      *
  17.      * @throws Exception\NotFoundException
  18.      */
  19.     public static function find()
  20.     {
  21.         try {
  22.             $client = static::findOneByType(ClientInterface::class);
  23.         } catch (DiscoveryFailedException $e) {
  24.             throw new \Http\Discovery\Exception\NotFoundException('No PSR-18 clients found. Make sure to install a package providing "psr/http-client-implementation". Example: "php-http/guzzle7-adapter".'0$e);
  25.         }
  26.         return static::instantiateClass($client);
  27.     }
  28. }