AbstractXmlOutputParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 19
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0

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 4
    protected function transformXmlToArray(string $xmlString): array
13
    {
14 4
        if (mb_detect_encoding($xmlString, 'UTF-8', true) === false) {
15
            $xmlString = utf8_encode($xmlString);
16
        }
17
18 4
        $xml = simplexml_load_string($xmlString);
19 4
        $json = json_encode($xml);
20
21 4
        return json_decode($json, true);
22
    }
23
}
24