type = $type; $this->index = $index; $this->string = $string; } public function __toString(): string { return $this->string; } public function getType(): int { return $this->type; } public function getIndex(): int { return $this->index; } public function getElementName(): ?string { if ($this->getType() !== self::TYPE_ELEMENT) { return null; } if (!preg_match('#^<(?P[a-z][a-z0-9-]*)\b#i', $this->string, $matches)) { return null; } return $matches['name']; } }