ProviderNotRegistered.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the Geocoder package.
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * @license MIT License
  9. */
  10. namespace Geocoder\Exception;
  11. /**
  12. * @author William Durand <william.durand1@gmail.com>
  13. */
  14. final class ProviderNotRegistered extends \RuntimeException implements Exception
  15. {
  16. /**
  17. * @param string $providerName
  18. * @param array $registeredProviders
  19. */
  20. public static function create(string $providerName, array $registeredProviders = [])
  21. {
  22. return new self(sprintf(
  23. 'Provider "%s" is not registered, so you cannot use it. Did you forget to register it or made a typo?%s',
  24. $providerName,
  25. 0 == count($registeredProviders) ? '' : sprintf(' Registered providers are: %s.', implode(', ', $registeredProviders))
  26. ));
  27. }
  28. public static function noProviderRegistered()
  29. {
  30. return new self('No provider registered.');
  31. }
  32. }