Passed
Pull Request — master (#248)
by
unknown
10:47
created

JoinMeetingParameters::setRedirect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 2
c 2
b 0
f 1
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5
 *
6
 * Copyright (c) 2016-2024 BigBlueButton Inc. and by respective authors (see below).
7
 *
8
 * This program is free software; you can redistribute it and/or modify it under the
9
 * terms of the GNU Lesser General Public License as published by the Free Software
10
 * Foundation; either version 3.0 of the License, or (at your option) any later
11
 * version.
12
 *
13
 * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public License along
18
 * with BigBlueButton; if not, see <https://www.gnu.org/licenses/>.
19
 */
20
21
namespace BigBlueButton\Parameters;
22
23
use BigBlueButton\Enum\MeetingLayout;
24
use BigBlueButton\Enum\Role;
25
26
/**
27
 * Class JoinMeetingParametersTest.
28
 */
29
class JoinMeetingParameters extends UserDataParameters
30
{
31
    private ?string $meetingId;
32
33
    private ?string $username;
34
35
    /**
36
     * @deprecated Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct()
37
     */
38
    private ?string $password = null;
39
40
    private ?string $userId = null;
41
42
    private ?string $webVoiceConf = null;
43
44
    private ?float $creationTime = null;
45
46
    private ?string $avatarURL = null;
47
48
    private ?bool $redirect = null;
49
50
    /**
51
     * @var array<string, string>
52
     */
53
    private array $customParameters;
54
55
    private ?Role $role = null;
56
57
    private ?bool $excludeFromDashboard = null;
58
59
    private ?bool $guest = null;
60
61
    private ?MeetingLayout $defaultLayout = null;
62
63
    /**
64
     * @param mixed $passwordOrRole
65
     * @param mixed $meetingId
66
     * @param mixed $username
67
     */
68
    public function __construct($meetingId = null, $username = null, $passwordOrRole = null)
69
    {
70
        $this->meetingId = $meetingId;
71
        $this->username  = $username;
72
73
        if (Role::MODERATOR === $passwordOrRole || Role::VIEWER === $passwordOrRole) {
74
            $this->role = $passwordOrRole;
75
        } else {
76
            $this->password = $passwordOrRole;
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Parameters...ngParameters::$password has been deprecated: Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

76
            /** @scrutinizer ignore-deprecated */ $this->password = $passwordOrRole;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
77
        }
78
        $this->customParameters = [];
79
    }
80
81
    public function getMeetingId(): ?string
82
    {
83
        return $this->meetingId;
84
    }
85
86
    public function setMeetingId(string $meetingId): JoinMeetingParameters
87
    {
88
        $this->meetingId = $meetingId;
89
90
        return $this;
91
    }
92
93
    public function getUsername(): ?string
94
    {
95
        return $this->username;
96
    }
97
98
    public function setUsername(string $username): self
99
    {
100
        $this->username = $username;
101
102
        return $this;
103
    }
104
105
    /**
106
     * @deprecated Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct()
107
     */
108
    public function getPassword(): ?string
109
    {
110
        return $this->password;
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Parameters...ngParameters::$password has been deprecated: Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

110
        return /** @scrutinizer ignore-deprecated */ $this->password;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
111
    }
112
113
    /**
114
     *@deprecated Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct()
115
     */
116
    public function setPassword(string $password): self
117
    {
118
        $this->password = $password;
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Parameters...ngParameters::$password has been deprecated: Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

118
        /** @scrutinizer ignore-deprecated */ $this->password = $password;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
119
120
        return $this;
121
    }
122
123
    public function getUserId(): ?string
124
    {
125
        return $this->userId;
126
    }
127
128
    public function setUserId(string $userId): self
129
    {
130
        $this->userId = $userId;
131
132
        return $this;
133
    }
134
135
    public function getWebVoiceConf(): ?string
136
    {
137
        return $this->webVoiceConf;
138
    }
139
140
    public function setWebVoiceConf(string $webVoiceConf): self
141
    {
142
        $this->webVoiceConf = $webVoiceConf;
143
144
        return $this;
145
    }
146
147
    public function getCreationTime(): ?float
148
    {
149
        return $this->creationTime;
150
    }
151
152
    public function setCreationTime(float $creationTime): self
153
    {
154
        $this->creationTime = $creationTime;
155
156
        return $this;
157
    }
158
159
    public function getAvatarURL(): ?string
160
    {
161
        return $this->avatarURL;
162
    }
163
164
    public function setAvatarURL(string $avatarURL): self
165
    {
166
        $this->avatarURL = $avatarURL;
167
168
        return $this;
169
    }
170
171
    public function isRedirect(): ?bool
172
    {
173
        return $this->redirect;
174
    }
175
176
    public function setRedirect(bool $redirect): self
177
    {
178
        $this->redirect = $redirect;
179
180
        return $this;
181
    }
182
183
    public function getRole(): ?Role
184
    {
185
        return $this->role;
186
    }
187
188
    public function setRole(Role $role): self
189
    {
190
        $this->role = $role;
191
192
        return $this;
193
    }
194
195
    public function isExcludeFromDashboard(): ?bool
196
    {
197
        return $this->excludeFromDashboard;
198
    }
199
200
    public function setExcludeFromDashboard(bool $excludeFromDashboard): self
201
    {
202
        $this->excludeFromDashboard = $excludeFromDashboard;
203
204
        return $this;
205
    }
206
207
    public function isGuest(): ?bool
208
    {
209
        return $this->guest;
210
    }
211
212
    public function setGuest(bool $guest): self
213
    {
214
        $this->guest = $guest;
215
216
        return $this;
217
    }
218
219
    public function getDefaultLayout(): ?MeetingLayout
220
    {
221
        return $this->defaultLayout;
222
    }
223
224
    public function setDefaultLayout(MeetingLayout $defaultLayout): self
225
    {
226
        $this->defaultLayout = $defaultLayout;
227
228
        return $this;
229
    }
230
231
    public function setCustomParameter(string $paramName, string $paramValue): self
232
    {
233
        $this->customParameters[$paramName] = $paramValue;
234
235
        return $this;
236
    }
237
238
    public function getHTTPQuery(): string
239
    {
240
        $queries = [
241
            'meetingID'            => $this->meetingId,
242
            'fullName'             => $this->username,
243
            'password'             => $this->password,
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Parameters...ngParameters::$password has been deprecated: Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

243
            'password'             => /** @scrutinizer ignore-deprecated */ $this->password,

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
244
            'userID'               => $this->userId,
245
            'webVoiceConf'         => $this->webVoiceConf,
246
            'createTime'           => $this->creationTime,
247
            'role'                 => is_null($this->role) ? null : $this->role->value,
248
            'excludeFromDashboard' => !is_null($this->excludeFromDashboard) ? ($this->excludeFromDashboard ? 'true' : 'false') : $this->excludeFromDashboard,
249
            'avatarURL'            => $this->avatarURL,
250
            'redirect'             => !is_null($this->redirect) ? ($this->redirect ? 'true' : 'false') : $this->redirect,
251
            'guest'                => !is_null($this->guest) ? ($this->guest ? 'true' : 'false') : $this->guest,
252
            'defaultLayout'        => is_null($this->defaultLayout) ? null : $this->defaultLayout->value,
253
        ];
254
255
        foreach ($this->customParameters as $key => $value) {
256
            $queries[$key] = $value;
257
        }
258
259
        $this->buildUserData($queries);
260
261
        return $this->buildHTTPQuery($queries);
262
    }
263
}
264