chapterUrlFormat = $chapterUrlFormat; $this->validateUrlFormat($chapterUrlFormat); } public function getChapterUrl(string $mangaTitle, float $chapterNumber): string { $placeholders = [ '{chapterNumber}' => $chapterNumber, '{slug}' => $mangaTitle, ]; return str_replace(array_keys($placeholders), array_values($placeholders), $this->chapterUrlFormat); } private function validateUrlFormat(string $format): void { if (!str_contains($format, '{slug}')) { throw new InvalidArgumentException("The URL format must contain both {slug} and {chapterNumber} placeholders."); } } }