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

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