Skip to content

Commit 62c38a2

Browse files
committed
Filled the ChatMember Factory
1 parent 9f13a6b commit 62c38a2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Entities/ChatMember/Factory.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,28 @@
55

66

77
use Longman\TelegramBot\Entities\Entity;
8+
use Longman\TelegramBot\Exception\TelegramException;
89

910
class Factory extends \Longman\TelegramBot\Entities\Factory
1011
{
1112
public function make(array $data, string $bot_username): Entity
1213
{
13-
var_dump($data);
14+
$status = $data['status'];
15+
switch ($status) {
16+
case 'creator':
17+
return new ChatMemberOwner($data, $bot_username);
18+
case 'administrator':
19+
return new ChatMemberAdministrator($data, $bot_username);
20+
case 'member':
21+
return new ChatMemberMember($data, $bot_username);
22+
case 'restricted':
23+
return new ChatMemberRestricted($data, $bot_username);
24+
case 'left':
25+
return new ChatMemberLeft($data, $bot_username);
26+
case 'kicked':
27+
return new ChatMemberBanned($data, $bot_username);
28+
}
29+
30+
throw new TelegramException('Unexpected ChatMember type');
1431
}
1532
}

0 commit comments

Comments
 (0)