UpdateMessageViews::typeSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
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
 * The view count of the message has changed.
13
 */
14
class UpdateMessageViews extends Update
15
{
16
    public const TYPE_NAME = 'updateMessageViews';
17
18
    /**
19
     * Chat identifier.
20
     *
21
     * @var int
22
     */
23
    protected int $chatId;
24
25
    /**
26
     * Message identifier.
27
     *
28
     * @var int
29
     */
30
    protected int $messageId;
31
32
    /**
33
     * New value of the view count.
34
     *
35
     * @var int
36
     */
37
    protected int $views;
38
39
    public function __construct(int $chatId, int $messageId, int $views)
40
    {
41
        parent::__construct();
42
43
        $this->chatId    = $chatId;
44
        $this->messageId = $messageId;
45
        $this->views     = $views;
46
    }
47
48
    public static function fromArray(array $array): UpdateMessageViews
49
    {
50
        return new static(
51
            $array['chat_id'],
52
            $array['message_id'],
53
            $array['views'],
54
        );
55
    }
56
57
    public function typeSerialize(): array
58
    {
59
        return [
60
            '@type'      => static::TYPE_NAME,
61
            'chat_id'    => $this->chatId,
62
            'message_id' => $this->messageId,
63
            'views'      => $this->views,
64
        ];
65
    }
66
67
    public function getChatId(): int
68
    {
69
        return $this->chatId;
70
    }
71
72
    public function getMessageId(): int
73
    {
74
        return $this->messageId;
75
    }
76
77
    public function getViews(): int
78
    {
79
        return $this->views;
80
    }
81
}
82