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

Attendee::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 11
c 2
b 1
f 0
dl 0
loc 14
rs 9.9
cc 3
nc 3
nop 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
class Attendee
24
{
25
    /**
26
     * @var string
27
     */
28
    private $userId;
29
30
    /**
31
     * @var string
32
     */
33
    private $fullName;
34
35
    /**
36
     * @var string
37
     */
38
    private $role;
39
40
    /**
41
     * @var bool
42
     */
43
    private $isPresenter;
44
45
    /**
46
     * @var bool
47
     */
48
    private $isListeningOnly;
49
50
    /**
51
     * @var bool
52
     */
53
    private $hasJoinedVoice;
54
55
    /**
56
     * @var bool
57
     */
58
    private $hasVideo;
59
60
    /**
61
     * @var array
62
     */
63
    private $customData = [];
64
65
    /**
66
     * @var string
67
     */
68
    private $clientType;
69
70
    /**
71
     * Attendee constructor.
72
     *
73
     * @param $xml \SimpleXMLElement
74
     */
75
    public function __construct($xml)
76
    {
77
        $this->userId          = $xml->userID->__toString();
78
        $this->fullName        = $xml->fullName->__toString();
79
        $this->role            = $xml->role->__toString();
80
        $this->isPresenter     = 'true' === $xml->isPresenter->__toString();
81
        $this->isListeningOnly = 'true' === $xml->isListeningOnly->__toString();
82
        $this->hasJoinedVoice  = 'true' === $xml->hasJoinedVoice->__toString();
83
        $this->hasVideo        = 'true' === $xml->hasVideo->__toString();
84
        $this->clientType      = $xml->clientType->__toString();
85
86
        if ($xml->customdata) {
87
            foreach ($xml->customdata->children() as $data) {
88
                $this->customData[$data->getName()] = $data->__toString();
89
            }
90
        }
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getUserId()
97
    {
98
        return $this->userId;
99
    }
100
101
    /**
102
     * @return string
103
     */
104
    public function getFullName()
105
    {
106
        return $this->fullName;
107
    }
108
109
    /**
110
     * @return string
111
     */
112
    public function getRole()
113
    {
114
        return $this->role;
115
    }
116
117
    /**
118
     * @return null|bool
119
     */
120
    public function isPresenter()
121
    {
122
        return $this->isPresenter;
123
    }
124
125
    /**
126
     * @return null|bool
127
     */
128
    public function isListeningOnly()
129
    {
130
        return $this->isListeningOnly;
131
    }
132
133
    /**
134
     * @return null|bool
135
     */
136
    public function hasJoinedVoice()
137
    {
138
        return $this->hasJoinedVoice;
139
    }
140
141
    /**
142
     * @return null|bool
143
     */
144
    public function hasVideo()
145
    {
146
        return $this->hasVideo;
147
    }
148
149
    /**
150
     * @return string
151
     */
152
    public function getClientType()
153
    {
154
        return $this->clientType;
155
    }
156
157
    /**
158
     * @return array
159
     */
160
    public function getCustomData()
161
    {
162
        return $this->customData;
163
    }
164
}
165