SetGameScoreMethod   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 24
dl 0
loc 109
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createInline() 0 15 2
A create() 0 17 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\SetMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
10
/**
11
 * Class SetGameScoreMetod.
12
 *
13
 * @see https://core.telegram.org/bots/api#setgamescore
14
 */
15
class SetGameScoreMethod implements SetMethodAliasInterface
16
{
17
    use FillFromArrayTrait;
18
19
    /**
20
     * User identifier.
21
     *
22
     * @var int
23
     */
24
    public $userId;
25
26
    /**
27
     * New score, must be non-negative.
28
     *
29
     * @var int
30
     */
31
    public $score;
32
33
    /**
34
     * Optional. Pass True, if the high score is allowed to decrease.
35
     * This can be useful when fixing mistakes or banning cheaters.
36
     *
37
     * @var bool|null
38
     */
39
    public $force;
40
41
    /**
42
     * Optional. Pass True, if the game message should not be automatically edited to include the current scoreboard.
43
     *
44
     * @var bool|null
45
     */
46
    public $disableEditMessage;
47
48
    /**
49
     * Optional. Required if inline_message_id is not specified. Identifier of the sent message.
50
     *
51
     * @var int|null
52
     */
53
    public $chatId;
54
55
    /**
56
     * Optional. Required if inline_message_id is not specified. Identifier of the sent message.
57
     *
58
     * @var int|null
59
     */
60
    public $messageId;
61
62
    /**
63
     * Optional. Required if chat_id and message_id are not specified. Identifier of the inline message.
64
     *
65
     * @var string|null
66
     */
67
    public $inlineMessageId;
68
69
    /**
70
     * @param int        $userId
71
     * @param int        $score
72
     * @param int        $chatId
73
     * @param int        $messageId
74
     * @param array|null $data
75
     *
76
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
77
     *
78
     * @return SetGameScoreMethod
79
     */
80 1
    public static function create(
81
        int $userId,
82
        int $score,
83
        int $chatId,
84
        int $messageId,
85
        array $data = null
86
    ): SetGameScoreMethod {
87 1
        $instance = new static();
88 1
        $instance->userId = $userId;
89 1
        $instance->score = $score;
90 1
        $instance->chatId = $chatId;
91 1
        $instance->messageId = $messageId;
92 1
        if ($data) {
93 1
            $instance->fill($data);
94
        }
95
96 1
        return $instance;
97
    }
98
99
    /**
100
     * @param int        $userId
101
     * @param int        $score
102
     * @param string     $inlineMessageId
103
     * @param array|null $data
104
     *
105
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
106
     *
107
     * @return SetGameScoreMethod
108
     */
109 1
    public static function createInline(
110
        int $userId,
111
        int $score,
112
        string $inlineMessageId,
113
        array $data = null
114
    ): SetGameScoreMethod {
115 1
        $instance = new static();
116 1
        $instance->userId = $userId;
117 1
        $instance->score = $score;
118 1
        $instance->inlineMessageId = $inlineMessageId;
119 1
        if ($data) {
120 1
            $instance->fill($data);
121
        }
122
123 1
        return $instance;
124
    }
125
}
126