StorageStatisticsByFileType::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
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 AurimasNiekis\TdLibSchema;
10
11
/**
12
 * Contains the storage usage statistics for a specific file type.
13
 */
14
class StorageStatisticsByFileType extends TdObject
15
{
16
    public const TYPE_NAME = 'storageStatisticsByFileType';
17
18
    /**
19
     * File type.
20
     *
21
     * @var FileType
22
     */
23
    protected FileType $fileType;
24
25
    /**
26
     * Total size of the files.
27
     *
28
     * @var int
29
     */
30
    protected int $size;
31
32
    /**
33
     * Total number of files.
34
     *
35
     * @var int
36
     */
37
    protected int $count;
38
39
    public function __construct(FileType $fileType, int $size, int $count)
40
    {
41
        $this->fileType = $fileType;
42
        $this->size     = $size;
43
        $this->count    = $count;
44
    }
45
46
    public static function fromArray(array $array): StorageStatisticsByFileType
47
    {
48
        return new static(
49
            TdSchemaRegistry::fromArray($array['file_type']),
50
            $array['size'],
51
            $array['count'],
52
        );
53
    }
54
55
    public function typeSerialize(): array
56
    {
57
        return [
58
            '@type'     => static::TYPE_NAME,
59
            'file_type' => $this->fileType->typeSerialize(),
60
            'size'      => $this->size,
61
            'count'     => $this->count,
62
        ];
63
    }
64
65
    public function getFileType(): FileType
66
    {
67
        return $this->fileType;
68
    }
69
70
    public function getSize(): int
71
    {
72
        return $this->size;
73
    }
74
75
    public function getCount(): int
76
    {
77
        return $this->count;
78
    }
79
}
80