Completed
Push — master ( daea38...44c4b6 )
by Ghazi
02:21
created

BigBlueButton::deleteRecordings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
4
 *
5
 * Copyright (c) 2016 BigBlueButton Inc. and by respective authors (see below).
6
 *
7
 * This program is free software; you can redistribute it and/or modify it under the
8
 * terms of the GNU Lesser General Public License as published by the Free Software
9
 * Foundation; either version 3.0 of the License, or (at your option) any later
10
 * version.
11
 *
12
 * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License along
17
 * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
namespace BigBlueButton;
20
21
use BigBlueButton\Core\ApiMethod;
22
use BigBlueButton\Parameters\CreateMeetingParameters;
23
use BigBlueButton\Parameters\DeleteRecordingsParameters;
24
use BigBlueButton\Parameters\EndMeetingParameters;
25
use BigBlueButton\Parameters\GetMeetingInfoParameters;
26
use BigBlueButton\Parameters\GetRecordingsParameters;
27
use BigBlueButton\Parameters\IsMeetingRunningParameters;
28
use BigBlueButton\Parameters\JoinMeetingParameters;
29
use BigBlueButton\Parameters\PublishRecordingsParameters;
30
use BigBlueButton\Responses\ApiVersionResponse;
31
use BigBlueButton\Responses\CreateMeetingResponse;
32
use BigBlueButton\Responses\DeleteRecordingsResponse;
33
use BigBlueButton\Responses\EndMeetingResponse;
34
use BigBlueButton\Responses\GetDefaultConfigXMLResponse;
35
use BigBlueButton\Responses\GetMeetingInfoResponse;
36
use BigBlueButton\Responses\GetMeetingsResponse;
37
use BigBlueButton\Responses\GetRecordingsResponse;
38
use BigBlueButton\Responses\IsMeetingRunningResponse;
39
use BigBlueButton\Responses\JoinMeetingResponse;
40
use BigBlueButton\Responses\PublishRecordingsResponse;
41
use BigBlueButton\Util\UrlBuilder;
42
use SimpleXMLElement;
43
44
/**
45
 * Class BigBlueButton
46
 * @package BigBlueButton
47
 */
48
class BigBlueButton
49
{
50
    private $securitySalt;
51
    private $bbbServerBaseUrl;
52
    private $urlBuilder;
53
54
    public function __construct()
0 ignored issues
show
Coding Style introduced by
__construct uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
55
    {
56
        $this->securitySalt     = $_SERVER['BBB_SECURITY_SALT'];
57
        $this->bbbServerBaseUrl = $_SERVER['BBB_SERVER_BASE_URL'];
58
        $this->urlBuilder       = new UrlBuilder($this->securitySalt, $this->bbbServerBaseUrl);
59
    }
60
61
    /**
62
     * @return ApiVersionResponse
63
     *
64
     * @throws \RuntimeException
65
     */
66
    public function getApiVersion()
67
    {
68
        return new ApiVersionResponse($this->processXmlResponse($this->urlBuilder->buildUrl()));
0 ignored issues
show
Bug introduced by
It seems like $this->processXmlRespons...urlBuilder->buildUrl()) can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
69
    }
70
71
    /* __________________ BBB ADMINISTRATION METHODS _________________ */
72
    /* The methods in the following section support the following categories of the BBB API:
73
    -- create
74
    -- getDefaultConfigXML
75
    -- join
76
    -- end
77
    */
78
79
    /**
80
     * @param  CreateMeetingParameters $createMeetingParams
81
     * @return string
82
     */
83
    public function getCreateMeetingUrl($createMeetingParams)
84
    {
85
        return $this->urlBuilder->buildUrl(ApiMethod::CREATE, $createMeetingParams->getHTTPQuery());
86
    }
87
88
    /**
89
     * @param  CreateMeetingParameters $createMeetingParams
90
     * @return CreateMeetingResponse
91
     * @throws \RuntimeException
92
     */
93
    public function createMeeting($createMeetingParams)
94
    {
95
        $xml = $this->processXmlResponse($this->getCreateMeetingUrl($createMeetingParams), $createMeetingParams->getPresentationsAsXML());
0 ignored issues
show
Security Bug introduced by
It seems like $createMeetingParams->getPresentationsAsXML() targeting BigBlueButton\Parameters...getPresentationsAsXML() can also be of type false; however, BigBlueButton\BigBlueButton::processXmlResponse() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
96
97
        return new CreateMeetingResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...etPresentationsAsXML()) on line 95 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getDefaultConfigXMLUrl()
