| 1 |
<?php |
| 2 |
|
| 3 |
namespace Http\Discovery; |
| 4 |
|
| 5 |
use Http\Discovery\Exception\DiscoveryFailedException; |
| 6 |
use Http\Message\UriFactory; |
| 7 |
|
| 8 |
/** |
| 9 |
* Finds a URI Factory. |
| 10 |
* |
| 11 |
* @author David de Boer <david@ddeboer.nl> |
| 12 |
* |
| 13 |
* @deprecated This will be removed in 2.0. Consider using Psr17FactoryDiscovery. |
| 14 |
*/ |
| 15 |
final class UriFactoryDiscovery extends ClassDiscovery |
| 16 |
{ |
| 17 |
/** |
| 18 |
* Finds a URI Factory. |
| 19 |
* |
| 20 |
* @return UriFactory |
| 21 |
* |
| 22 |
* @throws Exception\NotFoundException |
| 23 |
*/ |
| 24 |
public static function find() |
| 25 |
{ |
| 26 |
try { |
| 27 |
$uriFactory = static::findOneByType(UriFactory::class); |
| 28 |
} catch (DiscoveryFailedException $e) { |
| 29 |
throw new NotFoundException('No uri factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.', 0, $e); |
| 30 |
} |
| 31 |
|
| 32 |
return static::instantiateClass($uriFactory); |
| 33 |
} |
| 34 |
} |
| 35 |
|