Completed
Push — master ( 4ff2ad...4ba911 )
by Franck
03:40
created

Xml   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 30
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A decode() 0 17 1
1
<?php
2
3
/**
4
 *
5
 * This file is part of the Apix Project.
6
 *
7
 * (c) Franck Cassedanne <franck at ouarz.net>
8
 *
9
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
10
 *
11
 */
12
13
namespace Apix\Input;
14
15
class Xml implements InputInterface
16
{
17
18
    /**
19
     * @var	string
20
     */
21
    public $encoding = 'utf-8';
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function decode($xmlStr, $assoc=true)
27
    {
28
29
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
30
            $array = json_decode(json_encode($xmlStr), true);
31
32
            foreach ( array_slice($array, 0) as $key => $value ) {
33
                if ( empty($value) ) $array[$key] = NULL;
34
                elseif ( is_array($value) ) $array[$key] = toArray($value);
35
            }
36
37
            return $array;
38
        */
39
40
        // json_decode only works with UTF-8!!!
41
        return json_decode(json_encode((array) simplexml_load_string($xmlStr)), $assoc);
42
    }
43
44
}
45