SendChatActionMethod::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\HasActionVariableInterface;
8
use TgBotApi\BotApiBase\Method\Interfaces\MethodInterface;
9
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
10
11
/**
12
 * Class SendChatActionMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#sendchataction
15
 */
16
class SendChatActionMethod implements HasActionVariableInterface, MethodInterface
17
{
18
    use ChatIdVariableTrait;
19
20
    /**
21
     * Type of action to broadcast.
22
     * Choose one, depending on what the user is about to receive:
23
     * typing for text messages,
24
     * upload_photo for photos,
25
     * record_video or upload_video for videos,
26
     * record_audio or upload_audio for audio files,
27
     * upload_document for general files,
28
     * find_location for location data,
29
     * record_video_note or upload_video_note for video notes.
30
     *
31
     * @var string
32
     */
33
    public $action;
34
35
    /**
36
     * @param int|string $chatId
37
     * @param string     $action
38
     *
39
     * @return SendChatActionMethod
40
     */
41 1
    public static function create($chatId, string $action): SendChatActionMethod
42
    {
43 1
        $instance = new static();
44 1
        $instance->chatId = $chatId;
45 1
        $instance->action = $action;
46
47 1
        return $instance;
48
    }
49
}
50