vendor/php-http/discovery/src/MessageFactoryDiscovery.php line 24

Open in your IDE?
  1. <?php
  2. namespace Http\Discovery;
  3. use Http\Discovery\Exception\DiscoveryFailedException;
  4. use Http\Message\MessageFactory;
  5. /**
  6.  * Finds a Message Factory.
  7.  *
  8.  * @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
  9.  *
  10.  * @deprecated This will be removed in 2.0. Consider using Psr17FactoryDiscovery.
  11.  */
  12. final class MessageFactoryDiscovery extends ClassDiscovery
  13. {
  14.     /**
  15.      * Finds a Message Factory.
  16.      *
  17.      * @return MessageFactory
  18.      *
  19.      * @throws Exception\NotFoundException
  20.      */
  21.     public static function find()
  22.     {
  23.         try {
  24.             $messageFactory = static::findOneByType(MessageFactory::class);
  25.         } catch (DiscoveryFailedException $e) {
  26.             throw new NotFoundException('No message factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.'0$e);
  27.         }
  28.         return static::instantiateClass($messageFactory);
  29.     }
  30. }