Completed
Push — master ( bd25e7...98ff1d )
by Maxime
33s
created

AbstractXmlOutputParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 71.43%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 2
c 5
b 1
f 0
lcom 0
cbo 0
dl 0
loc 19
ccs 5
cts 7
cp 0.7143
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A transformXmlToArray() 0 11 2
1
<?php
2
3
namespace Mhor\MediaInfo\Parser;
4
5
abstract class AbstractXmlOutputParser implements OutputParserInterface
6
{
7
    /**
8
     * @param string $xmlString
9
     *
10
     * @return array
11
     */
12 3
    protected function transformXmlToArray($xmlString)
13
    {
14 3
        if (mb_detect_encoding($xmlString, 'UTF-8', true) === false) {
15
            $xmlString = utf8_encode($xmlString);
16
        }
17
18 3
        $xml = simplexml_load_string($xmlString);
19 3
        $json = json_encode($xml);
20
21 3
        return json_decode($json, true);
22
    }
23
}
24