file = $file; $this->title = $title; $this->url = $url; $this->titles = $titles; $this->validateAttributes($attributes); $this->attributes = $attributes; } public function getFile(): ?string { return $this->file; } public function getTitle(): ?string { return $this->title; } public function getUrl(): ?string { return $this->url; } /** @return string[][]|string[][][] */ public function getTitles(): array { return $this->titles; } /** @return string[] */ public function getAttributes(): array { return $this->attributes; } /** @param string[] $attributes */ private function validateAttributes(array $attributes): void { foreach ($attributes as $attribute => $value) { if (! is_string($attribute) || $attribute === 'href' || ! (bool) preg_match('/^[a-zA-Z\_][\w\.\-_]+$/', $attribute)) { throw new RuntimeException(sprintf('Attribute with name "%s" is not allowed', $attribute)); } } } }