From 4c035992a97b5cfab1597e346f5860bcfaf65fe9 Mon Sep 17 00:00:00 2001 From: faissaloux Date: Sat, 26 Oct 2024 14:02:10 +0100 Subject: [PATCH] fix arabic lowercase --- src/Investigator.php | 10 ++++++---- tests/Fixtures/returnsArrayOnlyLowercase.php | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Investigator.php b/src/Investigator.php index c0e115b..20f66db 100644 --- a/src/Investigator.php +++ b/src/Investigator.php @@ -18,17 +18,19 @@ private function notLowercasesIn(array $array): array $unwanted = []; foreach ($array as $word) { - if ($word === '') { + if (is_array($word)) { + array_push($unwanted, ...$this->notLowercasesIn($word)); + continue; } - if (is_array($word)) { - array_push($unwanted, ...$this->notLowercasesIn($word)); + $clean = preg_replace('/[^A-Za-z]/', '', $word); + if ($clean == '') { continue; } - if (! ctype_lower(preg_replace('/[^A-Za-z]/', '', $word))) { + if (! ctype_lower($clean)) { $unwanted[] = $word; } } diff --git a/tests/Fixtures/returnsArrayOnlyLowercase.php b/tests/Fixtures/returnsArrayOnlyLowercase.php index d956467..37715e1 100644 --- a/tests/Fixtures/returnsArrayOnlyLowercase.php +++ b/tests/Fixtures/returnsArrayOnlyLowercase.php @@ -13,4 +13,5 @@ 'lowercase', 'lower', 'case', + 'العربية', ];