Skip to content

Commit a7d3605

Browse files
authored
Refactor validateLanguages() (#71)
`validateLanguages()` param is either null or array, so we don't need to check if it's an array, plus I made some renaming.
1 parent 013e4e7 commit a7d3605

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Plugin.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,22 @@ public function __construct(
5959
/**
6060
* Validates that the specified languages exist in the profanities directory.
6161
*
62-
* @param string|array<string>|null $language
62+
* @param array<string>|null $languages
6363
* @return array<int, string> List of languages that don't exist
6464
*/
65-
private function validateLanguages($language): array
65+
private function validateLanguages($languages): array
6666
{
67-
if ($language === null) {
67+
if ($languages === null) {
6868
return [];
6969
}
7070

7171
$profanitiesDir = __DIR__.'/Config/profanities';
72-
$languages = is_string($language) ? [$language] : $language;
7372
$invalidLanguages = [];
7473

75-
foreach ($languages as $lang) {
76-
$specificLanguage = "$profanitiesDir/$lang.php";
74+
foreach ($languages as $language) {
75+
$specificLanguage = "$profanitiesDir/$language.php";
7776
if (! file_exists($specificLanguage)) {
78-
$invalidLanguages[] = $lang;
77+
$invalidLanguages[] = $language;
7978
}
8079
}
8180

0 commit comments

Comments
 (0)