SendGameMethod   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 33
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
10
use TgBotApi\BotApiBase\Type\InlineKeyboardMarkupType;
11
12
/**
13
 * Class SendGameType.
14
 *
15
 * @see https://core.telegram.org/bots/api#sendgame
16
 */
17
class SendGameMethod implements SendMethodAliasInterface
18
{
19
    use FillFromArrayTrait;
20
    use SendToChatVariablesTrait;
21
22
    /**
23
     * Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
24
     *
25
     * @var string
26
     */
27
    public $gameShortName;
28
29
    /**
30
     * Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown.
31
     * If not empty, the first button must launch the game.
32
     *
33
     * @var InlineKeyboardMarkupType|null
34
     */
35
    public $replyMarkup;
36
37
    /**
38
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
39
     */
40 1
    public static function create(int $chatId, string $gameShortName, array $data = null): SendGameMethod
41
    {
42 1
        $instance = new static();
43 1
        $instance->chatId = $chatId;
44 1
        $instance->gameShortName = $gameShortName;
45 1
        if ($data) {
46 1
            $instance->fill($data);
47
        }
48
49 1
        return $instance;
50
    }
51
}
52