File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 2020 ],
2121 "require" : {
2222 "php" : " ^8.1 || ^8.2 || ^8.3 || ^8.4" ,
23- "illuminate/support" : " ^9.0 || ^10.0 || ^11.0 || ^12.0"
23+ "illuminate/support" : " ^9.0 || ^10.0 || ^11.0 || ^12.0" ,
24+ "ext-intl" : " *"
2425 },
2526 "require-dev" : {
2627 "phpunit/phpunit" : " ^9.5.10 || ^10.0 || ^11.0" ,
Original file line number Diff line number Diff line change 2020 *
2121 * Features:
2222 * - Lowercases all text (UTF-8 safe)
23- * - Optionally removes diacritics using PHP’s Normalizer (if available )
23+ * - Removes diacritics using PHP's intl extension (required )
2424 * - Strips all non-alphanumeric characters
25+ *
26+ * Requirements:
27+ * - The intl PHP extension must be installed for consistent normalization
2528 */
2629class Normalizer
2730{
@@ -44,11 +47,9 @@ public static function normalize(?string $v): ?string
4447 // Convert to lowercase (UTF-8 safe)
4548 $ s = mb_strtolower ($ v , 'UTF-8 ' );
4649
47- // Optionally remove diacritics if intl extension is available
48- if (class_exists (\Normalizer::class)) {
49- $ s = \Normalizer::normalize ($ s , \Normalizer::FORM_D );
50- $ s = preg_replace ('/\p{M}/u ' , '' , $ s ); // strip diacritics
51- }
50+ // Remove diacritics using intl extension
51+ $ s = \Normalizer::normalize ($ s , \Normalizer::FORM_D );
52+ $ s = preg_replace ('/\p{M}/u ' , '' , $ s ); // strip diacritics
5253
5354 // Retain only letters and digits
5455 $ s = preg_replace ('/[^a-z0-9]/u ' , '' , $ s );
You can’t perform that action at this time.
0 commit comments