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

EditMessageReplyMarkup   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 46
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMandatoryFields() 0 5 1
A bindToObject() 0 12 3
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Methods;
6
7
use Psr\Log\LoggerInterface;
8
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
9
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
10
use unreal4u\TelegramAPI\Exceptions\InvalidResultType;
11
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData;
12
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
13
use unreal4u\TelegramAPI\Telegram\Types\Inline\Keyboard\Markup;
14
use unreal4u\TelegramAPI\Telegram\Types\Message;
15
16
/**
17
 * Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On
18
 * success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
19
 *
20
 * Objects defined as-is july 2016
21
 *
22
 * @see https://core.telegram.org/bots/api#editmessagereplymarkup
23
 */
24
class EditMessageReplyMarkup extends TelegramMethods
25
{
26
    /**
27
     * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target
28
     * channel (in the format @channelusername)
29
     * @var string
30
     */
31
    public $chat_id = '';
32
33
    /**
34
     * Required if inline_message_id is not specified. Unique identifier of the sent message
35
     * @var int
36
     */
37
    public $message_id = 0;
38
39
    /**
40
     * Required if chat_id and message_id are not specified. Identifier of the inline message
41
     * @var string
42
     */
43
    public $inline_message_id = '';
44
45
    /**
46
     * Optional. A JSON-serialized object for an inline keyboard.
47
     * @var Markup
48
     */
49
    public $reply_markup;
50
51
    public function getMandatoryFields(): array
52
    {
53
        $returnValue = [];
54
        return $this->mandatoryUserOrInlineMessageId($returnValue);
55
    }
56
57
    public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes
58
    {
59
        $typeOfResult = $data->getTypeOfResult();
60
        switch ($typeOfResult) {
61
            case 'array':
62
                return new Message($data->getResult(), $logger);
63
            case 'boolean':
64
                return new ResultBoolean($data->getResultBoolean(), $logger);
65
            default:
66
                throw new InvalidResultType('Result is of type: %s. Expecting one of array or boolean');
67
        }
68
    }
69
}
70