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

voice   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A download() 0 2 1
A __construct() 0 3 2
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\api\telegram;
6
use stdClass;
7
8
/**
9
 * This object represents a voice note.
10
 */
11
class voice 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
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
    /** Duration of the audio in seconds as defined by sender */
25
    public int $duration;
26
27
    /** Optional. MIME type of the file as defined by sender */
28
    public string $mime_type;
29
30
    /**
31
     * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have
32
     * difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit
33
     * integer or double-precision float type are safe for storing this value.
34
     */
35
    public int $file_size;
36
37
38
    public function __construct(stdClass|null $object = null) {
39
        if ($object != null) {
40
            parent::__construct($object, self::subs);
41
        }
42
    }
43
44
    /**
45
     * download this file and save it in destination
46
     *
47
     * if destination doesn't set , it will save in `file_name` file
48
     *
49
     * It has 20MB download limit(same as telegram)
50
     *
51
     * e.g. => $voice->download();
52
     *
53
     * e.g. => $voice->download('test.ogg');
54
     *
55
     * @param string|null $destination destination for save the file
56
     *
57
     * @return bool|string string will be returned when destination doesn't set
58
     */
59
    public function download(string|null $destination = null): bool|string {
60
        return telegram::downloadFile($destination ?? 'unknown.ogg',$this->file_id);
61
    }
62
}
63