Completed
Push — master ( 718eb8...2626a3 )
by Jignesh
01:10
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
namespace JoisarJignesh\Bigbluebutton\Services;
4
5
use BigBlueButton\Parameters\SetConfigXMLParameters;
6
7
trait InitConfigXml
8
{
9
    /**
10
     * @param array $parameters
11
     *
12
     * require fields
13
     * xml
14
     * meetingID
15
     *
16
     * @return SetConfigXMLParameters gXMLParameters
17
     * @throws \Exception
18
     */
19
    public function initSetConfigXml(array $parameters)
20
    {
21
        $parameters = Fluent($parameters);
22
        $configXml = new SetConfigXMLParameters($parameters->get('meetingID'));
23
        $rawXml = $parameters->xml;
24
        if (! $parameters->xml instanceof \SimpleXMLElement) {
25
            try {
26
                $rawXml = new \SimpleXMLElement($parameters->xml);
27
            } catch (\Exception $e) {
28
                throw new \Exception('Could not parse payload as XMl');
29
            }
30
        }
31
32
        $configXml->setRawXml($rawXml);
33
34
        return $configXml;
35
    }
36
}
37