Passed
Push — draft ( 8ec7b9...aebf0a )
by Nikolay
03:09
created

SendStickerMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 34
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method;
6
7
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
8
use Greenplugin\TelegramBot\Method\Traits\SendToChatVariablesTrait;
9
use Greenplugin\TelegramBot\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 \Greenplugin\TelegramBot\Exception\BadArgumentException
37
     *
38
     * @return SendStickerMethod
39
     */
40
    public static function create($chatId, $sticker, array $data = null): SendStickerMethod
41
    {
42
        $instance = new static();
43
        $instance->chatId = $chatId;
44
        $instance->sticker = $sticker;
45
        if ($data) {
46
            $instance->fill($data);
47
        }
48
49
        return $instance;
50
    }
51
}
52