Completed
Push — master ( 9056d7...e52bc4 )
by Adam
08:23
created

Xml::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php namespace BestServedCold\PhalueObjects\File;
2
3
use BestServedCold\PhalueObjects\File;
4
5
final class Xml extends File
6
{
7
    public function parse()
8
    {
9
        return $this->xmlJsonFix(simplexml_load_string($this->getContents(), 'SimpleXMLElement', LIBXML_NOCDATA));
10
    }
11
12
    private function xmlJsonFix($xml)
13
    {
14
        return json_decode(str_replace(':[]', ':null', str_replace(':{}', ':null', json_encode((array) $xml))), 1);
15
    }
16
}
17