CoreFiles by mySites.guru
Psr18ClientDiscovery.php31 lines, 1,038 bytes, from wordpress-7.2-beta1.zip
Raw History Compare with 7.1-beta4
md5
384f76b25f1e07d78065e245d2f73991
sha1
884f15c7075d897a2d8c1da8adba3d59fa1fd568
sha256
12ea56ae41a37059d222695476fa1a77261b1ed7c7360ec0a73e3f75608d98ef
<?php

namespace WordPress\AiClientDependencies\Http\Discovery;

use WordPress\AiClientDependencies\Http\Discovery\Exception\DiscoveryFailedException;
use WordPress\AiClientDependencies\Http\Discovery\Exception\NotFoundException as RealNotFoundException;
use WordPress\AiClientDependencies\Psr\Http\Client\ClientInterface;
/**
 * Finds a PSR-18 HTTP Client.
 *
 * @author Tobias Nyholm <[email protected]>
 */
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);
    }
}

The same content is in 44 releases, WordPress 7.0-beta1 to 7.2-RC2. See them all, or every version of this file.