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 1313
1414/**
1515 * @author Pierre Ambroise <pierre27.ambroise@gmail.com>
16+ * @author Alexander Schranz <alexander@sulu.io>
1617 *
1718 * @internal
1819 */
@@ -33,4 +34,8 @@ public static function get_exception_handler(): ?callable
3334
3435 return $ handler ;
3536 }
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+ }
3641}
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(); }
2222if (!function_exists ('get_exception_handler ' )) {
2323 function get_exception_handler (): ?callable { return p \Php85::get_exception_handler (); }
2424}
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()
7878 $ handler = new TestHandlerInvokable ();
7979 yield [$ handler , $ handler ];
8080 }
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+ }
81100}
82101
83102class TestHandler
You can’t perform that action at this time.
0 commit comments