Completed
Push — master ( 46d7d4...59ec59 )
by Jignesh
01:12
created

initConfigXml::initSetConfigXml()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
4
namespace JoisarJignesh\Bigbluebutton\Services;
5
6
7
use BigBlueButton\Parameters\SetConfigXMLParameters;
8
9
trait initConfigXml
10
{
11
    /**
12
     * @param array $parameters
13
     *
14
     * require fields
15
     * xml
16
     * meetingID
17
     *
18
     * @return SetConfigXMLParameters gXMLParameters
19
     * @throws \Exception
20
     */
21
    public function initSetConfigXml(array $parameters)
22
    {
23
        $parameters = Fluent($parameters);
24
        $configXml = new SetConfigXMLParameters($parameters->get('meetingID'));
25
        $rawXml = $parameters->xml;
26
        if (!$parameters->xml instanceof \SimpleXMLElement) {
27
            try {
28
                $rawXml = new \SimpleXMLElement($parameters->xml);
29
            } catch (\Exception $e) {
30
                throw new \Exception('Could not parse payload as XMl');
31
            }
32
        }
33
34
        $configXml->setRawXml($rawXml);
35
36
        return $configXml;
37
    }
38
}
39