Passed
Push — main ( d761d2...4cb247 )
by Miaad
10:19
created

animation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 62
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 2
A download() 0 2 1
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\api\telegram;
6
use stdClass;
7
8
/**
9
 * This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
10
 */
11
class animation 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 = ['thumb' => 'BPT\types\photoSize'];
14
15
    /** Identifier for this file, which can be used to download or reuse the file */
16
    public string $file_id;
17
18
    /**
19
     * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be
20
     * used to download or reuse the file.
21
     */
22
    public string $file_unique_id;
23
24
    /** Video width as defined by sender */
25
    public int $width;
26
27
    /** Video height as defined by sender */
28
    public int $height;
29
30
    /** Duration of the video in seconds as defined by sender */
31
    public int $duration;
32
33
    /** Optional. Animation thumbnail as defined by sender */
34
    public photoSize $thumb;
35
36
    /** Optional. Original animation filename as defined by sender */
37
    public string $file_name;
38
39
    /** Optional. MIME type of the file as defined by sender */
40
    public string $mime_type;
41
42
    /**
43
     * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have
44
     * difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit
45
     * integer or double-precision float type are safe for storing this value.
46
     */
47
    public int $file_size;
48
49
50
    public function __construct(stdClass|null $object = null) {
51
        if ($object != null) {
52
            parent::__construct($object, self::subs);
53
        }
54
    }
55
56
    /**
57
     * download this file and save it in destination
58
     *
59
     * if destination doesn't set , it will return the downloaded file(as string)
60
     *
61
     * It has 20MB download limit(same as telegram)
62
     *
63
     * e.g. => $animation->download();
64
     *
65
     * e.g. => $animation->download('test.gif');
66
     *
67
     * @param string|null $destination destination for save the file
68
     *
69
     * @return bool|string string will be returned when destination doesn't set
70
     */
71
    public function download(string|null $destination = null): bool|string {
72
        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.gif',$this->file_id);
73
    }
74
}
75