Completed
Push — master ( d04b6a...4e4c0e )
by Nikolay
03:14
created

CreateNewStickerSetMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 18
dl 0
loc 87
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 19 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\CreateMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\EmojisVariableTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
use TgBotApi\BotApiBase\Type\InputFileType;
11
use TgBotApi\BotApiBase\Type\MaskPositionType;
12
13
/**
14
 * Class CreateNewStickerSetMethod.
15
 *
16
 * @see https://core.telegram.org/bots/api#createnewstickerset
17
 */
18
class CreateNewStickerSetMethod implements CreateMethodAliasInterface
19
{
20
    use FillFromArrayTrait;
21
    use EmojisVariableTrait;
22
23
    /**
24
     * User identifier of created sticker set owner.
25
     *
26
     * @var int
27
     */
28
    public $userId;
29
30
    /**
31
     * Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals).
32
     * Can contain only english letters, digits and underscores.
33
     * Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”.
34
     * <bot_username> is case insensitive. 1-64 characters.
35
     *
36
     * @var string
37
     */
38
    public $name;
39
40
    /**
41
     * Sticker set title, 1-64 characters.
42
     *
43
     * @var string
44
     */
45
    public $title;
46
47
    /**
48
     * Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px,
49
     * and either width or height must be exactly 512px.
50
     * Pass a file_id as a String to send a file that already exists on the Telegram servers,
51
     * pass an HTTP URL as a String for Telegram to get a file from the Internet,
52
     * or upload a new one using multipart/form-data.
53
     *
54
     * @var InputFileType|string
55
     */
56
    public $pngSticker;
57
58
    /**
59
     * Optional. Pass True, if a set of mask stickers should be created.
60
     *
61
     * @var bool|null
62
     */
63
    public $containsMasks;
64
65
    /**
66
     * Optional. A JSON-serialized object for position where the mask should be placed on faces.
67
     *
68
     * @var MaskPositionType|null
69
     */
70
    public $maskPosition;
71
72
    /**
73
     * CreateNewStickerSetMethod constructor.
74
     *
75
     * @param int                  $userId
76
     * @param string               $name
77
     * @param string               $title
78
     * @param InputFileType|string $pngSticker
79
     * @param string               $emojis
80
     * @param array|null           $data
81
     *
82
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
83
     *
84
     * @return CreateNewStickerSetMethod
85
     */
86 1
    public static function create(
87
        int $userId,
88
        string $name,
89
        string $title,
90
        $pngSticker,
91
        string $emojis,
92
        array $data = null
93
    ): CreateNewStickerSetMethod {
94 1
        $instance = new static();
95 1
        $instance->userId = $userId;
96 1
        $instance->name = $name;
97 1
        $instance->title = $title;
98 1
        $instance->pngSticker = $pngSticker;
99 1
        $instance->emojis = $emojis;
100 1
        if ($data) {
101 1
            $instance->fill($data);
102
        }
103
104 1
        return $instance;
105
    }
106
}
107