| @@ 12-33 (lines=22) @@ | ||
| 9 | * |
|
| 10 | * @author Márk Sági-Kazár <[email protected]> |
|
| 11 | */ |
|
| 12 | final class MessageFactoryDiscovery extends ClassDiscovery |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * Finds a Message Factory. |
|
| 16 | * |
|
| 17 | * @return MessageFactory |
|
| 18 | */ |
|
| 19 | public static function find() |
|
| 20 | { |
|
| 21 | try { |
|
| 22 | $messageFactory = static::findOneByType('Http\Message\MessageFactory'); |
|
| 23 | ||
| 24 | return new $messageFactory(); |
|
| 25 | } catch (NotFoundException $e) { |
|
| 26 | throw new NotFoundException( |
|
| 27 | 'No factories found. Install php-http/message to use Guzzle or Diactoros factories.', |
|
| 28 | 0, |
|
| 29 | $e |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||
| @@ 12-33 (lines=22) @@ | ||
| 9 | * |
|
| 10 | * @author Михаил Красильников <[email protected]> |
|
| 11 | */ |
|
| 12 | final class StreamFactoryDiscovery extends ClassDiscovery |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * Finds a Stream Factory. |
|
| 16 | * |
|
| 17 | * @return StreamFactory |
|
| 18 | */ |
|
| 19 | public static function find() |
|
| 20 | { |
|
| 21 | try { |
|
| 22 | $streamFactory = static::findOneByType('Http\Message\StreamFactory'); |
|
| 23 | ||
| 24 | return new $streamFactory(); |
|
| 25 | } catch (NotFoundException $e) { |
|
| 26 | throw new NotFoundException( |
|
| 27 | 'No factories found. Install php-http/message to use Guzzle or Diactoros factories.', |
|
| 28 | 0, |
|
| 29 | $e |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||
| @@ 12-33 (lines=22) @@ | ||
| 9 | * |
|
| 10 | * @author David de Boer <[email protected]> |
|
| 11 | */ |
|
| 12 | final class UriFactoryDiscovery extends ClassDiscovery |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * Finds a URI Factory. |
|
| 16 | * |
|
| 17 | * @return UriFactory |
|
| 18 | */ |
|
| 19 | public static function find() |
|
| 20 | { |
|
| 21 | try { |
|
| 22 | $uriFactory = static::findOneByType('Http\Message\UriFactory'); |
|
| 23 | ||
| 24 | return new $uriFactory(); |
|
| 25 | } catch (NotFoundException $e) { |
|
| 26 | throw new NotFoundException( |
|
| 27 | 'No factories found. Install php-http/message to use Guzzle or Diactoros factories.', |
|
| 28 | 0, |
|
| 29 | $e |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||