Completed
Push — master ( 54e92f...46abfb )
by Camilo
04:46
created

Game   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 54
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A mapSubObjects() 0 13 4
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Types;
6
7
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
8
use unreal4u\TelegramAPI\Telegram\Types\Custom\MessageEntityArray;
9
use unreal4u\TelegramAPI\Telegram\Types\Custom\PhotoSizeArray;
10
11
/**
12
 * This object represents a game. Use BotFather to create and edit games, their short names will act as unique
13
 * identifiers
14
 *
15
 * Objects defined as-is December 2016
16
 *
17
 * @see https://core.telegram.org/bots/api#game
18
 */
19
class Game extends TelegramTypes
20
{
21
    /**
22
     * Title of the game
23
     * @var string
24
     */
25
    public $title = '';
26
27
    /**
28
     * Description of the game
29
     * @var string
30
     */
31
    public $description = '';
32
33
    /**
34
     * Photo that will be displayed in the game message in chats
35
     * @var PhotoSize[]
36
     */
37
    public $photo = [];
38
39
    /**
40
     * Optional. Brief description of the game or high scores included in the game message. Can be automatically edited
41
     * to include current high scores for the game when the bot calls setGameScore, or manually edited using
42
     * editMessageText. 0-4096 characters
43
     * @var int
44
     */
45
    public $text = '';
46
47
    /**
48
     * Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc
49
     * @var MessageEntity[]
50
     */
51
    public $text_entities = [];
52
53
    /**
54
     * Optional. Animation that will be displayed in the game message in chats. Upload via BotFather
55
     * @var Animation
56
     */
57
    public $animation;
58
59
    public function mapSubObjects(string $key, array $data): TelegramTypes
60
    {
61
        switch ($key) {
62
            case 'photo':
63
                return new PhotoSizeArray($data, $this->logger);
64
            case 'text_entities':
65
                return new MessageEntityArray($data, $this->logger);
66
            case 'animation':
67
                return new Animation($data, $this->logger);
68
        }
69
70
        return parent::mapSubObjects($key, $data);
71
    }
72
}
73