1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BPT\types; |
4
|
|
|
|
5
|
|
|
use BPT\telegram\telegram; |
6
|
|
|
use BPT\tools\tools; |
7
|
|
|
use stdClass; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). |
11
|
|
|
*/ |
12
|
|
|
class animation extends types { |
|
|
|
|
13
|
|
|
/** Keep all properties which has sub properties */ |
14
|
|
|
private const subs = ['thumbnail' => 'BPT\types\photoSize']; |
15
|
|
|
|
16
|
|
|
/** Identifier for this file, which can be used to download or reuse the file */ |
17
|
|
|
public string $file_id; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be |
21
|
|
|
* used to download or reuse the file. |
22
|
|
|
*/ |
23
|
|
|
public string $file_unique_id; |
24
|
|
|
|
25
|
|
|
/** Video width as defined by sender */ |
26
|
|
|
public int $width; |
27
|
|
|
|
28
|
|
|
/** Video height as defined by sender */ |
29
|
|
|
public int $height; |
30
|
|
|
|
31
|
|
|
/** Duration of the video in seconds as defined by sender */ |
32
|
|
|
public int $duration; |
33
|
|
|
|
34
|
|
|
/** Optional. Animation thumbnail as defined by sender */ |
35
|
|
|
public null|photoSize $thumbnail = null; |
36
|
|
|
|
37
|
|
|
/** Optional. Original animation filename as defined by sender */ |
38
|
|
|
public null|string $file_name = null; |
39
|
|
|
|
40
|
|
|
/** Optional. MIME type of the file as defined by sender */ |
41
|
|
|
public null|string $mime_type = null; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have |
45
|
|
|
* difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit |
46
|
|
|
* integer or double-precision float type are safe for storing this value. |
47
|
|
|
*/ |
48
|
|
|
public null|int $file_size = null; |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
public function __construct(stdClass|null $object = null) { |
52
|
|
|
if ($object != null) { |
53
|
|
|
parent::__construct($object, self::subs); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* download this file and save it in destination |
59
|
|
|
* |
60
|
|
|
* if destination doesn't set , it will return the downloaded file(as string) |
61
|
|
|
* |
62
|
|
|
* It has 20MB download limit(same as telegram) |
63
|
|
|
* |
64
|
|
|
* e.g. => $animation->download(); |
65
|
|
|
* |
66
|
|
|
* e.g. => $animation->download('test.gif'); |
67
|
|
|
* |
68
|
|
|
* @param string|null $destination destination for save the file |
69
|
|
|
* |
70
|
|
|
* @return bool|string string will be returned when destination doesn't set |
71
|
|
|
*/ |
72
|
|
|
public function download(string|null $destination = null): bool|string { |
73
|
|
|
return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.gif',$this->file_id); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get download link of this file |
78
|
|
|
* |
79
|
|
|
* It does not bypass telegram limits(e.g: Download size limit in public bot api) |
80
|
|
|
* |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
|
|
public function link(): string { |
84
|
|
|
return telegram::fileLink($this->file_id); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function typedSize (int $precision = 2, bool $space_between = true): string { |
88
|
|
|
return tools::byteFormat($this->file_id, $precision, $space_between); |
|
|
|
|
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths