UserProfilePhoto::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 PHPTdGram\Schema;
10
11
/**
12
 * Contains full information about a user profile photo.
13
 */
14
class UserProfilePhoto extends TdObject
15
{
16
    public const TYPE_NAME = 'userProfilePhoto';
17
18
    /**
19
     * Unique user profile photo identifier.
20
     */
21
    protected string $id;
22
23
    /**
24
     * Point in time (Unix timestamp) when the photo has been added.
25
     */
26
    protected int $addedDate;
27
28
    /**
29
     * Available variants of the user photo, in different sizes.
30
     *
31
     * @var PhotoSize[]
32
     */
33
    protected array $sizes;
34
35
    public function __construct(string $id, int $addedDate, array $sizes)
36
    {
37
        $this->id        = $id;
38
        $this->addedDate = $addedDate;
39
        $this->sizes     = $sizes;
40
    }
41
42
    public static function fromArray(array $array): UserProfilePhoto
43
    {
44
        return new static(
45
            $array['id'],
46
            $array['added_date'],
47
            array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['sizes']),
48
        );
49
    }
50
51
    public function typeSerialize(): array
52
    {
53
        return [
54
            '@type'           => static::TYPE_NAME,
55
            'id'              => $this->id,
56
            'added_date'      => $this->addedDate,
57
            array_map(fn ($x) => $x->typeSerialize(), $this->sizes),
58
        ];
59
    }
60
61
    public function getId(): string
62
    {
63
        return $this->id;
64
    }
65
66
    public function getAddedDate(): int
67
    {
68
        return $this->addedDate;
69
    }
70
71
    public function getSizes(): array
72
    {
73
        return $this->sizes;
74
    }
75
}
76