Passed
Push — master ( 163ca3...6d62ea )
by Armando
01:57
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
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