StickerSet::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 12
dl 0
loc 26
rs 9.8666
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 PHPTdGram\Schema;
10
11
/**
12
 * Represents a sticker set.
13
 */
14
class StickerSet extends TdObject
15
{
16
    public const TYPE_NAME = 'stickerSet';
17
18
    /**
19
     * Identifier of the sticker set.
20
     */
21
    protected string $id;
22
23
    /**
24
     * Title of the sticker set.
25
     */
26
    protected string $title;
27
28
    /**
29
     * Name of the sticker set.
30
     */
31
    protected string $name;
32
33
    /**
34
     * Sticker set thumbnail in WEBP format with width and height 100; may be null. The file can be downloaded only before the thumbnail is changed.
35
     */
36
    protected ?PhotoSize $thumbnail;
37
38
    /**
39
     * True, if the sticker set has been installed by the current user.
40
     */
41
    protected bool $isInstalled;
42
43
    /**
44
     * True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously.
45
     */
46
    protected bool $isArchived;
47
48
    /**
49
     * True, if the sticker set is official.
50
     */
51
    protected bool $isOfficial;
52
53
    /**
54
     * True, is the stickers in the set are animated.
55
     */
56
    protected bool $isAnimated;
57
58
    /**
59
     * True, if the stickers in the set are masks.
60
     */
61
    protected bool $isMasks;
62
63
    /**
64
     * True for already viewed trending sticker sets.
65
     */
66
    protected bool $isViewed;
67
68
    /**
69
     * List of stickers in this set.
70
     *
71
     * @var Sticker[]
72
     */
73
    protected array $stickers;
74
75
    /**
76
     * A list of emoji corresponding to the stickers in the same order. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object.
77
     *
78
     * @var Emojis[]
79
     */
80
    protected array $emojis;
81
82
    public function __construct(
83
        string $id,
84
        string $title,
85
        string $name,
86
        ?PhotoSize $thumbnail,
87
        bool $isInstalled,
88
        bool $isArchived,
89
        bool $isOfficial,
90
        bool $isAnimated,
91
        bool $isMasks,
92
        bool $isViewed,
93
        array $stickers,
94
        array $emojis
95
    ) {
96
        $this->id          = $id;
97
        $this->title       = $title;
98
        $this->name        = $name;
99
        $this->thumbnail   = $thumbnail;
100
        $this->isInstalled = $isInstalled;
101
        $this->isArchived  = $isArchived;
102
        $this->isOfficial  = $isOfficial;
103
        $this->isAnimated  = $isAnimated;
104
        $this->isMasks     = $isMasks;
105
        $this->isViewed    = $isViewed;
106
        $this->stickers    = $stickers;
107
        $this->emojis      = $emojis;
108
    }
109
110
    public static function fromArray(array $array): StickerSet
111
    {
112
        return new static(
113
            $array['id'],
114
            $array['title'],
115
            $array['name'],
116
            (isset($array['thumbnail']) ? TdSchemaRegistry::fromArray($array['thumbnail']) : null),
117
            $array['is_installed'],
118
            $array['is_archived'],
119
            $array['is_official'],
120
            $array['is_animated'],
121
            $array['is_masks'],
122
            $array['is_viewed'],
123
            array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['stickers']),
124
            array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['emojis']),
125
        );
126
    }
127
128
    public function typeSerialize(): array
129
    {
130
        return [
131
            '@type'           => static::TYPE_NAME,
132
            'id'              => $this->id,
133
            'title'           => $this->title,
134
            'name'            => $this->name,
135
            'thumbnail'       => (isset($this->thumbnail) ? $this->thumbnail : null),
136
            'is_installed'    => $this->isInstalled,
137
            'is_archived'     => $this->isArchived,
138
            'is_official'     => $this->isOfficial,
139
            'is_animated'     => $this->isAnimated,
140
            'is_masks'        => $this->isMasks,
141
            'is_viewed'       => $this->isViewed,
142
            array_map(fn ($x) => $x->typeSerialize(), $this->stickers),
143
            array_map(fn ($x) => $x->typeSerialize(), $this->emojis),
144
        ];
145
    }
146
147
    public function getId(): string
148
    {
149
        return $this->id;
150
    }
151
152
    public function getTitle(): string
153
    {
154
        return $this->title;
155
    }
156
157
    public function getName(): string
158
    {
159
        return $this->name;
160
    }
161
162
    public function getThumbnail(): ?PhotoSize
163
    {
164
        return $this->thumbnail;
165
    }
166
167
    public function getIsInstalled(): bool
168
    {
169
        return $this->isInstalled;
170
    }
171
172
    public function getIsArchived(): bool
173
    {
174
        return $this->isArchived;
175
    }
176
177
    public function getIsOfficial(): bool
178
    {
179
        return $this->isOfficial;
180
    }
181
182
    public function getIsAnimated(): bool
183
    {
184
        return $this->isAnimated;
185
    }
186
187
    public function getIsMasks(): bool
188
    {
189
        return $this->isMasks;
190
    }
191
192
    public function getIsViewed(): bool
193
    {
194
        return $this->isViewed;
195
    }
196
197
    public function getStickers(): array
198
    {
199
        return $this->stickers;
200
    }
201
202
    public function getEmojis(): array
203
    {
204
        return $this->emojis;
205
    }
206
}
207