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

chatPhoto::download()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 2
rs 10
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\api\telegram;
6
use stdClass;
7
8
/**
9
 * This object represents a chat photo.
10
 */
11
class chatPhoto 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
    /**
16
     * File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for
17
     * as long as the photo is not changed.
18
     */
19
    public string $small_file_id;
20
21
    /**
22
     * Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for
23
     * different bots. Can't be used to download or reuse the file.
24
     */
25
    public string $small_file_unique_id;
26
27
    /**
28
     * File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as
29
     * long as the photo is not changed.
30
     */
31
    public string $big_file_id;
32
33
    /**
34
     * Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for
35
     * different bots. Can't be used to download or reuse the file.
36
     */
37
    public string $big_file_unique_id;
38
39
40
    public function __construct(stdClass|null $object = null) {
41
        if ($object != null) {
42
            parent::__construct($object, self::subs);
43
        }
44
    }
45
46
    /**
47
     * download this file and save it in destination
48
     *
49
     * if destination doesn't set , it will return the downloaded file(as string)
50
     *
51
     * It has 20MB download limit(same as telegram)
52
     *
53
     * e.g. => $photo->download();
54
     *
55
     * e.g. => $photo->download('test.mp4');
56
     *
57
     * @param string|null $destination destination for save the file
58
     * @param bool $big select big or small photo to download
59
     *
60
     * @return bool|string string will be returned when destination doesn't set
61
     */
62
    public function download(string|null $destination = null,bool $big = true): bool|string {
63
        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.mp4',$big ? $this->big_file_id : $this->small_file_id);
64
    }
65
}
66