NullTransportFactory.php 917 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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\UnsupportedSchemeException;
  12. /**
  13. * @author Fabien Potencier <fabien@symfony.com>
  14. *
  15. * @experimental in 5.1
  16. */
  17. final class NullTransportFactory extends AbstractTransportFactory
  18. {
  19. /**
  20. * @return NullTransport
  21. */
  22. public function create(Dsn $dsn): TransportInterface
  23. {
  24. if ('null' === $dsn->getScheme()) {
  25. return new NullTransport($this->dispatcher);
  26. }
  27. throw new UnsupportedSchemeException($dsn, 'null', $this->getSupportedSchemes());
  28. }
  29. protected function getSupportedSchemes(): array
  30. {
  31. return ['null'];
  32. }
  33. }