XmlConverter   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 47
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0
wmc 9
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A xmlToArrayRecursive() 0 24 5
A xmlToArray() 0 19 4
1
<?php
2
namespace agoalofalife\bpm\Handlers;
3
4
5
use SimpleXMLElement;
6
7
trait XmlConverter
8
{
9 6
    private function xmlToArrayRecursive($xml) {
10 6
        $xml = (array) $xml;
11
12 6
        if(empty($xml)) {
13 3
            return null;
14
        }
15
16 4
        foreach ($xml as $key => $val) {
17 4
            if (is_array($val)){
18 1
                $xml[$key] = $this->xmlToArray($val);
19 1
            } else {
20 4
                if ($val instanceof SimpleXMLElement) {
21 3
                    $xml[$key] = $this->xmlToArray($val);
22 3
                }
23
                // TODO not smog to find a similar case
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% 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...
24
//                elseif (empty($val)) {
25
//                    $xml[$key] = null;
26
//                }
27
            }
28
29 4
        }
30
31 4
        return $xml;
32
    }
33
34 4
    private function xmlToArray($xml) {
35 4
        $xml = (array) $xml;
36
37 4
        if(empty($xml)) {
38 1
            return null;
39
        }
40
41 4
        foreach ($xml as $key=>$val) {
42 4
            if ($val instanceof SimpleXMLElement) {
43 2
                $xml[$key] = $this->xmlToArray($val);
44 2
            }
45
            // TODO not smog to find a similar case
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% 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...
46
//            elseif (empty($val)) {
47
//                $xml[$key] = null;
48
//            }
49 4
        }
50
51 4
        return $xml;
52
    }
53
}