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

EditMessageMediaMethod::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 6
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
     * @param int|string    $chatId
31
     * @param int           $messageId
32
     * @param InputFileType $media
33
     * @param array|null    $data
34
     *
35
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
36
     *
37
     * @return EditMessageMediaMethod
38
     */
39
    public static function create(
40
        $chatId,
41
        int $messageId,
42
        InputFileType $media,
43
        array $data = null
44
    ): EditMessageMediaMethod {
45
        $instance = new static();
46
        $instance->chatId = $chatId;
47
        $instance->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...
48
        $instance->messageId = $messageId;
49
        if ($data) {
50
            $instance->fill($data);
51
        }
52
53
        return $instance;
54
    }
55
56
    /**
57
     * @param string        $inlineMessageId
58
     * @param InputFileType $media
59
     * @param array|null    $data
60
     *
61
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
62
     *
63
     * @return EditMessageMediaMethod
64
     */
65
    public static function createInline(
66
        string $inlineMessageId,
67
        InputFileType $media,
68
        array $data = null
69
    ): EditMessageMediaMethod {
70
        $instance = new static();
71
        $instance->inlineMessageId = $inlineMessageId;
72
        $instance->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...
73
        if ($data) {
74
            $instance->fill($data);
75
        }
76
77
        return $instance;
78
    }
79
}
80