Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

vendor/symfony/mailer/Transport/AbstractHttpTransport.php line 31

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Mailer\Transport;
  11. use Psr\EventDispatcher\EventDispatcherInterface;
  12. use Psr\Log\LoggerInterface;
  13. use Symfony\Component\HttpClient\HttpClient;
  14. use Symfony\Component\Mailer\Exception\HttpTransportException;
  15. use Symfony\Component\Mailer\SentMessage;
  16. use Symfony\Contracts\HttpClient\HttpClientInterface;
  17. use Symfony\Contracts\HttpClient\ResponseInterface;
  18. /**
  19.  * @author Victor Bocharsky <victor@symfonycasts.com>
  20.  */
  21. abstract class AbstractHttpTransport extends AbstractTransport
  22. {
  23.     protected $host;
  24.     protected $port;
  25.     protected $client;
  26.     public function __construct(HttpClientInterface $client nullEventDispatcherInterface $dispatcher nullLoggerInterface $logger null)
  27.     {
  28.         $this->client $client;
  29.         if (null === $client) {
  30.             if (!class_exists(HttpClient::class)) {
  31.                 throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".'__CLASS__));
  32.             }
  33.             $this->client HttpClient::create();
  34.         }
  35.         parent::__construct($dispatcher$logger);
  36.     }
  37.     /**
  38.      * @return $this
  39.      */
  40.     public function setHost(?string $host)
  41.     {
  42.         $this->host $host;
  43.         return $this;
  44.     }
  45.     /**
  46.      * @return $this
  47.      */
  48.     public function setPort(?int $port)
  49.     {
  50.         $this->port $port;
  51.         return $this;
  52.     }
  53.     abstract protected function doSendHttp(SentMessage $message): ResponseInterface;
  54.     protected function doSend(SentMessage $message): void
  55.     {
  56.         $response null;
  57.         try {
  58.             $response $this->doSendHttp($message);
  59.             $message->appendDebug($response->getInfo('debug') ?? '');
  60.         } catch (HttpTransportException $e) {
  61.             $e->appendDebug($e->getResponse()->getInfo('debug') ?? '');
  62.             throw $e;
  63.         }
  64.     }
  65. }