XmlParser::parse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
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