Factory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 14 2
1
<?php
2
3
namespace Longman\TelegramBot\Entities\ChatBoostSource;
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
            'premium'   => ChatBoostSourcePremium::class,
13
            'gift_code' => ChatBoostSourceGiftCode::class,
14
            'giveaway'  => ChatBoostSourceGiveaway::class,
15
        ];
16
17
        if (!isset($type[$data['source'] ?? ''])) {
18
            return new ChatBoostSourceNotImplemented($data, $bot_username);
19
        }
20
21
        $class = $type[$data['source']];
22
        return new $class($data, $bot_username);
23
    }
24
}
25