GetChatMessageCount   A
last analyzed

Complexity

Total Complexity 6

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 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getChatId() 0 3 1
A getReturnLocal() 0 3 1
A typeSerialize() 0 7 1
A getFilter() 0 3 1
A __construct() 0 5 1
A fromArray() 0 6 1
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
 * Returns approximate number of messages of the specified type in the chat.
13
 */
14
class GetChatMessageCount extends TdFunction
15
{
16
    public const TYPE_NAME = 'getChatMessageCount';
17
18
    /**
19
     * Identifier of the chat in which to count messages.
20
     *
21
     * @var int
22
     */
23
    protected int $chatId;
24
25
    /**
26
     * Filter for message content; searchMessagesFilterEmpty is unsupported in this function.
27
     *
28
     * @var SearchMessagesFilter
29
     */
30
    protected SearchMessagesFilter $filter;
31
32
    /**
33
     * If true, returns count that is available locally without sending network requests, returning -1 if the number of messages is unknown.
34
     *
35
     * @var bool
36
     */
37
    protected bool $returnLocal;
38
39
    public function __construct(int $chatId, SearchMessagesFilter $filter, bool $returnLocal)
40
    {
41
        $this->chatId      = $chatId;
42
        $this->filter      = $filter;
43
        $this->returnLocal = $returnLocal;
44
    }
45
46
    public static function fromArray(array $array): GetChatMessageCount
47
    {
48
        return new static(
49
            $array['chat_id'],
50
            TdSchemaRegistry::fromArray($array['filter']),
51
            $array['return_local'],
52
        );
53
    }
54
55
    public function typeSerialize(): array
56
    {
57
        return [
58
            '@type'        => static::TYPE_NAME,
59
            'chat_id'      => $this->chatId,
60
            'filter'       => $this->filter->typeSerialize(),
61
            'return_local' => $this->returnLocal,
62
        ];
63
    }
64
65
    public function getChatId(): int
66
    {
67
        return $this->chatId;
68
    }
69
70
    public function getFilter(): SearchMessagesFilter
71
    {
72
        return $this->filter;
73
    }
74
75
    public function getReturnLocal(): bool
76
    {
77
        return $this->returnLocal;
78
    }
79
}
80