Completed
Push — master ( 588078...30ae0c )
by Nikolay
04:51 queued 02:15
created

EditMessageMediaMethod   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 14
dl 0
loc 72
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 1
A createInline() 0 10 1
A __construct() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method;
6
7
use Greenplugin\TelegramBot\Method\Traits\EditMessageVariablesTrait;
8
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
9
use Greenplugin\TelegramBot\Type\InputFileType;
10
use Greenplugin\TelegramBot\Type\InputMedia\InputMediaType;
11
12
/**
13
 * Class EditMessageMediaMethod.
14
 *
15
 * @see https://core.telegram.org/bots/api#editmessagemedia
16
 */
17
class EditMessageMediaMethod
18
{
19
    use FillFromArrayTrait;
20
    use EditMessageVariablesTrait;
21
22
    /**
23
     * A JSON-serialized object for a new media content of the message.
24
     *
25
     * @var InputMediaType
26
     */
27
    public $media;
28
29
    /**
30
     * EditMessageMediaMethod constructor.
31
     *
32
     * @param int|string    $chatId
33
     * @param InputFileType $media
34
     * @param array|null    $data
35
     *
36
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
37
     */
38
    public function __construct($chatId, InputFileType $media, array $data = null)
39
    {
40
        $this->chatId = $chatId;
41
        $this->media = $media;
0 ignored issues
show
Documentation Bug introduced by
It seems like $media of type Greenplugin\TelegramBot\Type\InputFileType is incompatible with the declared type Greenplugin\TelegramBot\...putMedia\InputMediaType of property $media.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
        if ($data) {
43
            $this->fill($data);
44
        }
45
    }
46
47
    /**
48
     * @param int|string    $chatId
49
     * @param int           $messageId
50
     * @param InputFileType $media
51
     * @param array|null    $data
52
     *
53
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
54
     *
55
     * @return EditMessageMediaMethod
56
     */
57
    public static function create(
58
        $chatId,
59
        int $messageId,
60
        InputFileType $media,
61
        array $data = null
62
    ): EditMessageMediaMethod {
63
        $instance = new self($chatId, $media, $data);
64
        $instance->messageId = $messageId;
65
66
        return $instance;
67
    }
68
69
    /**
70
     * @param int|string    $chatId
71
     * @param string        $inlineMessageId
72
     * @param InputFileType $media
73
     * @param array|null    $data
74
     *
75
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
76
     *
77
     * @return EditMessageMediaMethod
78
     */
79
    public static function createInline(
80
        $chatId,
81
        string $inlineMessageId,
82
        InputFileType $media,
83
        array $data = null
84
    ): EditMessageMediaMethod {
85
        $instance = new self($chatId, $media, $data);
86
        $instance->inlineMessageId = $inlineMessageId;
87
88
        return $instance;
89
    }
90
}
91