vendor/symfony/mailer/Transport/AbstractTransportFactory.php line 28

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\Mailer\Exception\IncompleteDsnException;
  14. use Symfony\Contracts\HttpClient\HttpClientInterface;
  15. /**
  16.  * @author Konstantin Myakshin <molodchick@gmail.com>
  17.  */
  18. abstract class AbstractTransportFactory implements TransportFactoryInterface
  19. {
  20.     protected $dispatcher;
  21.     protected $client;
  22.     protected $logger;
  23.     public function __construct(EventDispatcherInterface $dispatcher nullHttpClientInterface $client nullLoggerInterface $logger null)
  24.     {
  25.         $this->dispatcher $dispatcher;
  26.         $this->client $client;
  27.         $this->logger $logger;
  28.     }
  29.     public function supports(Dsn $dsn): bool
  30.     {
  31.         return \in_array($dsn->getScheme(), $this->getSupportedSchemes());
  32.     }
  33.     abstract protected function getSupportedSchemes(): array;
  34.     protected function getUser(Dsn $dsn): string
  35.     {
  36.         $user $dsn->getUser();
  37.         if (null === $user) {
  38.             throw new IncompleteDsnException('User is not set.');
  39.         }
  40.         return $user;
  41.     }
  42.     protected function getPassword(Dsn $dsn): string
  43.     {
  44.         $password $dsn->getPassword();
  45.         if (null === $password) {
  46.             throw new IncompleteDsnException('Password is not set.');
  47.         }
  48.         return $password;
  49.     }
  50. }