Completed
Push — master ( 5e4939...d9a3d5 )
by Camilo
01:45
created

SetStickerSetThumb::hasLocalFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Methods;
6
7
use Generator;
8
use Psr\Log\LoggerInterface;
9
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
10
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
11
use unreal4u\TelegramAPI\InternalFunctionality\TelegramResponse;
12
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile;
13
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
14
15
/**
16
 * Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only.
17
 * Returns True on success.
18
 *
19
 * Objects defined as-is June 2020, Bot API v4.9
20
 *
21
 * @see https://core.telegram.org/bots/api#setstickersetthumb
22
 */
23
class SetStickerSetThumb extends TelegramMethods
24
{
25
    /**
26
     * Sticker set name
27
     * @var string
28
     */
29
    public $name;
30
31
    /**
32
     * User identifier of the sticker set owner
33
     * @var int
34
     */
35
    public $user_id;
36
37
    /**
38
     * A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a
39
     * TGS animation with the thumbnail up to 32 kilobytes in size; see
40
     * https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements.
41
     * Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a
42
     * String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on
43
     * Sending Files ». Animated sticker set thumbnail can't be uploaded via HTTP URL.
44
     *
45
     * @var InputFile|string
46
     */
47
    public $thumb;
48
49
    public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes
50
    {
51
        return new ResultBoolean($data->getResultBoolean(), $logger);
52
    }
53
54
    public function getMandatoryFields(): array
55
    {
56
        return [
57
            'name',
58
            'user_id',
59
        ];
60
    }
61
62
    public function hasLocalFiles(): bool
63
    {
64
        return $this->thumb instanceof InputFile;
65
    }
66
67
    public function getLocalFiles(): Generator
68
    {
69
        yield 'thumb' => $this->thumb;
70
    }
71
}
72