Completed
Push — master ( 5959a8...2e5ec2 )
by Jignesh
01:13
created

Bbb::start()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace JoisarJignesh\Bigbluebutton;
5
6
use BigBlueButton\BigBlueButton;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, JoisarJignesh\Bigbluebutton\BigBlueButton.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
7
use BigBlueButton\Parameters\CreateMeetingParameters;
8
use BigBlueButton\Parameters\DeleteRecordingsParameters;
9
use BigBlueButton\Parameters\EndMeetingParameters;
10
use BigBlueButton\Parameters\GetMeetingInfoParameters;
11
use BigBlueButton\Parameters\GetRecordingsParameters;
12
use BigBlueButton\Parameters\IsMeetingRunningParameters;
13
use BigBlueButton\Parameters\JoinMeetingParameters;
14
use BigBlueButton\Parameters\PublishRecordingsParameters;
15
use BigBlueButton\Parameters\SetConfigXMLParameters;
16
use JoisarJignesh\Bigbluebutton\Services\initMeeting;
17
18
class Bbb
19
{
20
    use initMeeting;
21
22
    /**
23
     * @var
24
     */
25
    private $response;
26
    /**
27
     * @var BigBlueButton
28
     */
29
    protected $bbb;
30
31
32
    /**
33
     * Bbb constructor.
34
     *
35
     * @param BigBlueButton $bbb
36
     */
37
    public function __construct(BigBlueButton $bbb)
38
    {
39
        $this->bbb = $bbb;
40
    }
41
42
    /**
43
     * @return BigBlueButton
44
     */
45
    public function make()
46
    {
47
        return $this->bbb;
48
    }
49
    /**
50
     *  Return a list of all meetings
51
     *
52
     * @return \Illuminate\Support\Collection
53
     */
54
    public function all()
55
    {
56
        $this->response = $this->bbb->getMeetings();
57 View Code Duplication
        if ($this->response->success()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
            if (count($this->response->getRawXml()->meetings->meeting) > 0) {
59
                $meetings = [];
60
                foreach ($this->response->getRawXml()->meetings->meeting as $meeting) {
61
                    $meetings[] = XmlToArray($meeting);
62
                }
63
64
                return collect(XmlToArray($meetings));
65
            }
66
        }
67
68
        return collect([]);
69
    }
70
71
72
    /**
73
     * $meeting
74
     *
75
     * @param $meeting
76
     *
77
     * required fields
78
     * meetingID
79
     * meetingName
80
     *
81
     * @return mixed
82
     */
83 View Code Duplication
    public function create($meeting)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
84
    {
85
        if (!$meeting instanceof CreateMeetingParameters) {
86
            $meeting = $this->initCreateMeeting($meeting);
87
        }
88
89
        $this->response = $this->bbb->createMeeting($meeting);
90
        if ($this->response->failed()) {
91
            return $this->response->getMessage();
92
        } else {
93
            return collect(XmlToArray($this->response->getRawXml()));
94
        }
95
    }
96
97
    /**
98
     * @param $meeting
99
     *
100
     * required fields:
101
     * meetingID
102
     *
103
     * @return bool
104
     */
105 View Code Duplication
    public function isMeetingRunning($meeting)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
106
    {
107
        if (!$meeting instanceof IsMeetingRunningParameters) {
108
            $meeting = $this->initIsMeetingRunning($meeting);
109
        }
110
111
        $this->response = $this->bbb->isMeetingRunning($meeting);
112
        if ($this->response->success()) {
113
            $response = XmlToArray($this->response->getRawXml());
114
            if (isset($response['running']) && $response['running'] == "true") {
115
                return true;
116
            }
117
        }
118
119
        return false;
120
    }
121
122
    /**
123
     *  Join meeting
124
     *
125
     * @param $meeting
126
     * required fields
127
     *
128
     *  meetingID
129
     *  userName join by name
130
     *  password which role want to join
131
     *
132
     * @return string
133
     */
134
    public function join($meeting)
135
    {
136
        if (!$meeting instanceof JoinMeetingParameters) {
137
            $meeting = $this->initJoinMeeting($meeting);
138
        }
139
140
        if ($meeting->isRedirect()) {
141
            return $this->bbb->getJoinMeetingURL($meeting);
142
        }
143
144
        return $this->bbb->joinMeeting($meeting)->getUrl();
145
    }
146
147
    /**
148
     *  Returns information about the meeting
149
     *
150
     * @param $meeting
151
     * required fields
152
     * meetingID
153
     * moderatorPW must be there moderator password
154
     *
155
     * @return \Illuminate\Support\Collection
156
     */
157 View Code Duplication
    public function getMeetingInfo($meeting)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
158
    {
159
        if (!$meeting instanceof GetMeetingInfoParameters) {
160
            $meeting = $this->initGetMeetingInfo($meeting);
161
        }
162
163
        $this->response = $this->bbb->getMeetingInfo($meeting);
164
        if ($this->response->success()) {
165
            return collect(XmlToArray($this->response->getRawXml()));
166
        }
167
168
        return collect([]);
169
    }
170
171
    /**
172
     * @param $parameters
173
     *
174
     *  required fields
175
     * meetingID
176
     * meetingName
177
     * userName
178
     * attendeePW
179
     * moderatorPW
180
     *
181
     * @return mixed
182
     */
183
    public function start($parameters)
184
    {
185
        return $this->initStart($parameters);
186
    }
187
188
    /**
189
     *  Close meeting
190
     *
191
     * @param  $meeting
192
     * required fields:
193
     * meetingID
194
     * moderatorPW close meeting must be there moderator password
195
     *
196
     * @return bool
197
     */
198
    public function close($meeting)
199
    {
200
        if (!$meeting instanceof EndMeetingParameters) {
201
            $meeting = $this->initCloseMeeting($meeting);
202
        }
203
204
        $this->response = $this->bbb->endMeeting($meeting);
205
        if ($this->response->success()) {
206
            return true;
207
        }
208
209
        return false;
210
    }
211
212
    /**
213
     *
214
     * @param $recording
215
     * required fields
216
     * meetingID
217
     *
218
     * optional fields
219
     * recordID
220
     * state
221
     * @return \Illuminate\Support\Collection
222
     */
223
    public function getRecordings($recording)
224
    {
225
        if (!$recording instanceof GetRecordingsParameters) {
226
            $recording = $this->initGetRecordings($recording);
227
        }
228
229
        $this->response = $this->bbb->getRecordings($recording);
230 View Code Duplication
        if (count($this->response->getRawXml()->recordings->recording) > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
231
            $recordings = [];
232
            foreach ($this->response->getRawXml()->recordings->recording as $r) {
233
                $recordings[] = XmlToArray($r);
234
            }
235
236
            return collect($recordings);
237
        }
238
239
        return collect([]);
240
    }
241
242
    /**
243
     * @param $recording
244
     * recordID as string(sepeate by commma)
245
     * publish as bool
246
     *
247
     * @return bool
248
     */
249 View Code Duplication
    public function publishRecordings($recording)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
250
    {
251
        if (!$recording instanceof PublishRecordingsParameters) {
252
            $recording = $this->initPublishRecordings($recording);
253
        }
254
255
        $this->response = $this->bbb->publishRecordings($recording);
256
        if ($this->response->success()) {
257
            $response = XmlToArray($this->response->getRawXml());
258
            if (isset($response['published']) && $response['published'] == "true") {
259
                return true;
260
            }
261
        }
262
263
        return false;
264
    }
265
266
    /**
267
     * @param $recording
268
     *
269
     * required fields
270
     * recordingID
271
     *
272
     * @return \Illuminate\Support\Collection
273
     */
274
    public function deleteRecordings($recording)
275
    {
276
        if (!$recording instanceof DeleteRecordingsParameters) {
277
            $recording = $this->initDeleteRecordings($recording);
278
        }
279
280
        $this->response = $this->bbb->deleteRecordings($recording);
281
        return collect(XmlToArray($this->response->getRawXml()));
282
    }
283
284
    /**
285
     * @param $configXml
286
     *
287
     * @return \Illuminate\Support\Collection
288
     */
289
    public function setConfigXml($configXml)
290
    {
291
        if(!$configXml instanceof SetConfigXMLParameters){
292
            $configXml = $this->initSetConfigXml($configXml);
293
        }
294
295
        $this->response = $this->bbb->setConfigXML($configXml);
296
        return collect(XmlToArray($this->response->getRawXml()));
297
    }
298
299
    /**
300
     * @return \BigBlueButton\Responses\GetDefaultConfigXMLResponse
301
     */
302
    public function getDefaultConfigXml()
303
    {
304
        $this->response = $this->bbb->getDefaultConfigXML();
305
        return $this->response;
306
    }
307
308
    /**
309
     * @return \Illuminate\Support\Collection
310
     */
311
    public function getApiVersion()
312
    {
313
        $this->response = $this->bbb->getApiVersion();
314
        return collect(XmlToArray($this->response->getRawXml()));
315
    }
316
317
318
319
}
320