Passed
Push — master ( 163ca3...6d62ea )
by Armando
01:57
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
7
class Factory extends \Longman\TelegramBot\Entities\Factory
8
{
9
    public static function make(array $data, string $bot_username): Entity
10
    {
11
        $type = [
12
            'creator'       => ChatMemberOwner::class,
13
            'administrator' => ChatMemberAdministrator::class,
14
            'member'        => ChatMemberMember::class,
15
            'restricted'    => ChatMemberRestricted::class,
16
            'left'          => ChatMemberLeft::class,
17
            'kicked'        => ChatMemberBanned::class,
18
        ];
19
20
        if (!isset($type[$data['status'] ?? ''])) {
21
            return new ChatMemberNotImplemented($data, $bot_username);
22
        }
23
24
        $class = $type[$data['status']];
25
        return new $class($data, $bot_username);
26
    }
27
}
28