Completed
Push — master ( abe09c...f5c117 )
by Jignesh
01:34
created

Bbb::deleteRecordings()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
4
namespace JoisarJignesh\Bigbluebutton;
5
6
use BigBlueButton\BigBlueButton;
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 JoisarJignesh\Bigbluebutton\Services\initMeeting;
15
16
class Bbb
17
{
18
    use initMeeting;
19
20
    private $response;
21
    /**
22
     * @var BigBlueButton
23
     */
24
    protected $bbb;
25
26
27
    public function __construct(BigBlueButton $bbb)
28
    {
29
        $this->bbb = $bbb;
30
    }
31
32
    /*
33
     * return BigBlueButton\BigBlueButton
34
     * return BigBlueButton Class of Api class
35
     */
36
    public function make()
37
    {
38
        return $this->bbb;
39
    }
40
    /**
41
     *  Return a list of all meetings
42
     *
43
     * @return \Illuminate\Support\Collection
44
     */
45
    public function all()
46
    {
47
        $this->response = $this->bbb->getMeetings();
48 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...
49
            if (count($this->response->getRawXml()->meetings->meeting) > 0) {
50
                $meetings = [];
51
                foreach ($this->response->getRawXml()->meetings->meeting as $meeting) {
52
                    $meetings[] = $meeting;
53
                }
54
55
                return collect($meetings);
56
            }
57
        }
58
59
        return collect([]);
60
    }
61
62
63
    /**
64
     * $meeting
65
     *
66
     * @param $meeting
67
     *
68
     * required fields
69
     * meetingID
70
     * meetingName
71
     *
72
     * @return mixed
73
     */
74 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...
75
    {
76
        if (!$meeting instanceof CreateMeetingParameters) {
77
            $meeting = $this->initCreateMeeting($meeting);
78
        }
79
80
        $this->response = $this->bbb->createMeeting($meeting);
81
        if ($this->response->failed()) {
82
            return $this->response->getMessage();
83
        } else {
84
            return collect(XmlToArray($this->response->getRawXml()));
85
        }
86
    }
87
88
    /**
89
     * @param $meeting
90
     *
91
     * required fields:
92
     * meetingID
93
     *
94
     * @return bool
95
     */
96
    public function isMeetingRunning($meeting)
97
    {
98
        if (!$meeting instanceof IsMeetingRunningParameters) {
99
            $meeting = $this->initIsMeetingRunning($meeting);
100
        }
101
102
        $this->response = $this->bbb->isMeetingRunning($meeting);
103
        if ($this->response->success()) {
104
            $response = XmlToArray($this->response->getRawXml());
105
            if (isset($response['running']) && $response['running'] == "true") {
106
                return true;
107
            }
108
        }
109
110
        return false;
111
    }
112
113
    /**
114
     *  Join meeting
115
     *
116
     * @param $meeting
117
     * required fields
118
     *
119
     *  meetingID
120
     *  userName join by name
121
     *  password which role want to join
122
     *
123
     * @return string
124
     */
125
    public function join($meeting)
126
    {
127
        if (!$meeting instanceof JoinMeetingParameters) {
128
            $meeting = $this->initJoinMeeting($meeting);
129
        }
130
131
        if ($meeting->isRedirect()) {
132
            return $this->bbb->getJoinMeetingURL($meeting);
133
        }
134
135
        return $this->bbb->joinMeeting($meeting)->getUrl();
136
    }
137
138
    /**
139
     *  Returns information about the meeting
140
     *
141
     * @param $meeting
142
     * required fields
143
     * meetingID
144
     * moderatorPW must be there moderator password
145
     *
146
     * @return \Illuminate\Support\Collection
147
     */
148 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...
149
    {
150
        if (!$meeting instanceof GetMeetingInfoParameters) {
151
            $meeting = $this->initGetMeetingInfo($meeting);
152
        }
153
154
        $this->response = $this->bbb->getMeetingInfo($meeting);
155
        if ($this->response->success()) {
156
            return collect(XmlToArray($this->response->getRawXml()));
157
        }
158
159
        return collect([]);
160
    }
161
162
    /*
163
         * required fields
164
         * meetingID
165
         * meetingName
166
         * userName
167
         * attendeePW
168
         * moderatorPW
169
         */
170
    public function start($parameters)
171
    {
172
        return $this->initStart($parameters);
173
    }
174
175
    /**
176
     *  Close meeting
177
     *
178
     * @param  $meeting
179
     * required fields:
180
     * meetingID
181
     * moderatorPW close meeting must be there moderator password
182
     *
183
     * @return bool
184
     */
185
    public function close($meeting)
186
    {
187
        if (!$meeting instanceof EndMeetingParameters) {
188
            $meeting = $this->initCloseMeeting($meeting);
189
        }
190
191
        $this->response = $this->bbb->endMeeting($meeting);
192
        if ($this->response->success()) {
193
            return true;
194
        }
195
196
        return false;
197
    }
198
199
    /**
200
     *
201
     * @param $recording
202
     * required fields
203
     * meetingID
204
     *
205
     * optional fields
206
     * recordID
207
     * state
208
     * @return \Illuminate\Support\Collection
209
     */
210
    public function getRecordings($recording)
211
    {
212
        if (!$recording instanceof GetRecordingsParameters) {
213
            $recording = $this->initGetRecordings($recording);
214
        }
215
216
        $this->response = $this->bbb->getRecordings($recording);
217 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...
218
            $recordings = [];
219
            foreach ($this->response->getRawXml()->recordings->recording as $r) {
220
                $recordings[] = $r;
221
            }
222
223
            return collect($recordings);
224
        }
225
226
        return collect([]);
227
    }
228
229
    /*
230
     * required fields
231
     * recordingID
232
     */
233
    public function deleteRecordings($recording)
234
    {
235
        if (!$recording instanceof DeleteRecordingsParameters) {
236
            $recording = $this->initDeleteRecordings($recording);
237
        }
238
239
        $this->response = $this->bbb->deleteRecordings($recording);
240
        return collect(XmlToArray($this->response->getRawXml()));
241
    }
242
243
}
244