Completed
Push — master ( 62cb7b...4b7fdd )
by Nikolay
02:34
created

SendStickerMethod::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
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
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\Traits\FillFromArrayTrait;
8
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
9
use TgBotApi\BotApiBase\Type\InputFileType;
10
11
/**
12
 * Class SendStickerMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#sendsticker
15
 */
16
class SendStickerMethod
17
{
18
    use FillFromArrayTrait;
19
    use SendToChatVariablesTrait;
20
21
    /**
22
     * Sticker to send.
23
     * Pass a file_id as String to send a file that exists on the Telegram servers (recommended),
24
     * pass an HTTP URL as a String for Telegram to get a .webp file from the Internet,
25
     * or upload a new one using multipart/form-data.
26
     *
27
     * @var InputFileType|string
28
     */
29
    public $sticker;
30
31
    /**
32
     * @param int|string           $chatId
33
     * @param InputFileType|string $sticker
34
     * @param array|null           $data
35
     *
36
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
37
     *
38
     * @return SendStickerMethod
39
     */
40 2
    public static function create($chatId, $sticker, array $data = null): SendStickerMethod
41
    {
42 2
        $instance = new static();
43 2
        $instance->chatId = $chatId;
44 2
        $instance->sticker = $sticker;
45 2
        if ($data) {
46 2
            $instance->fill($data);
47
        }
48
49 2
        return $instance;
50
    }
51
}
52