File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 13
13
14
14
/**
15
15
* @author Pierre Ambroise <[email protected] >
16
+ * @author Alexander Schranz <[email protected] >
16
17
*
17
18
* @internal
18
19
*/
@@ -33,4 +34,8 @@ public static function get_exception_handler(): ?callable
33
34
34
35
return $ handler ;
35
36
}
37
+
38
+ public static function locale_is_right_to_left (string $ locale ): bool {
39
+ return (bool ) preg_match ('/^(?:ar|he|fa|ur|ps|sd|ug|ckb|yi|dv|ku_arab|ku-arab)(?:[_-].*)?$/i ' , $ locale );
40
+ }
36
41
}
Original file line number Diff line number Diff line change @@ -22,3 +22,7 @@ function get_error_handler(): ?callable { return p\Php85::get_error_handler(); }
22
22
if (!function_exists ('get_exception_handler ' )) {
23
23
function get_exception_handler (): ?callable { return p \Php85::get_exception_handler (); }
24
24
}
25
+
26
+ if (!function_exists ('locale_is_right_to_left ' )) {
27
+ function locale_is_right_to_left (string $ locale ): bool { return p \Php85::locale_is_right_to_left ($ locale ); }
28
+ }
Original file line number Diff line number Diff line change @@ -78,6 +78,25 @@ public static function provideHandler()
78
78
$ handler = new TestHandlerInvokable ();
79
79
yield [$ handler , $ handler ];
80
80
}
81
+
82
+ public function testLocaleIsRightToLeft (): void
83
+ {
84
+ $ this ->assertTrue (locale_is_right_to_left ('ar ' ));
85
+ $ this ->assertTrue (locale_is_right_to_left ('he ' ));
86
+ $ this ->assertTrue (locale_is_right_to_left ('fa ' ));
87
+ $ this ->assertTrue (locale_is_right_to_left ('ur ' ));
88
+ $ this ->assertTrue (locale_is_right_to_left ('ps ' ));
89
+ $ this ->assertTrue (locale_is_right_to_left ('sd ' ));
90
+ $ this ->assertTrue (locale_is_right_to_left ('ug ' ));
91
+ $ this ->assertTrue (locale_is_right_to_left ('ckb ' ));
92
+ $ this ->assertTrue (locale_is_right_to_left ('yi ' ));
93
+ $ this ->assertTrue (locale_is_right_to_left ('dv ' ));
94
+ $ this ->assertTrue (locale_is_right_to_left ('ku_arab ' ));
95
+ $ this ->assertTrue (locale_is_right_to_left ('ku-arab ' ));
96
+
97
+ $ this ->assertFalse (locale_is_right_to_left ('en ' ));
98
+ $ this ->assertFalse (locale_is_right_to_left ('fr ' ));
99
+ }
81
100
}
82
101
83
102
class TestHandler
You can’t perform that action at this time.
0 commit comments