XmlParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 7 2
1
<?php
2
3
namespace SimpleDIC\Parser;
4
5
class XmlParser implements ParserInterface
6
{
7
    /**
8
     * @param string $filename
9
     *
10
     * @return array|false
11
     * @throws \Exception
12
     */
13
    public function parse($filename)
14
    {
15
        if (false === extension_loaded('simplexml')) {
16
            throw new \Exception('SimpleXML extension is not loaded. Add "ext-simplexml": "*" to your composer.json.');
17
        }
18
19
        return json_decode(json_encode(simplexml_load_file($filename)), true);
20
    }
21
}
22