Completed
Push — master ( 6710d9...a1d3d8 )
by Ghazi
01:40
created

Meeting::getDuration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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