TemplateCanNotBeExpanded.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * League.Uri (https://uri.thephpleague.com)
  4. *
  5. * (c) Ignace Nyamagana Butera <nyamsprod@gmail.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. declare(strict_types=1);
  11. namespace League\Uri\UriTemplate;
  12. use InvalidArgumentException;
  13. use League\Uri\Contracts\UriException;
  14. class TemplateCanNotBeExpanded extends InvalidArgumentException implements UriException
  15. {
  16. public readonly array $variablesNames;
  17. public function __construct(string $message = '', string ...$variableNames)
  18. {
  19. parent::__construct($message, 0, null);
  20. $this->variablesNames = $variableNames;
  21. }
  22. public static function dueToUnableToProcessValueListWithPrefix(string $variableName): self
  23. {
  24. return new self('The ":" modifier cannot be applied on "'.$variableName.'" since it is a list of values.', $variableName);
  25. }
  26. public static function dueToNestedListOfValue(string $variableName): self
  27. {
  28. return new self('The "'.$variableName.'" cannot be a nested list.', $variableName);
  29. }
  30. public static function dueToMissingVariables(string ...$variableNames): self
  31. {
  32. return new self('The following required variables are missing: `'.implode('`, `', $variableNames).'`.', ...$variableNames);
  33. }
  34. }