NullProviderFactory.php 843 B

12345678910111213141516171819202122232425262728293031323334
  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\Translation\Provider;
  11. use Symfony\Component\Translation\Exception\UnsupportedSchemeException;
  12. /**
  13. * @author Mathieu Santostefano <msantostefano@protonmail.com>
  14. */
  15. final class NullProviderFactory extends AbstractProviderFactory
  16. {
  17. public function create(Dsn $dsn): ProviderInterface
  18. {
  19. if ('null' === $dsn->getScheme()) {
  20. return new NullProvider();
  21. }
  22. throw new UnsupportedSchemeException($dsn, 'null', $this->getSupportedSchemes());
  23. }
  24. protected function getSupportedSchemes(): array
  25. {
  26. return ['null'];
  27. }
  28. }