Photo   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getMinithumbnail() 0 3 1
A getHasStickers() 0 3 1
A __construct() 0 5 1
A getSizes() 0 3 1
A typeSerialize() 0 7 2
A fromArray() 0 6 2
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
 * Describes a photo.
13
 */
14
class Photo extends TdObject
15
{
16
    public const TYPE_NAME = 'photo';
17
18
    /**
19
     * True, if stickers were added to the photo.
20
     *
21
     * @var bool
22
     */
23
    protected bool $hasStickers;
24
25
    /**
26
     * Photo minithumbnail; may be null.
27
     *
28
     * @var Minithumbnail|null
29
     */
30
    protected ?Minithumbnail $minithumbnail;
31
32
    /**
33
     * Available variants of the photo, in different sizes.
34
     *
35
     * @var PhotoSize[]
36
     */
37
    protected array $sizes;
38
39
    public function __construct(bool $hasStickers, ?Minithumbnail $minithumbnail, array $sizes)
40
    {
41
        $this->hasStickers   = $hasStickers;
42
        $this->minithumbnail = $minithumbnail;
43
        $this->sizes         = $sizes;
44
    }
45
46
    public static function fromArray(array $array): Photo
47
    {
48
        return new static(
49
            $array['has_stickers'],
50
            (isset($array['minithumbnail']) ? TdSchemaRegistry::fromArray($array['minithumbnail']) : null),
51
            array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['sizes']),
52
        );
53
    }
54
55
    public function typeSerialize(): array
56
    {
57
        return [
58
            '@type'           => static::TYPE_NAME,
59
            'has_stickers'    => $this->hasStickers,
60
            'minithumbnail'   => (isset($this->minithumbnail) ? $this->minithumbnail : null),
61
            array_map(fn ($x) => $x->typeSerialize(), $this->sizes),
62
        ];
63
    }
64
65
    public function getHasStickers(): bool
66
    {
67
        return $this->hasStickers;
68
    }
69
70
    public function getMinithumbnail(): ?Minithumbnail
71
    {
72
        return $this->minithumbnail;
73
    }
74
75
    public function getSizes(): array
76
    {
77
        return $this->sizes;
78
    }
79
}
80