Skip to content

Commit 63ba67d

Browse files
committed
Avoid preg_match in Telegram::classNameToCommandName()
1 parent b1157b5 commit 63ba67d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Telegram.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,10 +1294,11 @@ public function getUpdateFilter(): ?callable
12941294
*/
12951295
protected function classNameToCommandName(string $class): string
12961296
{
1297-
if (!preg_match('/^(.+)Command$/', $class, $matches)) {
1297+
// 7 is the length of 'Command'
1298+
if (substr($class, -7) !== 'Command') {
12981299
return '';
12991300
}
1300-
$temp = $matches[1];
1301+
$temp = substr($class, 0, -7);
13011302
$chunks = [];
13021303
$currentUpperCaseLetter = '';
13031304
while ($temp !== '') {

0 commit comments

Comments
 (0)