Completed
Push — master ( 2171d1...d76c2c )
by Nikolay
06:00
created

StopPollMethod::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 10
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\MethodInterface;
8
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
use TgBotApi\BotApiBase\Method\Traits\MessageIdVariableTrait;
11
use TgBotApi\BotApiBase\Type\InlineKeyboardMarkupType;
12
13
/**
14
 * Class StopPollMethod
15
 * Use this method to stop a poll which was sent by the bot.
16
 * On success, the stopped Poll with the final results is returned.
17
 *
18
 * @see https://core.telegram.org/bots/api#stoppoll
19
 */
20
class StopPollMethod implements MethodInterface
21
{
22
    use FillFromArrayTrait;
23
    use ChatIdVariableTrait;
24
    use MessageIdVariableTrait;
25
26
    /**
27
     * Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard,
28
     * instructions to remove reply keyboard or to force a reply from the user.
29
     *
30
     * @var InlineKeyboardMarkupType
31
     */
32
    public $replyMarkup;
33
34
    /**
35
     * @param string     $chatId
36
     * @param int        $messageId
37
     * @param array|null $data
38
     *
39
     * @return StopPollMethod
40
     */
41 3
    public static function create(string $chatId, int $messageId, array $data = null): self
42
    {
43 3
        $instance = new static();
44 3
        $instance->chatId = $chatId;
45 3
        $instance->messageId = $messageId;
46 3
        if ($data) {
47 3
            $instance->fill($data);
48
        }
49
50 3
        return $instance;
51
    }
52
}
53