$excludingWords * @param array $includingWords * @param array|null $languages * @return array */ public static function analyse(string $file, array $excludingWords = [], array $includingWords = [], $languages = null): array { $words = []; $profanitiesDir = __DIR__.'/Config/profanities'; $errors = []; if (str_contains($file, '/Config/profanities/')) { return []; } if (($profanitiesFiles = scandir($profanitiesDir)) === false) { return []; } $profanitiesFiles = array_diff($profanitiesFiles, ['.', '..']); if ($languages) { foreach ($languages as $lang) { $specificLanguage = "$profanitiesDir/$lang.php"; if (file_exists($specificLanguage)) { $words = array_merge( $words, include $specificLanguage ); } } } else { $words = include "$profanitiesDir/en.php"; } $words = array_merge($words, $includingWords); $words = array_diff($words, $excludingWords); $fileContents = (string) file_get_contents($file); $lines = explode("\n", $fileContents); $foundProfanity = []; foreach ($words as $word) { foreach ($lines as $lineNumber => $line) { $key = $lineNumber.'-'.$word; if (preg_match('/(?