Skip to content

Commit 1f42583

Browse files
committed
feat(legacy-create-video): [golden-master] 🔵 refactor sanitizeTitle
1 parent 8316ffe commit 1f42583

File tree

1 file changed

+11
-8
lines changed
  • exercises/legacy_create_video/solutions/codely_php-symfony_golden-master/src/AppBundle/Application

1 file changed

+11
-8
lines changed

exercises/legacy_create_video/solutions/codely_php-symfony_golden-master/src/AppBundle/Application/VideoCreator.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ public function createVideo($title, $url, $courseId): array
2727

2828
private function sanitizeTitle(string $title): string
2929
{
30-
if (strpos($title, "hexagonal")) {
31-
$title = str_replace("hexagonal", "Hexagonal", $title);
32-
}
33-
if (strpos($title, "solid")) {
34-
$title = str_replace("solid", "SOLID", $title);
35-
}
36-
if (strpos($title, "tdd")) {
37-
$title = str_replace("tdd", "TDD", $title);
30+
$replacements = [
31+
"hexagonal" => "Hexagonal",
32+
"solid" => "SOLID",
33+
"tdd" => "TDD",
34+
];
35+
36+
foreach ($replacements as $search => $replace) {
37+
if (strpos($title, $search)) {
38+
$title = str_replace($search, $replace, $title);
39+
}
3840
}
41+
3942
return $title;
4043
}
4144
}

0 commit comments

Comments
 (0)