Factory::make()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 17
c 0
b 0
f 0
rs 9.9
cc 2
nc 2
nop 1
1
<?php
2
3
namespace TelegramBot\Entities\ChatMember;
4
5
use TelegramBot\Entity;
6
7
class Factory extends \TelegramBot\Factory
8
{
9
10
    public static function make(array $data): 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);
23
        }
24
25
        $class = $type[$data['status']];
26
        return new $class($data);
27
    }
28
29
}
30