sticker   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
c 0
b 0
f 0
dl 0
loc 97
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A download() 0 2 1
A __construct() 0 3 2
A link() 0 2 1
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\telegram\telegram;
6
use stdClass;
7
8
/**
9
 * This object represents a sticker.
10
 */
11
class sticker extends types {
0 ignored issues
show
Bug introduced by
The type BPT\types\types was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
    /** Keep all of properties which has sub properties */
13
    private const subs = [
14
        'thumbnail' => 'BPT\types\photoSize',
15
        'premium_animation' => 'BPT\types\file',
16
        'mask_position' => 'BPT\types\maskPosition',
17
    ];
18
19
    /** Identifier for this file, which can be used to download or reuse the file */
20
    public string $file_id;
21
22
    /**
23
     * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be
24
     * used to download or reuse the file.
25
     */
26
    public string $file_unique_id;
27
28
    /**
29
     * Type of the sticker, currently one of “regular”, “mask”, “custom_emoji”. The type of the sticker is
30
     * independent from its format, which is determined by the fields is_animated and is_video.
31
     */
32
    public string $type;
33
34
    /** Sticker width */
35
    public int $width;
36
37
    /** Sticker height */
38
    public int $height;
39
40
    /** True, if the sticker is animated */
41
    public null|bool $is_animated = null;
42
43
    /** True, if the sticker is a video sticker */
44
    public null|bool $is_video = null;
45
46
    /** Optional. Sticker thumbnail in the .WEBP or .JPG format */
47
    public null|photoSize $thumbnail = null;
48
49
    /** Optional. Emoji associated with the sticker */
50
    public null|string $emoji = null;
51
52
    /** Optional. Name of the sticker set to which the sticker belongs */
53
    public null|string $set_name = null;
54
55
    /** Optional. Premium animation for the sticker, if the sticker is premium */
56
    public null|file $premium_animation = null;
57
58
    /** Optional. For mask stickers, the position where the mask should be placed */
59
    public null|maskPosition $mask_position = null;
60
61
    /** Optional. For custom emoji stickers, unique identifier of the custom emoji */
62
    public string $custom_emoji_id;
63
64
    /**
65
     * Optional. True, if the sticker must be repainted to a text color in messages, the color of the Telegram
66
     * Premium badge in emoji status, white color on chat photos, or another appropriate color in other places
67
     */
68
    public bool $needs_repainting;
69
70
    /** Optional. File size in bytes */
71
    public null|int $file_size = null;
72
73
74
    public function __construct(stdClass|null $object = null) {
75
        if ($object != null) {
76
            parent::__construct($object, self::subs);
77
        }
78
    }
79
80
    /**
81
     * download this file and save it in destination
82
     *
83
     * if destination doesn't set , it will return the downloaded file(as string)
84
     *
85
     * It has 20MB download limit(same as telegram)
86
     *
87
     * e.g. => $sticker->download();
88
     *
89
     * e.g. => $sticker->download('test.png');
90
     *
91
     * @param string|null $destination destination for save the file
92
     *
93
     * @return bool|string string will be returned when destination doesn't set
94
     */
95
    public function download(string|null $destination = null): bool|string {
96
        return telegram::downloadFile($destination ?? 'unknown.png',$this->file_id);
97
    }
98
99
    /**
100
     * Get download link of this file
101
     *
102
     * It does not bypass telegram limits(e.g: Download size limit in public bot api)
103
     *
104
     * @return string
105
     */
106
    public function link(): string {
107
        return telegram::fileLink($this->file_id);
108
    }
109
}
110