NamespaceUri.php 595 B

12345678910111213141516171819202122232425
  1. <?php declare(strict_types = 1);
  2. namespace TheSeer\Tokenizer;
  3. class NamespaceUri {
  4. /** @var string */
  5. private $value;
  6. public function __construct(string $value) {
  7. $this->ensureValidUri($value);
  8. $this->value = $value;
  9. }
  10. public function asString(): string {
  11. return $this->value;
  12. }
  13. private function ensureValidUri($value): void {
  14. if (\strpos($value, ':') === false) {
  15. throw new NamespaceUriException(
  16. \sprintf("Namespace URI '%s' must contain at least one colon", $value)
  17. );
  18. }
  19. }
  20. }