Passed
Pull Request — master (#1)
by João Felipe Magro
01:22
created

XmlService::xmlToStdClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace Ipag\Classes\Services;
4
5
final class XmlService
6
{
7
    public function validate($message)
8
    {
9
        libxml_use_internal_errors(true);
10
        $response = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA);
11
12
        if ($response === false) {
13
            throw new \Exception('Não foi possível identificar o XML de retorno.');
14
        }
15
16
        return $response;
17
    }
18
19
    public function xmlToStdClass($xml)
20
    {
21
        return json_decode(json_encode((array) $xml));
22
    }
23
}
24