Passed
Push — master ( 1b1236...bd5fab )
by Nikolay
01:00 queued 15s
created

SendDiceMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 8
c 1
b 0
f 1
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10

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\Exception\BadArgumentException;
8
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
11
12
/**
13
 * Class SendDiceMethod.
14
 *
15
 * Use this method to send a dice, which will have a random value from 1 to 6.
16
 * On success, the sent Message is returned.
17
 * (Yes, we're aware of the “proper” singular of die.
18
 * But it's awkward, and we decided to help it change.
19
 * One dice at a time!)
20
 *
21
 * @see https://core.telegram.org/bots/api#senddice
22
 */
23
class SendDiceMethod implements SendMethodAliasInterface
24
{
25
    use SendToChatVariablesTrait;
26
    use FillFromArrayTrait;
27
28
    /**
29
     * @param int|string $chatId
30
     *
31
     * @throws BadArgumentException
32
     */
33 1
    public static function create($chatId, array $data = null): SendDiceMethod
34
    {
35 1
        $instance = new static();
36 1
        $instance->chatId = $chatId;
37
38 1
        if ($data) {
39 1
            $instance->fill($data);
40
        }
41
42 1
        return $instance;
43
    }
44
}
45