vendor/sentry/sentry/src/Transport/DefaultTransportFactory.php line 58

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sentry\Transport;
  4. use Http\Message\MessageFactory as MessageFactoryInterface;
  5. use Psr\Log\LoggerInterface;
  6. use Sentry\HttpClient\HttpClientFactoryInterface;
  7. use Sentry\Options;
  8. /**
  9.  * This class is the default implementation of the {@see TransportFactoryInterface}
  10.  * interface.
  11.  */
  12. final class DefaultTransportFactory implements TransportFactoryInterface
  13. {
  14.     /**
  15.      * @var MessageFactoryInterface The PSR-7 message factory
  16.      */
  17.     private $messageFactory;
  18.     /**
  19.      * @var HttpClientFactoryInterface The factory to create the HTTP client
  20.      */
  21.     private $httpClientFactory;
  22.     /**
  23.      * @var LoggerInterface|null A PSR-3 logger
  24.      */
  25.     private $logger;
  26.     /**
  27.      * Constructor.
  28.      *
  29.      * @param MessageFactoryInterface    $messageFactory    The PSR-7 message factory
  30.      * @param HttpClientFactoryInterface $httpClientFactory The HTTP client factory
  31.      * @param LoggerInterface|null       $logger            A PSR-3 logger
  32.      */
  33.     public function __construct(MessageFactoryInterface $messageFactoryHttpClientFactoryInterface $httpClientFactory, ?LoggerInterface $logger null)
  34.     {
  35.         $this->messageFactory $messageFactory;
  36.         $this->httpClientFactory $httpClientFactory;
  37.         $this->logger $logger;
  38.     }
  39.     /**
  40.      * {@inheritdoc}
  41.      */
  42.     public function create(Options $options): TransportInterface
  43.     {
  44.         if (null === $options->getDsn(false)) {
  45.             return new NullTransport();
  46.         }
  47.         return new HttpTransport(
  48.             $options,
  49.             $this->httpClientFactory->create($options),
  50.             $this->messageFactory,
  51.             true,
  52.             false,
  53.             $this->logger
  54.         );
  55.     }
  56. }