| Conditions | 2 |
| Paths | 1 |
| Total Lines | 10 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | public function sort(array &$fields) |
||
| 27 | { |
||
| 28 | usort($fields, function (SimpleXMLElement $field1, SimpleXMLElement $field2) { |
||
| 29 | $typeComparison = $this->fieldTypeToOrder[(string) $field1->FldType] - $this->fieldTypeToOrder[(string) $field2->FldType]; |
||
| 30 | |||
| 31 | if ($typeComparison === 0) { |
||
| 32 | // Same field type, so order by field name |
||
| 33 | return strcmp((string)$field1->attributes()['Name'], (string)$field2->attributes()['Name']); |
||
| 34 | } else { |
||
| 35 | return $typeComparison; |
||
| 36 | } |
||
| 40 |