Debian Codegraph @

lib/3rdParty/composer/php-http/discovery/src/Psr18ClientDiscovery.php

raw symbols SCIP
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 * Finds a PSR-18 HTTP Client.
11 *
12 * @author Tobias Nyholm <[email protected]>
13 */
14 final class Psr18ClientDiscovery extends ClassDiscovery
15 {
16 /**
17 * Finds a PSR-18 HTTP Client.
18 *
19 * @return ClientInterface
20 *
21 * @throws RealNotFoundException
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 }