Passed
Push — master ( 26433b...596cc9 )
by Armando
16:00 queued 05:59
created

Factory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 15 2
1
<?php
2
3
namespace Longman\TelegramBot\Entities\MessageOrigin;
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
            'user'        => MessageOriginUser::class,
13
            'hidden_user' => MessageOriginHiddenUser::class,
14
            'chat'        => MessageOriginChat::class,
15
            'channel'     => MessageOriginChannel::class,
16
        ];
17
18
        if (!isset($type[$data['type'] ?? ''])) {
19
            return new MessageOriginNotImplemented($data, $bot_username);
20
        }
21
22
        $class = $type[$data['type']];
23
        return new $class($data, $bot_username);
24
    }
25
}
26