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

SendPollMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 38
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 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
11
/**
12
 * Class SendPollMethod
13
 * Use this method to send a native poll. A native poll can't be sent to a private chat.
14
 * On success, the sent Message is returned.
15
 *
16
 * @see https://core.telegram.org/bots/api#sendpoll
17
 */
18
class SendPollMethod implements SendMethodAliasInterface
19
{
20
    use FillFromArrayTrait;
21
    use SendToChatVariablesTrait;
22
23
    /**
24
     * Poll question, 1-255 characters.
25
     *
26
     * @var string;
27
     */
28
    public $question;
29
30
    /**
31
     * List of answer options, 2-10 strings 1-100 characters each.
32
     *
33
     * @var string[]
34
     */
35
    public $options;
36
37
    /**
38
     * @param string     $chatId
39
     * @param string     $question
40
     * @param string[]   $options
41
     * @param array|null $data
42
     *
43
     * @return SendPollMethod
44
     */
45 3
    public static function create(string $chatId, string $question, array $options, array $data = null): self
46
    {
47 3
        $instance = new static();
48 3
        $instance->chatId = $chatId;
49 3
        $instance->question = $question;
50 3
        $instance->options = $options;
51 3
        if ($data) {
52 3
            $instance->fill($data);
53
        }
54
55 3
        return $instance;
56
    }
57
}
58