104
    {
105
        return $this->urlBuilder->buildUrl(ApiMethod::GET_DEFAULT_CONFIG_XML);
106
    }
107
108
    /**
109
     * @return GetDefaultConfigXMLResponse
110
     * @throws \RuntimeException
111
     */
112
    public function getDefaultConfigXML()
113
    {
114
        $xml = $this->processXmlResponse($this->getDefaultConfigXMLUrl());
115
116
        return new GetDefaultConfigXMLResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...tDefaultConfigXMLUrl()) on line 114 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
117
    }
118
119
    /**
120
     * @param $joinMeetingParams JoinMeetingParameters
121
     *
122
     * @return string
123
     */
124
    public function getJoinMeetingURL($joinMeetingParams)
125
    {
126
        return $this->urlBuilder->buildUrl(ApiMethod::JOIN, $joinMeetingParams->getHTTPQuery());
127
    }
128
129
    /**
130
     * @param $joinMeetingParams JoinMeetingParameters
131
     *
132
     * @return JoinMeetingResponse
133
     * @throws \RuntimeException
134
     */
135
    public function joinMeeting($joinMeetingParams)
136
    {
137
        $xml = $this->processXmlResponse($this->getJoinMeetingURL($joinMeetingParams));
138
139
        return new JoinMeetingResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...RL($joinMeetingParams)) on line 137 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
140
    }
141
142
    /**
143
     * @param $endParams EndMeetingParameters
144
     *
145
     * @return string
146
     */
147
    public function getEndMeetingURL($endParams)
148
    {
149
        return $this->urlBuilder->buildUrl(ApiMethod::END, $endParams->getHTTPQuery());
150
    }
151
152
    /**
153
     * @param $endParams EndMeetingParameters
154
     *
155
     * @return EndMeetingResponse
156
     * @throws \RuntimeException
157
     * */
158
    public function endMeeting($endParams)
159
    {
160
        $xml = $this->processXmlResponse($this->getEndMeetingURL($endParams));
161
162
        return new EndMeetingResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...MeetingURL($endParams)) on line 160 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
163
    }
164
165
    /* __________________ BBB MONITORING METHODS _________________ */
166
    /* The methods in the following section support the following categories of the BBB API:
167
    -- isMeetingRunning
168
    -- getMeetings
169
    -- getMeetingInfo
170
    */
171
172
    /**
173
     * @param $meetingParams IsMeetingRunningParameters
174
     * @return string
175
     */
176
    public function getIsMeetingRunningUrl($meetingParams)
177
    {
178
        return $this->urlBuilder->buildUrl(ApiMethod::IS_MEETING_RUNNING, $meetingParams->getHTTPQuery());
179
    }
180
181
    /**
182
     * @param $meetingParams
183
     * @return IsMeetingRunningResponse
184
     * @throws \RuntimeException
185
     */
186
    public function isMeetingRunning($meetingParams)
187
    {
188
        $xml = $this->processXmlResponse($this->getIsMeetingRunningUrl($meetingParams));
189
190
        return new IsMeetingRunningResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...ingUrl($meetingParams)) on line 188 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
191
    }
192
193
    /**
194
     * @return string
195
     */
196
    public function getMeetingsUrl()
197
    {
198
        return $this->urlBuilder->buildUrl(ApiMethod::GET_MEETINGS);
199
    }
200
201
    /**
202
     * @return GetMeetingsResponse
203
     * @throws \RuntimeException
204
     */
205
    public function getMeetings()
206
    {
207
        $xml = $this->processXmlResponse($this->getMeetingsUrl());
208
209
        return new GetMeetingsResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...this->getMeetingsUrl()) on line 207 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
210
    }
211
212
    /**
213
     * @param $meetingParams GetMeetingInfoParameters
214
     * @return string
215
     */
216
    public function getMeetingInfoUrl($meetingParams)
217
    {
218
        return $this->urlBuilder->buildUrl(ApiMethod::IS_MEETING_RUNNING, $meetingParams->getHTTPQuery());
219
    }
220
221
    /**
222
     * @param $meetingParams GetMeetingInfoParameters
223
     * @return GetMeetingInfoResponse
224
     * @throws \RuntimeException
225
     */
226
    public function getMeetingInfo($meetingParams)
