Photo   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A typeSerialize() 0 7 2
A __construct() 0 5 1
A fromArray() 0 6 2
A getMinithumbnail() 0 3 1
A getHasStickers() 0 3 1
A getSizes() 0 3 1
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
 * 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
    protected bool $hasStickers;
22
23
    /**
24
     * Photo minithumbnail; may be null.
25
     */
26
    protected ?Minithumbnail $minithumbnail;
27
28
    /**
29
     * Available variants of the photo, in different sizes.
30
     *
31
     * @var PhotoSize[]
32
     */
33
    protected array $sizes;
34
35
    public function __construct(bool $hasStickers, ?Minithumbnail $minithumbnail, array $sizes)
36
    {
37
        $this->hasStickers   = $hasStickers;
38
        $this->minithumbnail = $minithumbnail;
39
        $this->sizes         = $sizes;
40
    }
41
42
    public static function fromArray(array $array): Photo
43
    {
44
        return new static(
45
            $array['has_stickers'],
46
            (isset($array['minithumbnail']) ? TdSchemaRegistry::fromArray($array['minithumbnail']) : null),
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
            'has_stickers'    => $this->hasStickers,
56
            'minithumbnail'   => (isset($this->minithumbnail) ? $this->minithumbnail : null),
57
            array_map(fn ($x) => $x->typeSerialize(), $this->sizes),
58
        ];
59
    }
60
61
    public function getHasStickers(): bool
62
    {
63
        return $this->hasStickers;
64
    }
65
66
    public function getMinithumbnail(): ?Minithumbnail
67
    {
68
        return $this->minithumbnail;
69
    }
70
71
    public function getSizes(): array
72
    {
73
        return $this->sizes;
74
    }
75
}
76