Passed
Pull Request — master (#189)
by Ghazi
10:24
created

Meeting   A

Complexity

Total Complexity 32

Size/Duplication

Total Lines 406
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 32
eloc 92
c 4
b 0
f 0
dl 0
loc 406
rs 9.84

28 Methods

Rating   Name   Duplication   Size   Complexity  
A getMeetingId() 0 3 1
A getCreationDate() 0 3 1
A getMetas() 0 10 3
A isRecording() 0 3 1
A getCreationTime() 0 3 1
A hasBeenForciblyEnded() 0 3 1
A getAttendeePassword() 0 3 1
A getMeetingName() 0 3 1
A getModeratorCount() 0 3 1
A getStartTime() 0 3 1
A isBreakout() 0 3 1
A __construct() 0 26 1
A getListenerCount() 0 3 1
A hasUserJoined() 0 3 1
A getMaxUsers() 0 3 1
A getAttendees() 0 10 3
A getModeratorPassword() 0 3 1
A getParticipantCount() 0 3 1
A getEndTime() 0 3 1
A getVoiceBridge() 0 3 1
A isRunning() 0 3 1
A getDuration() 0 3 1
A getInternalMeetingId() 0 3 1
A getDialNumber() 0 3 1
A getVoiceParticipantCount() 0 3 1
A getVideoCount() 0 3 1
A getViewers() 0 9 1
A getModerators() 0 9 1
1
<?php
2
3
/*
4
 * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5
 *
6
 * Copyright (c) 2016-2022 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 <http://www.gnu.org/licenses/>.
19
 */
20
21
namespace BigBlueButton\Core;
22
23
/**
24
 * Class Meeting.
25
 */
26
class Meeting
27
{
28
    /**
29
     * @var \SimpleXMLElement
30
     */
31
    protected $rawXml;
32
33
    /**
34
     * @var string
35
     */
36
    private $meetingId;
37
38
    /**
39
     * @var string
40
     */
41
    private $meetingName;
42
43
    /**
44
     * @var float
45
     */
46
    private $creationTime;
47
48
    /**
49
     * @var string
50
     */
51
    private $creationDate;
52
53
    /**
54
     * @var int
55
     */
56
    private $voiceBridge;
57
58
    /**
59
     * @var string
60
     */
61
    private $dialNumber;
62
63
    /**
64
     * @var string
65
     */
66
    private $attendeePassword;
67
68
    /**
69
     * @var string
70
     */
71
    private $moderatorPassword;
72
73
    /**
74
     * @var bool
75
     */
76
    private $hasBeenForciblyEnded;
77
78
    /**
79
     * @var bool
80
     */
81
    private $isRunning;
82
83
    /**
84
     * @var int
85
     */
86
    private $participantCount;
87
88
    /**
89
     * @var int
90
     */
91
    private $listenerCount;
92
93
    /**
94
     * @var int
95
     */
96
    private $voiceParticipantCount;
97
98
    /**
99
     * @var int
100
     */
101
    private $videoCount;
102
103
    /**
104
     * @var int
105
     */
106
    private $duration;
107
108
    /**
109
     * @var bool
110
     */
111
    private $hasUserJoined;
112
113
    /**
114
     * @var string
115
     */
116
    private $internalMeetingId;
117
118
    /**
119
     * @var bool
120
     */
121
    private $isRecording;
122
123
    /**
124
     * @var float
125
     */
126
    private $startTime;
127
128
    /**
129
     * @var float
130
     */
131
    private $endTime;
132
133
    /**
134
     * @var int
135
     */
136
    private $maxUsers;
137
138
    /**
139
     * @var int
140
     */
141
    private $moderatorCount;
142
143
    /**
144
     * @var Attendee[]
145
     */
146
    private $attendees;
147
148
    /**
149
     * @var array
150
     */
151
    private $metas;
152
153
    /**
154
     * @var bool
155
     */
156
    private $isBreakout;
157
158
    /**
159
     * Meeting constructor.
160
     *
161
     * @param $xml \SimpleXMLElement
162
     */
163
    public function __construct($xml)
164
    {
165
        $this->rawXml                = $xml;
166
        $this->meetingId             = $xml->meetingID->__toString();
167
        $this->meetingName           = $xml->meetingName->__toString();
168
        $this->creationTime          = (float) $xml->createTime;
169
        $this->creationDate          = $xml->createDate->__toString();
170
        $this->voiceBridge           = (int) $xml->voiceBridge;
171
        $this->dialNumber            = $xml->dialNumber->__toString();
172
        $this->attendeePassword      = $xml->attendeePW->__toString();
173
        $this->moderatorPassword     = $xml->moderatorPW->__toString();
174
        $this->hasBeenForciblyEnded  = 'true' === $xml->hasBeenForciblyEnded->__toString();
175
        $this->isRunning             = 'true' === $xml->running->__toString();
176
        $this->participantCount      = (int) $xml->participantCount;
177
        $this->listenerCount         = (int) $xml->listenerCount;
178
        $this->voiceParticipantCount = (int) $xml->voiceParticipantCount;
179
        $this->videoCount            = (int) $xml->videoCount;
180
        $this->duration              = (int) $xml->duration;
181
        $this->hasUserJoined         = 'true' === $xml->hasUserJoined->__toString();
182
        $this->internalMeetingId     = $xml->internalMeetingID->__toString();
183
        $this->isRecording           = 'true' === $xml->recording->__toString();
184
        $this->startTime             = (float) $xml->startTime;
185
        $this->endTime               = (float) $xml->endTime;
186
        $this->maxUsers              = (int) $xml->maxUsers->__toString();
187
        $this->moderatorCount        = (int) $xml->moderatorCount->__toString();
188
        $this->isBreakout            = 'true' === $xml->isBreakout->__toString();
189
    }
190
191
    /**
192
     * @return string
193
     */
194
    public function getMeetingId()
195
    {
196
        return $this->meetingId;
197
    }
198
199
    /**
200
     * @return string
201
     */
202
    public function getMeetingName()
203
    {
204
        return $this->meetingName;
205
    }
206
207
    /**
208
     * @return float
209
     */
210
    public function getCreationTime()
211
    {
212
        return $this->creationTime;
213
    }
214
215
    /**
216
     * @return string
217
     */
218
    public function getCreationDate()
219
    {
220
        return $this->creationDate;
221
    }
222
223
    /**
224
     * @return int
225
     */
226
    public function getVoiceBridge()
227
    {
228
        return $this->voiceBridge;
229
    }
230
231
    /**
232
     * @return string
233
     */
234
    public function getDialNumber()
235
    {
236
        return $this->dialNumber;
237
    }
238
239
    /**
240
     * @return string
241
     */
242
    public function getAttendeePassword()
243
    {
244
        return $this->attendeePassword;
245
    }
246
247
    /**
248
     * @return string
249
     */
250
    public function getModeratorPassword()
251
    {
252
        return $this->moderatorPassword;
253
    }
254
255
    /**
256
     * @return null|bool
257
     */
258
    public function hasBeenForciblyEnded()
259
    {
260
        return $this->hasBeenForciblyEnded;
261
    }
262
263
    /**
264
     * @return null|bool
265
     */
266
    public function isRunning()
267
    {
268
        return $this->isRunning;
269
    }
270
271
    /**
272
     * @return int
273
     */
274
    public function getParticipantCount()
275
    {
276
        return $this->participantCount;
277
    }
278
279
    /**
280
     * @return int
281
     */
282
    public function getListenerCount()
283
    {
284
        return $this->listenerCount;
285
    }
286
287
    /**
288
     * @return int
289
     */
290
    public function getVoiceParticipantCount()
291
    {
292
        return $this->voiceParticipantCount;
293
    }
294
295
    /**
296
     * @return int
297
     */
298
    public function getVideoCount()
299
    {
300
        return $this->videoCount;
301
    }
302
303
    /**
304
     * @return int
305
     */
306
    public function getDuration()
307
    {
308
        return $this->duration;
309
    }
310
311
    /**
312
     * @return null|bool
313
     */
314
    public function hasUserJoined()
315
    {
316
        return $this->hasUserJoined;
317
    }
318
319
    /**
320
     * @return string
321
     */
322
    public function getInternalMeetingId()
323
    {
324
        return $this->internalMeetingId;
325
    }
326
327
    /**
328
     * @return null|bool
329
     */
330
    public function isRecording()
331
    {
332
        return $this->isRecording;
333
    }
334
335
    /**
336
     * @return float
337
     */
338
    public function getStartTime()
339
    {
340
        return $this->startTime;
341
    }
342
343
    /**
344
     * @return float
345
     */
346
    public function getEndTime()
347
    {
348
        return $this->endTime;
349
    }
350
351
    /**
352
     * @return int
353
     */
354
    public function getMaxUsers()
355
    {
356
        return $this->maxUsers;
357
    }
358
359
    /**
360
     * @return int
361
     */
362
    public function getModeratorCount()
363
    {
364
        return $this->moderatorCount;
365
    }
366
367
    /**
368
     * @return Attendee[]
369
     */
370
    public function getAttendees()
371
    {
372
        if (null === $this->attendees) {
373
            $this->attendees = [];
374
            foreach ($this->rawXml->attendees->attendee as $attendeeXml) {
375
                $this->attendees[] = new Attendee($attendeeXml);
376
            }
377
        }
378
379
        return $this->attendees;
380
    }
381
382
    /**
383
     * Moderators of Meeting - Subset of Attendees.
384
     *
385
     * @return Attendee[]
386
     */
387
    public function getModerators()
388
    {
389
        $attendees = $this->getAttendees();
390
391
        $moderators = array_filter($attendees, function($attendee) {
392
            return 'MODERATOR' === $attendee->getRole();
393
        });
394
395
        return array_values($moderators);
396
    }
397
398
    /**
399
     * Viewers of Meeting - Subset of Attendees.
400
     *
401
     * @return Attendee[]
402
     */
403
    public function getViewers()
404
    {
405
        $attendees = $this->getAttendees();
406
407
        $viewers = array_filter($attendees, function($attendee) {
408
            return 'VIEWER' === $attendee->getRole();
409
        });
410
411
        return array_values($viewers);
412
    }
413
414
    /**
415
     * @return array
416
     */
417
    public function getMetas()
418
    {
419
        if (null === $this->metas) {
420
            $this->metas = [];
421
            foreach ($this->rawXml->metadata->children() as $metadataXml) {
422
                $this->metas[$metadataXml->getName()] = $metadataXml->__toString();
423
            }
424
        }
425
426
        return $this->metas;
427
    }
428
429
    public function isBreakout(): bool
430
    {
431
        return $this->isBreakout;
432
    }
433
}
434