Passed
Pull Request — develop (#1229)
by
unknown
02:50
created

Factory::make()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 5
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
nc 2
nop 2
dl 0
loc 17
ccs 0
cts 6
cp 0
crap 6
rs 9.9
c 5
b 0
f 0
1
<?php
2
3
namespace Longman\TelegramBot\Entities\ChatMember;
4
5
use Longman\TelegramBot\Entities\Entity;
6
use Longman\TelegramBot\Exception\TelegramException;
7
8
class Factory extends \Longman\TelegramBot\Entities\Factory
9
{
10
    public static function make(array $data, string $bot_username): Entity
11
    {
12
        $type = [
13
            'creator'       => ChatMemberOwner::class,
14
            'administrator' => ChatMemberAdministrator::class,
15
            'member'        => ChatMemberMember::class,
16
            'restricted'    => ChatMemberRestricted::class,
17
            'left'          => ChatMemberLeft::class,
18
            'kicked'        => ChatMemberBanned::class,
19
        ];
20
21
        if (! isset($type[$data['status'] ?? ''])) {
22
            return new ChatMemberNotImplemented($data, $bot_username);
23
        }
24
25
        $class = $type[$data['status']];
26
        return new $class($data, $bot_username);
27
    }
28
}
29