@@ -252,7 +252,7 @@ public function getCommandObject($command)
252
252
$ which [] = 'User ' ;
253
253
254
254
foreach ($ which as $ auth ) {
255
- $ command_namespace = __NAMESPACE__ . '\\Commands \\' . $ auth . 'Commands \\' . ucfirst ($ command ) . 'Command ' ;
255
+ $ command_namespace = __NAMESPACE__ . '\\Commands \\' . $ auth . 'Commands \\' . $ this -> ucfirstUnicode ($ command ) . 'Command ' ;
256
256
if (class_exists ($ command_namespace )) {
257
257
return new $ command_namespace ($ this , $ this ->update );
258
258
}
@@ -430,7 +430,7 @@ public function handle()
430
430
*/
431
431
private function getCommandFromType ($ type )
432
432
{
433
- return ucfirst (str_replace ('_ ' , '' , $ type ));
433
+ return $ this -> ucfirstUnicode (str_replace ('_ ' , '' , $ type ));
434
434
}
435
435
436
436
/**
@@ -521,7 +521,7 @@ public function executeCommand($command)
521
521
*/
522
522
protected function sanitizeCommand ($ command )
523
523
{
524
- return str_replace (' ' , '' , ucwords (str_replace ('_ ' , ' ' , $ command )));
524
+ return str_replace (' ' , '' , $ this -> ucwordsUnicode (str_replace ('_ ' , ' ' , $ command )));
525
525
}
526
526
527
527
/**
@@ -759,4 +759,30 @@ public function unsetWebHook()
759
759
760
760
return $ result ;
761
761
}
762
+
763
+ /**
764
+ * Replace function `ucwords` for UTF-8 characters in the class definition and commands
765
+ *
766
+ * @param string $str
767
+ * @param string $encoding (default = 'UTF-8')
768
+ *
769
+ * @return string
770
+ */
771
+ protected function ucwordsUnicode ($ str , $ encoding = 'UTF-8 ' )
772
+ {
773
+ return mb_convert_case ($ str , MB_CASE_TITLE , $ encoding );
774
+ }
775
+
776
+ /**
777
+ * Replace function `ucfirst` for UTF-8 characters in the class definition and commands
778
+ *
779
+ * @param string $str
780
+ * @param string $encoding (default = 'UTF-8')
781
+ *
782
+ * @return string
783
+ */
784
+ protected function ucfirstUnicode ($ str , $ encoding = 'UTF-8 ' )
785
+ {
786
+ return mb_strtoupper (mb_substr ($ str , 0 , 1 , $ encoding ), $ encoding ) . mb_strtolower (mb_substr ($ str , 1 , mb_strlen ($ str ), $ encoding ), $ encoding );
787
+ }
762
788
}
0 commit comments