Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | public function make(array $data, string $bot_username): Entity |
||
13 | { |
||
14 | if (! isset($data['status'])) { |
||
15 | throw new TelegramException('Missing ChatMember status'); |
||
16 | } |
||
17 | |||
18 | $type = [ |
||
19 | 'creator' => ChatMemberOwner::class, |
||
20 | 'administrator' => ChatMemberAdministrator::class, |
||
21 | 'member' => ChatMemberMember::class, |
||
22 | 'restricted' => ChatMemberRestricted::class, |
||
23 | 'left' => ChatMemberLeft::class, |
||
24 | 'kicked' => ChatMemberBanned::class, |
||
25 | ]; |
||
26 | |||
27 | if (! isset($type[$data['status']])) { |
||
28 | throw new TelegramException('Unexpected ChatMember status'); |
||
29 | } |
||
30 | |||
31 | $class = $type[$data['status']]; |
||
32 | return new $class($data, $bot_username); |
||
33 | } |
||
35 |