PageBlockChatLink::getPhoto()   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
 * A link to a chat.
13
 */
14
class PageBlockChatLink extends PageBlock
15
{
16
    public const TYPE_NAME = 'pageBlockChatLink';
17
18
    /**
19
     * Chat title.
20
     */
21
    protected string $title;
22
23
    /**
24
     * Chat photo; may be null.
25
     */
26
    protected ?ChatPhoto $photo;
27
28
    /**
29
     * Chat username, by which all other information about the chat should be resolved.
30
     */
31
    protected string $username;
32
33
    public function __construct(string $title, ?ChatPhoto $photo, string $username)
34
    {
35
        parent::__construct();
36
37
        $this->title    = $title;
38
        $this->photo    = $photo;
39
        $this->username = $username;
40
    }
41
42
    public static function fromArray(array $array): PageBlockChatLink
43
    {
44
        return new static(
45
            $array['title'],
46
            (isset($array['photo']) ? TdSchemaRegistry::fromArray($array['photo']) : null),
47
            $array['username'],
48
        );
49
    }
50
51
    public function typeSerialize(): array
52
    {
53
        return [
54
            '@type'    => static::TYPE_NAME,
55
            'title'    => $this->title,
56
            'photo'    => (isset($this->photo) ? $this->photo : null),
57
            'username' => $this->username,
58
        ];
59
    }
60
61
    public function getTitle(): string
62
    {
63
        return $this->title;
64
    }
65
66
    public function getPhoto(): ?ChatPhoto
67
    {
68
        return $this->photo;
69
    }
70
71
    public function getUsername(): string
72
    {
73
        return $this->username;
74
    }
75
}
76