Completed
Push — v1.ns ( dc5273...919dbc )
by Timo
05:10 queued 01:22
created

XMLContextReader::convertXmlToArray()   B

Complexity

Conditions 5
Paths 12

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 5
eloc 12
c 1
b 1
f 0
nc 12
nop 2
dl 0
loc 19
rs 8.8571
1
<?php
2
3
namespace PEIP\Context;
4
/* 
5
 * To change this template, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
/**
10
 * Description of XMLContextReader
11
 *
12
 * @author timo
13
 */
14
use PEIP\Translator\XMLArrayTranslator;
15
16
class XMLContextReader extends \PEIP\ABS\Base\Connectable {
17
    //put your code here
18
19
    protected $config;
20
21
22
    public function __construct($config){ //print_r((array)simplexml_load_string($config));
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% 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...
23
        $this->config = ($config);       
24
    }
25
26
    public function read(){      
27
        $iterator = new \SimpleXMLIterator($this->config);
28
        $iterator->rewind();
29
        while($iterator->valid()){
30
            
31
            $arrayNode = XMLArrayTranslator::translate($iterator->current()->asXML()); 
32
            $this->doFireEvent('read_node', array('NODE'=>$arrayNode));            
33
            $iterator->next();
34
        }
35
        
36
        foreach($iterator as $xmlNode){  
0 ignored issues
show
Unused Code introduced by
This foreach statement is empty and can be removed.

This check looks for foreach loops that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

Consider removing the loop.

Loading history...
37
38
        }
39
        $this->config = array();
40
    }
41
42
}
43
44