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

initConfigXml   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A initSetConfigXml() 0 17 3
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