vendor/symfony/notifier/Transport/AbstractTransportFactory.php line 27

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