| @@ 14-37 (lines=24) @@ | ||
| 11 | * |
|
| 12 | * @author Joel Wurtz <[email protected]> |
|
| 13 | */ |
|
| 14 | final class HttpAsyncClientDiscovery extends ClassDiscovery |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * Finds an HTTP Async Client. |
|
| 18 | * |
|
| 19 | * @return HttpAsyncClient |
|
| 20 | * |
|
| 21 | * @throws NotFoundException |
|
| 22 | */ |
|
| 23 | public static function find() |
|
| 24 | { |
|
| 25 | try { |
|
| 26 | $asyncClient = static::findOneByType(HttpAsyncClient::class); |
|
| 27 | ||
| 28 | return new $asyncClient(); |
|
| 29 | } catch (DiscoveryFailedException $e) { |
|
| 30 | throw new NotFoundException( |
|
| 31 | 'No HTTPlug async clients found. Make sure to install a package providing "php-http/async-client-implementation". Example: "php-http/guzzle6-adapter".', |
|
| 32 | 0, |
|
| 33 | $e |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 14-37 (lines=24) @@ | ||
| 11 | * |
|
| 12 | * @author Márk Sági-Kazár <[email protected]> |
|
| 13 | */ |
|
| 14 | final class HttpClientDiscovery extends ClassDiscovery |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * Finds an HTTP Client. |
|
| 18 | * |
|
| 19 | * @return HttpClient |
|
| 20 | * |
|
| 21 | * @throws NotFoundException |
|
| 22 | */ |
|
| 23 | public static function find() |
|
| 24 | { |
|
| 25 | try { |
|
| 26 | $client = static::findOneByType(HttpClient::class); |
|
| 27 | ||
| 28 | return new $client(); |
|
| 29 | } catch (DiscoveryFailedException $e) { |
|
| 30 | throw new NotFoundException( |
|
| 31 | 'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter".', |
|
| 32 | 0, |
|
| 33 | $e |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 14-37 (lines=24) @@ | ||
| 11 | * |
|
| 12 | * @author Márk Sági-Kazár <[email protected]> |
|
| 13 | */ |
|
| 14 | final class MessageFactoryDiscovery extends ClassDiscovery |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * Finds a Message Factory. |
|
| 18 | * |
|
| 19 | * @return MessageFactory |
|
| 20 | * |
|
| 21 | * @throws NotFoundException |
|
| 22 | */ |
|
| 23 | public static function find() |
|
| 24 | { |
|
| 25 | try { |
|
| 26 | $messageFactory = static::findOneByType(MessageFactory::class); |
|
| 27 | ||
| 28 | return new $messageFactory(); |
|
| 29 | } catch (DiscoveryFailedException $e) { |
|
| 30 | throw new NotFoundException( |
|
| 31 | 'No message factories found. To use Guzzle or Diactoros factories install php-http/message and the chosen message implementation.', |
|
| 32 | 0, |
|
| 33 | $e |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 14-37 (lines=24) @@ | ||
| 11 | * |
|
| 12 | * @author Михаил Красильников <[email protected]> |
|
| 13 | */ |
|
| 14 | final class StreamFactoryDiscovery extends ClassDiscovery |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * Finds a Stream Factory. |
|
| 18 | * |
|
| 19 | * @return StreamFactory |
|
| 20 | * |
|
| 21 | * @throws NotFoundException |
|
| 22 | */ |
|
| 23 | public static function find() |
|
| 24 | { |
|
| 25 | try { |
|
| 26 | $streamFactory = static::findOneByType(StreamFactory::class); |
|
| 27 | ||
| 28 | return new $streamFactory(); |
|
| 29 | } catch (DiscoveryFailedException $e) { |
|
| 30 | throw new NotFoundException( |
|
| 31 | 'No stream factories found. To use Guzzle or Diactoros factories install php-http/message and the chosen message implementation.', |
|
| 32 | 0, |
|
| 33 | $e |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 14-37 (lines=24) @@ | ||
| 11 | * |
|
| 12 | * @author David de Boer <[email protected]> |
|
| 13 | */ |
|
| 14 | final class UriFactoryDiscovery extends ClassDiscovery |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * Finds a URI Factory. |
|
| 18 | * |
|
| 19 | * @return UriFactory |
|
| 20 | * |
|
| 21 | * @throws NotFoundException |
|
| 22 | */ |
|
| 23 | public static function find() |
|
| 24 | { |
|
| 25 | try { |
|
| 26 | $uriFactory = static::findOneByType(UriFactory::class); |
|
| 27 | ||
| 28 | return new $uriFactory(); |
|
| 29 | } catch (DiscoveryFailedException $e) { |
|
| 30 | throw new NotFoundException( |
|
| 31 | 'No uri factories found. To use Guzzle or Diactoros factories install php-http/message and the chosen message implementation.', |
|
| 32 | 0, |
|
| 33 | $e |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||