| Conditions | 11 |
| Paths | 2 |
| Total Lines | 38 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 51 | public static function xmlDeserialize(Reader $reader) |
||
| 52 | { |
||
| 53 | $sysinfo = new self(); |
||
| 54 | |||
| 55 | // Borrowing a parser from the KeyValue class. |
||
| 56 | $children = $reader->parseInnerTree(); |
||
| 57 | if(is_array($children)) { |
||
| 58 | foreach ($children as $child) { |
||
| 59 | if ($child['name'] === '{}slots') { |
||
| 60 | $sysinfo->slots = $child['value']; |
||
| 61 | } |
||
| 62 | if ($child['name'] === '{}mainqueue') { |
||
| 63 | $sysinfo->mainqueue = $child['value']; |
||
| 64 | } |
||
| 65 | if ($child['name'] === '{}idlequeue') { |
||
| 66 | $sysinfo->idlequeue = $child['value']; |
||
| 67 | } |
||
| 68 | if ($child['name'] === '{}bandwidth') { |
||
| 69 | $sysinfo->bandwidth = $child['value']; |
||
| 70 | } |
||
| 71 | if ($child['name'] === '{}quota') { |
||
| 72 | $sysinfo->quota = $child['value']; |
||
| 73 | } |
||
| 74 | if ($child['name'] === '{}limits') { |
||
| 75 | $sysinfo->limits = $child['value']; |
||
| 76 | } |
||
| 77 | if ($child['name'] === '{}network') { |
||
| 78 | $sysinfo->networks[] = $child['value']; |
||
| 79 | } |
||
| 80 | if ($child['name'] === '{}stats') { |
||
| 81 | $sysinfo->stats = $child['value']; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | } |
||
| 85 | |||
| 86 | |||
| 87 | return $sysinfo; |
||
| 88 | } |
||
| 89 | |||
| 90 | } |