Passed
Push — master ( 02a361...e20c00 )
by Shahrad
02:40
created

Factory   A

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 TelegramBot\Entities\MenuButton;
4
5
use TelegramBot\Entity;
6
7
class Factory extends \TelegramBot\Factory
8
{
9
    public static function make(array $data): Entity
10
    {
11
        $type = [
12
            'commands' => MenuButtonCommands::class,
13
            'web_app'  => MenuButtonWebApp::class,
14
            'default'  => MenuButtonDefault::class,
15
        ];
16
17
        if (! isset($type[$data['type'] ?? ''])) {
18
            return new MenuButtonNotImplemented($data);
19
        }
20
21
        $class = $type[$data['type']];
22
        return new $class($data);
23
    }
24
}
25