227
    {
228
        $xml = $this->processXmlResponse($this->getMeetingInfoUrl($meetingParams));
229
230
        return new GetMeetingInfoResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...nfoUrl($meetingParams)) on line 228 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
231
    }
232
233
    /* __________________ BBB RECORDING METHODS _________________ */
234
    /* The methods in the following section support the following categories of the BBB API:
235
    -- getRecordings
236
    -- publishRecordings
237
    -- deleteRecordings
238
    */
239
240
    /**
241
     * @param $recordingsParams GetRecordingsParameters
242
     * @return string
243
     */
244
    public function getRecordingsUrl($recordingsParams)
245
    {
246
        return $this->urlBuilder->buildUrl(ApiMethod::GET_RECORDINGS, $recordingsParams->getHTTPQuery());
247
    }
248
249
    /**
250
     * @param $recordingParams
251
     * @return GetRecordingsResponse
252
     * @throws \RuntimeException
253
     */
254
    public function getRecordings($recordingParams)
255
    {
256
        $xml = $this->processXmlResponse($this->getRecordingsUrl($recordingParams));
257
258
        return new GetRecordingsResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...sUrl($recordingParams)) on line 256 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
259
    }
260
261
    /**
262
     * @param $recordingParams PublishRecordingsParameters
263
     * @return string
264
     */
265
    public function getPublishRecordingsUrl($recordingParams)
266
    {
267
        return $this->urlBuilder->buildUrl(ApiMethod::PUBLISH_RECORDINGS, $recordingParams->getHTTPQuery());
268
    }
269
270
    /**
271
     * @param $recordingParams PublishRecordingsParameters
272
     * @return PublishRecordingsResponse
273
     * @throws \RuntimeException
274
     */
275
    public function publishRecordings($recordingParams)
276
    {
277
        $xml = $this->processXmlResponse($this->getPublishRecordingsUrl($recordingParams));
278
279
        return new PublishRecordingsResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...sUrl($recordingParams)) on line 277 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
280
    }
281
282
    /**
283
     * @param $recordingParams DeleteRecordingsParameters
284
     * @return string
285
     */
286
    public function deleteRecordingsUrl($recordingParams)
287
    {
288
        return $this->urlBuilder->buildUrl(ApiMethod::DELETE_RECORDINGS, $recordingParams->getHTTPQuery());
289
    }
290
291
    /**
292
     * @param $recordingParams
293
     * @return DeleteRecordingsResponse
294
     * @throws \RuntimeException
295
     */
296
    public function deleteRecordings($recordingParams)
297
    {
298
        $xml = $this->processXmlResponse($this->deleteRecordingsUrl($recordingParams));
299
300
        return new DeleteRecordingsResponse($xml);
0 ignored issues
show
Bug introduced by
It seems like $xml defined by $this->processXmlRespons...sUrl($recordingParams)) on line 298 can be null; however, BigBlueButton\Responses\...Response::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
301
    }
302
303
    /* ____________________ INTERNAL CLASS METHODS ___________________ */
304
305
    /**
306
     * A private utility method used by other public methods to process XML responses.
307
     *
308
     * @param $url
309
     * @param  string            $xml
310
     * @return SimpleXMLElement
311
     * @throws \RuntimeException
312
     */
313
    private function processXmlResponse($url, $xml = '')
314
    {
315
        if (extension_loaded('curl')) {
316
            $ch = curl_init();
317
            if (!$ch) {
318
                throw new \RuntimeException('Unhandled curl error: ' . curl_error($ch));
319
            }
320
            $timeout = 10;
321
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
322
            curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
323
            curl_setopt($ch, CURLOPT_URL, $url);
324
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
325
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
326
            if (count($xml) !== 0) {
327
                curl_setopt($ch, CURLOPT_HEADER, 0);
328
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
329
                curl_setopt($ch, CURLOPT_POST, 1);
330
                curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
331
                curl_setopt($ch, CURLOPT_HTTPHEADER, [
332
                    'Content-type: application/xml',
333
                    'Content-length: ' . strlen($xml),
334
                ]);
335
            }
336
            $data = curl_exec($ch);
337
            if ($data === false) {
338
                throw new \RuntimeException('Unhandled curl error: ' . curl_error($ch));
339
            }
340
            curl_close($ch);
341
342
            return new SimpleXMLElement($data);
343
        }
344
        if (count($xml) !== 0) {
345
            throw new \RuntimeException('Post XML data set but curl PHP module is not installed or not enabled.');
346
        }
347
    }
348
}
349