Completed
Push — master ( 0a6e40...a44d55 )
by Camilo
06:48
created

UploadStickerFile   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMandatoryFields() 0 7 1
A hasLocalFiles() 0 4 1
A getLocalFiles() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Methods;
6
7
use Generator;
8
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
9
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile;
10
11
/**
12
 * Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods
13
 * (can be used multiple times). Returns the uploaded File on success
14
 *
15
 * Objects defined as-is july 2017
16
 *
17
 * @see https://core.telegram.org/bots/api#uploadstickerfile
18
 */
19
class UploadStickerFile extends TelegramMethods
20
{
21
    /**
22
     * User identifier of sticker file owner
23
     * @var string
24
     */
25
    public $user_id = 0;
26
27
    /**
28
     * Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either
29
     * width or height must be exactly 512px
30
     * @var string|InputFile
31
     */
32
    public $png_sticker;
33
34
    /**
35
     * Gets the name of all mandatory fields
36
     * @return array
37
     */
38
    public function getMandatoryFields(): array
39
    {
40
        return [
41
            'user_id',
42
            'png_sticker',
43
        ];
44
    }
45
46
    public function hasLocalFiles(): bool
47
    {
48
        return $this->png_sticker instanceof InputFile;
49
    }
50
51
    public function getLocalFiles(): Generator
52
    {
53
        yield 'png_sticker' => $this->png_sticker;
54
    }
55
}
56