[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/php-ai-client/third-party/Http/Discovery/ -> Psr18ClientDiscovery.php (source)

   1  <?php
   2  
   3  namespace WordPress\AiClientDependencies\Http\Discovery;
   4  
   5  use WordPress\AiClientDependencies\Http\Discovery\Exception\DiscoveryFailedException;
   6  use WordPress\AiClientDependencies\Http\Discovery\Exception\NotFoundException as RealNotFoundException;
   7  use WordPress\AiClientDependencies\Psr\Http\Client\ClientInterface;
   8  /**
   9   * Finds a PSR-18 HTTP Client.
  10   *
  11   * @author Tobias Nyholm <tobias.nyholm@gmail.com>
  12   */
  13  final class Psr18ClientDiscovery extends ClassDiscovery
  14  {
  15      /**
  16       * Finds a PSR-18 HTTP Client.
  17       *
  18       * @return ClientInterface
  19       *
  20       * @throws RealNotFoundException
  21       */
  22      public static function find()
  23      {
  24          try {
  25              $client = static::findOneByType(ClientInterface::class);
  26          } catch (DiscoveryFailedException $e) {
  27              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);
  28          }
  29          return static::instantiateClass($client);
  30      }
  31  }


Generated : Sat Jun 13 09:38:55 2026 Cross-referenced by PHPXref