Completed
Push — master ( 2eee41...ce0d19 )
by Camilo
03:03
created

Chat::mapSubObjects()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
crap 6
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Types;
6
7
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
8
9
/**
10
 * This object represents a chat.
11
 *
12
 * Objects defined as-is july 2017
13
 *
14
 * @see https://core.telegram.org/bots/api#chat
15
 */
16
class Chat extends TelegramTypes
17
{
18
    /**
19
     * Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have
20
     * difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or
21
     * double-precision float type are safe for storing this identifier
22
     * @var int
23
     */
24
    public $id = 0;
25
26
    /**
27
     * Type of chat, can be either “private”, “group”, “supergroup” or “channel”
28
     * @var string
29
     */
30
    public $type = '';
31
32
    /**
33
     * Optional. Title, for channels and group chats
34
     * @var string
35
     */
36
    public $title = '';
37
38
    /**
39
     * Optional. Username, for private chats, supergroups and channels if available
40
     * @var string
41
     */
42
    public $username = '';
43
44
    /**
45
     * Optional. First name of the other party in a private chat
46
     * @var string
47
     */
48
    public $first_name = '';
49
50
    /**
51
     * Optional. Last name of the other party in a private chat
52
     * @var string
53
     */
54
    public $last_name = '';
55
56
    /**
57
     * Optional. True if a group has ‘All Members Are Admins’ enabled.
58
     * @var bool
59
     */
60
    public $all_members_are_administrators = false;
61
62
    /**
63
     * Optional. Chat photo. Returned only in getChat
64
     * @var ChatPhoto
65
     */
66
    public $photo;
67
68
    /**
69
     * Optional. Description, for supergroups and channel chats. Returned only in getChat
70
     * @var string
71
     */
72
    public $description = '';
73
74
    /**
75
     * Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat
76
     * @var string
77
     */
78
    public $invite_link = '';
79
80
    public function mapSubObjects(string $key, array $data): TelegramTypes {
81
        switch ($key) {
82
            case 'photo':
83
                return new ChatPhoto($data, $this->logger);
84
        }
85
        return parent::mapSubObjects($key, $data);
86
    }
87
}
88