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

document   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 53
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 a general file (as opposed to photos, voice messages and audio files).
10
 */
11
class document 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
    /** Optional. Document thumbnail as defined by sender */
25
    public photoSize $thumb;
26
27
    /** Optional. Original filename as defined by sender */
28
    public string $file_name;
29
30
    /** Optional. MIME type of the file as defined by sender */
31
    public string $mime_type;
32
33
    /**
34
     * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have
35
     * difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit
36
     * integer or double-precision float type are safe for storing this value.
37
     */
38
    public int $file_size;
39
40
41
    public function __construct(stdClass|null $object = null) {
42
        if ($object != null) {
43
            parent::__construct($object, self::subs);
44
        }
45
    }
46
47
    /**
48
     * download this file and save it in destination
49
     *
50
     * if destination doesn't set , it will save in `file_name` file
51
     *
52
     * It has 20MB download limit(same as telegram)
53
     *
54
     * e.g. => $document->download();
55
     *
56
     * e.g. => $document->download('test.zip');
57
     *
58
     * @param string|null $destination destination for save the file
59
     *
60
     * @return bool|string string will be returned when destination doesn't set
61
     */
62
    public function download(string|null $destination = null): bool|string {
63
        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.txt',$this->file_id);
64
    }
65
}
66