Conditions | 4 |
Paths | 8 |
Total Lines | 30 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 20 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | 2 | public function parse() |
|
30 | { |
||
31 | 2 | $data = array(); |
|
32 | 2 | $data['id'] = (string)$this->xmlElement->attributes()['id']; |
|
33 | 2 | $data['chan'] = array(); |
|
34 | |||
35 | 2 | foreach($this->xmlElement->signal->attributes() AS $k => $v) |
|
36 | { |
||
37 | 2 | $data['signal'][$k] = (string)$v; |
|
38 | 2 | } |
|
39 | |||
40 | 2 | foreach($this->xmlElement->battery->attributes() AS $k => $v) |
|
41 | { |
||
42 | 2 | $data['battery'][$k] = (string)$v; |
|
43 | 2 | } |
|
44 | |||
45 | 2 | foreach($this->xmlElement->chan AS $chan) |
|
46 | { |
||
47 | 2 | $channel = array(); |
|
48 | 2 | $channel['id'] = (int)$chan->attributes()['id']; |
|
49 | 2 | $channel['curr']['units'] = (string)$chan->curr->attributes()['units']; |
|
50 | 2 | $channel['curr']['value'] = (float)$chan->curr; |
|
51 | 2 | $channel['day']['units'] = (string)$chan->day->attributes()['units']; |
|
52 | 2 | $channel['day']['value'] = (float)$chan->day; |
|
53 | |||
54 | 2 | $data['chan'][] = $channel; |
|
55 | 2 | } |
|
56 | |||
57 | 2 | return new Electricity($data); |
|
58 | } |
||
59 | } |
||
60 |