Completed
Push — master ( 5e4939...d9a3d5 )
by Camilo
01:45
created

SetMyCommands   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A bindToObject() 0 4 1
A getMandatoryFields() 0 6 1
A performSpecialConditions() 0 5 1
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\InternalFunctionality\TelegramResponse;
11
use unreal4u\TelegramAPI\Telegram\Types\BotCommand;
12
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
13
14
/**
15
 * Use this method to change the list of the bot's commands. Returns True on success.
16
 *
17
 * Objects defined as-is June 2020, Bot API v4.9
18
 *
19
 * @see https://core.telegram.org/bots/api#setmycommands
20
 */
21
class SetMyCommands extends TelegramMethods
22
{
23
    /**
24
     * A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be
25
     * specified.
26
     *
27
     * @var BotCommand[]
28
     */
29
    public $commands;
30
31
    public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes
32
    {
33
        return new ResultBoolean($data->getResultBoolean(), $logger);
34
    }
35
36
    public function getMandatoryFields(): array
37
    {
38
        return [
39
            'commands',
40
        ];
41
    }
42
43
    public function performSpecialConditions(): TelegramMethods
44
    {
45
        $this->commands = json_encode($this->commands);
46
        return parent::performSpecialConditions();
47
    }
48
}
49