InputMediaPhotoType::create()   A
last analyzed

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 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Type\InputMedia;
6
7
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
8
use TgBotApi\BotApiBase\Type\InputFileType;
9
10
/**
11
 * Class InputMediaPhotoType.
12
 *
13
 * @see https://core.telegram.org/bots/api#inputmediaphoto
14
 */
15
class InputMediaPhotoType extends InputMediaType
16
{
17
    use FillFromArrayTrait;
18
19
    /**
20
     * @param string|InputFileType $media
21
     * @param array|null           $data
22
     *
23
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
24
     *
25
     * @return InputMediaPhotoType
26
     */
27 1
    public static function create($media, array $data = null): InputMediaPhotoType
28
    {
29 1
        $instance = new static();
30 1
        $instance->media = $media;
31 1
        $instance->type = static::TYPE_PHOTO;
32 1
        if ($data) {
33 1
            $instance->fill($data);
34
        }
35
36 1
        return $instance;
37
    }
38
}
39