ChatEventMemberRestricted   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getUserId() 0 3 1
A typeSerialize() 0 7 1
A fromArray() 0 6 1
A getOldStatus() 0 3 1
A getNewStatus() 0 3 1
A __construct() 0 7 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
 * A chat member was restricted/unrestricted or banned/unbanned, or the list of their restrictions has changed.
13
 */
14
class ChatEventMemberRestricted extends ChatEventAction
15
{
16
    public const TYPE_NAME = 'chatEventMemberRestricted';
17
18
    /**
19
     * Chat member user identifier.
20
     */
21
    protected int $userId;
22
23
    /**
24
     * Previous status of the chat member.
25
     */
26
    protected ChatMemberStatus $oldStatus;
27
28
    /**
29
     * New status of the chat member.
30
     */
31
    protected ChatMemberStatus $newStatus;
32
33
    public function __construct(int $userId, ChatMemberStatus $oldStatus, ChatMemberStatus $newStatus)
34
    {
35
        parent::__construct();
36
37
        $this->userId    = $userId;
38
        $this->oldStatus = $oldStatus;
39
        $this->newStatus = $newStatus;
40
    }
41
42
    public static function fromArray(array $array): ChatEventMemberRestricted
43
    {
44
        return new static(
45
            $array['user_id'],
46
            TdSchemaRegistry::fromArray($array['old_status']),
47
            TdSchemaRegistry::fromArray($array['new_status']),
48
        );
49
    }
50
51
    public function typeSerialize(): array
52
    {
53
        return [
54
            '@type'      => static::TYPE_NAME,
55
            'user_id'    => $this->userId,
56
            'old_status' => $this->oldStatus->typeSerialize(),
57
            'new_status' => $this->newStatus->typeSerialize(),
58
        ];
59
    }
60
61
    public function getUserId(): int
62
    {
63
        return $this->userId;
64
    }
65
66
    public function getOldStatus(): ChatMemberStatus
67
    {
68
        return $this->oldStatus;
69
    }
70
71
    public function getNewStatus(): ChatMemberStatus
72
    {
73
        return $this->newStatus;
74
    }
75
}
76