File::getExpectedSize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace PHPTdGram\Schema;
10
11
/**
12
 * Represents a file.
13
 */
14
class File extends TdObject
15
{
16
    public const TYPE_NAME = 'file';
17
18
    /**
19
     * Unique file identifier.
20
     */
21
    protected int $id;
22
23
    /**
24
     * File size; 0 if unknown.
25
     */
26
    protected int $size;
27
28
    /**
29
     * Expected file size in case the exact file size is unknown, but an approximate size is known. Can be used to show download/upload progress.
30
     */
31
    protected int $expectedSize;
32
33
    /**
34
     * Information about the local copy of the file.
35
     */
36
    protected LocalFile $local;
37
38
    /**
39
     * Information about the remote copy of the file.
40
     */
41
    protected RemoteFile $remote;
42
43
    public function __construct(int $id, int $size, int $expectedSize, LocalFile $local, RemoteFile $remote)
44
    {
45
        $this->id           = $id;
46
        $this->size         = $size;
47
        $this->expectedSize = $expectedSize;
48
        $this->local        = $local;
49
        $this->remote       = $remote;
50
    }
51
52
    public static function fromArray(array $array): File
53
    {
54
        return new static(
55
            $array['id'],
56
            $array['size'],
57
            $array['expected_size'],
58
            TdSchemaRegistry::fromArray($array['local']),
59
            TdSchemaRegistry::fromArray($array['remote']),
60
        );
61
    }
62
63
    public function typeSerialize(): array
64
    {
65
        return [
66
            '@type'         => static::TYPE_NAME,
67
            'id'            => $this->id,
68
            'size'          => $this->size,
69
            'expected_size' => $this->expectedSize,
70
            'local'         => $this->local->typeSerialize(),
71
            'remote'        => $this->remote->typeSerialize(),
72
        ];
73
    }
74
75
    public function getId(): int
76
    {
77
        return $this->id;
78
    }
79
80
    public function getSize(): int
81
    {
82
        return $this->size;
83
    }
84
85
    public function getExpectedSize(): int
86
    {
87
        return $this->expectedSize;
88
    }
89
90
    public function getLocal(): LocalFile
91
    {
92
        return $this->local;
93
    }
94
95
    public function getRemote(): RemoteFile
96
    {
97
        return $this->remote;
98
    }
99
}
100