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

Factory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 19
ccs 0
cts 6
cp 0
rs 10
c 5
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 17 2
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