Completed
Push — master ( 1ab7f6...5e4939 )
by Camilo
01:36
created

KeyboardButton::mapSubObjects()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
ccs 0
cts 4
cp 0
crap 6
rs 10
c 0
b 0
f 0
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 one button of the reply keyboard. For simple text buttons String can be used instead of this
11
 * object to specify text of the button. Optional fields request_contact, request_location, and request_poll are
12
 * mutually exclusive.
13
 *
14
 * Note: request_contact and request_location options will only work in Telegram versions released after 9 April, 2016.
15
 * Older clients will ignore them.
16
 * Note: request_poll option will only work in Telegram versions released after 23 January, 2020. Older clients will
17
 * display unsupported message.
18
 *
19
 * Objects defined as-is June 2020, Bot API v4.9
20
 *
21
 * @see https://core.telegram.org/bots/api#keyboardbutton
22
 */
23
class KeyboardButton extends TelegramTypes
24
{
25
    /**
26
     * Text of the button. If none of the optional fields are used, it will be sent to the bot as a message when the
27
     * button is pressed
28
     * @var string
29
     */
30
    public $text = '';
31
32
    /**
33
     * Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in
34
     * private chats only
35
     * @var bool
36
     */
37
    public $request_contact = false;
38
39
    /**
40
     * Optional. If True, the user's current location will be sent when the button is pressed. Available in private
41
     * chats only
42
     * @var bool
43
     */
44
    public $request_location = false;
45
46
    /**
47
     * Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is
48
     * pressed. Available in private chats only
49
     *
50
     * @var KeyboardButtonPollType
51
     */
52
    public $request_poll = null;
53
54
    protected function mapSubObjects(string $key, array $data): TelegramTypes
55
    {
56
        switch ($key) {
57
            case 'request_poll':
58
                return new KeyboardButtonPollType($data, $this->logger);
59
        }
60
        return parent::mapSubObjects($key, $data); // TODO: Change the autogenerated stub
61
    }
62
}
63