CreateNewStickerSetMethod   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 144
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 25
c 0
b 0
f 0
dl 0
loc 144
ccs 19
cts 19
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createStatic() 0 12 1
A createAnimated() 0 12 1
A createBase() 0 18 2
A create() 0 9 1
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
     * Optional. 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|null
55
     */
56
    public $pngSticker;
57
58
    /**
59
     * Optional. TGS animation with the sticker, uploaded using multipart/form-data.
60
     * See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements.
61
     *
62
     * @var InputFileType|null
63
     */
64
    public $tgsSticker;
65
66
    /**
67
     * Optional. Pass True, if a set of mask stickers should be created.
68
     *
69
     * @var bool|null
70
     */
71
    public $containsMasks;
72
73
    /**
74
     * Optional. A JSON-serialized object for position where the mask should be placed on faces.
75
     *
76
     * @var MaskPositionType|null
77
     */
78
    public $maskPosition;
79
80
    /**
81
     * CreateNewStickerSetMethod constructor.
82
     *
83
     * @param InputFileType|string $pngSticker
84
     *
85
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
86
     *
87
     * @deprecated
88
     * @see CreateNewStickerSetMethod::createStatic()
89
     */
90 1
    public static function create(
91
        int $userId,
92
        string $name,
93
        string $title,
94
        $pngSticker,
95
        string $emojis,
96
        array $data = null
97
    ): CreateNewStickerSetMethod {
98 1
        return static::createStatic($userId, $name, $title, $pngSticker, $emojis, $data);
99
    }
100
101
    /**
102
     * CreateNewStickerSetMethod constructor.
103
     *
104
     * @param InputFileType|string $pngSticker
105
     *
106
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
107
     */
108 1
    public static function createStatic(
109
        int $userId,
110
        string $name,
111
        string $title,
112
        $pngSticker,
113
        string $emojis,
114
        array $data = null
115
    ): CreateNewStickerSetMethod {
116 1
        $instance = static::createBase($userId, $name, $title, $emojis, $data);
117 1
        $instance->pngSticker = $pngSticker;
118
119 1
        return $instance;
120
    }
121
122
    /**
123
     * CreateNewStickerSetMethod constructor.
124
     *
125
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
126
     */
127 1
    public static function createAnimated(
128
        int $userId,
129
        string $name,
130
        string $title,
131
        InputFileType $tgsSticker,
132
        string $emojis,
133
        array $data = null
134
    ): CreateNewStickerSetMethod {
135 1
        $instance = static::createBase($userId, $name, $title, $emojis, $data);
136 1
        $instance->tgsSticker = $tgsSticker;
137
138 1
        return $instance;
139
    }
140
141
    /**
142
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
143
     */
144 2
    private static function createBase(
145
        int $userId,
146
        string $name,
147
        string $title,
148
        string $emojis,
149
        array $data = null
150
    ): CreateNewStickerSetMethod {
151 2
        $instance = new static();
152 2
        $instance->userId = $userId;
153 2
        $instance->name = $name;
154 2
        $instance->title = $title;
155 2
        $instance->emojis = $emojis;
156
157 2
        if ($data) {
158 2
            $instance->fill($data);
159
        }
160
161 2
        return $instance;
162
    }
163
}
164