ChatEventLogFilters::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 10
dl 0
loc 22
rs 9.9332
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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
 * Represents a set of filters used to obtain a chat event log.
13
 */
14
class ChatEventLogFilters extends TdObject
15
{
16
    public const TYPE_NAME = 'chatEventLogFilters';
17
18
    /**
19
     * True, if message edits should be returned.
20
     *
21
     * @var bool
22
     */
23
    protected bool $messageEdits;
24
25
    /**
26
     * True, if message deletions should be returned.
27
     *
28
     * @var bool
29
     */
30
    protected bool $messageDeletions;
31
32
    /**
33
     * True, if pin/unpin events should be returned.
34
     *
35
     * @var bool
36
     */
37
    protected bool $messagePins;
38
39
    /**
40
     * True, if members joining events should be returned.
41
     *
42
     * @var bool
43
     */
44
    protected bool $memberJoins;
45
46
    /**
47
     * True, if members leaving events should be returned.
48
     *
49
     * @var bool
50
     */
51
    protected bool $memberLeaves;
52
53
    /**
54
     * True, if invited member events should be returned.
55
     *
56
     * @var bool
57
     */
58
    protected bool $memberInvites;
59
60
    /**
61
     * True, if member promotion/demotion events should be returned.
62
     *
63
     * @var bool
64
     */
65
    protected bool $memberPromotions;
66
67
    /**
68
     * True, if member restricted/unrestricted/banned/unbanned events should be returned.
69
     *
70
     * @var bool
71
     */
72
    protected bool $memberRestrictions;
73
74
    /**
75
     * True, if changes in chat information should be returned.
76
     *
77
     * @var bool
78
     */
79
    protected bool $infoChanges;
80
81
    /**
82
     * True, if changes in chat settings should be returned.
83
     *
84
     * @var bool
85
     */
86
    protected bool $settingChanges;
87
88
    public function __construct(
89
        bool $messageEdits,
90
        bool $messageDeletions,
91
        bool $messagePins,
92
        bool $memberJoins,
93
        bool $memberLeaves,
94
        bool $memberInvites,
95
        bool $memberPromotions,
96
        bool $memberRestrictions,
97
        bool $infoChanges,
98
        bool $settingChanges
99
    ) {
100
        $this->messageEdits       = $messageEdits;
101
        $this->messageDeletions   = $messageDeletions;
102
        $this->messagePins        = $messagePins;
103
        $this->memberJoins        = $memberJoins;
104
        $this->memberLeaves       = $memberLeaves;
105
        $this->memberInvites      = $memberInvites;
106
        $this->memberPromotions   = $memberPromotions;
107
        $this->memberRestrictions = $memberRestrictions;
108
        $this->infoChanges        = $infoChanges;
109
        $this->settingChanges     = $settingChanges;
110
    }
111
112
    public static function fromArray(array $array): ChatEventLogFilters
113
    {
114
        return new static(
115
            $array['message_edits'],
116
            $array['message_deletions'],
117
            $array['message_pins'],
118
            $array['member_joins'],
119
            $array['member_leaves'],
120
            $array['member_invites'],
121
            $array['member_promotions'],
122
            $array['member_restrictions'],
123
            $array['info_changes'],
124
            $array['setting_changes'],
125
        );
126
    }
127
128
    public function typeSerialize(): array
129
    {
130
        return [
131
            '@type'               => static::TYPE_NAME,
132
            'message_edits'       => $this->messageEdits,
133
            'message_deletions'   => $this->messageDeletions,
134
            'message_pins'        => $this->messagePins,
135
            'member_joins'        => $this->memberJoins,
136
            'member_leaves'       => $this->memberLeaves,
137
            'member_invites'      => $this->memberInvites,
138
            'member_promotions'   => $this->memberPromotions,
139
            'member_restrictions' => $this->memberRestrictions,
140
            'info_changes'        => $this->infoChanges,
141
            'setting_changes'     => $this->settingChanges,
142
        ];
143
    }
144
145
    public function getMessageEdits(): bool
146
    {
147
        return $this->messageEdits;
148
    }
149
150
    public function getMessageDeletions(): bool
151
    {
152
        return $this->messageDeletions;
153
    }
154
155
    public function getMessagePins(): bool
156
    {
157
        return $this->messagePins;
158
    }
159
160
    public function getMemberJoins(): bool
161
    {
162
        return $this->memberJoins;
163
    }
164
165
    public function getMemberLeaves(): bool
166
    {
167
        return $this->memberLeaves;
168
    }
169
170
    public function getMemberInvites(): bool
171
    {
172
        return $this->memberInvites;
173
    }
174
175
    public function getMemberPromotions(): bool
176
    {
177
        return $this->memberPromotions;
178
    }
179
180
    public function getMemberRestrictions(): bool
181
    {
182
        return $this->memberRestrictions;
183
    }
184
185
    public function getInfoChanges(): bool
186
    {
187
        return $this->infoChanges;
188
    }
189
190
    public function getSettingChanges(): bool
191
    {
192
        return $this->settingChanges;
193
    }
194
}
195