Conditions | 1 |
Paths | 1 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | 2 | public function parse() |
|
29 | { |
||
30 | 2 | $data = array(); |
|
31 | 2 | $data['id'] = (string)$this->xmlElement->attributes()['id']; |
|
32 | |||
33 | 2 | $data['current']['generating']['units'] = (string)$this->xmlElement->current->generating->attributes()['units']; |
|
34 | 2 | $data['current']['generating']['value'] = (float)$this->xmlElement->current->generating; |
|
35 | 2 | $data['current']['exporting']['units'] = (string)$this->xmlElement->current->exporting->attributes()['units']; |
|
36 | 2 | $data['current']['exporting']['value'] = (float)$this->xmlElement->current->exporting; |
|
37 | |||
38 | 2 | $data['day']['generating']['units'] = (string)$this->xmlElement->day->generated->attributes()['units']; |
|
39 | 2 | $data['day']['generating']['value'] = (float)$this->xmlElement->day->generated; |
|
40 | 2 | $data['day']['exporting']['units'] = (string)$this->xmlElement->day->exported->attributes()['units']; |
|
41 | 2 | $data['day']['exporting']['value'] = (float)$this->xmlElement->day->exported; |
|
42 | |||
43 | 2 | return new Solar($data); |
|
44 | } |
||
45 | |||
47 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: