Conditions | 2 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 2.032 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public function sort(array &$fields) |
||
27 | { |
||
28 | 1 | usort($fields, function ($field1, $field2) { |
|
29 | // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps |
||
30 | 1 | $typeComparison = $this->fieldTypeToOrder[(string) $field1->FldType] - $this->fieldTypeToOrder[(string) $field2->FldType]; |
|
31 | |||
32 | 1 | if ($typeComparison === 0) { |
|
33 | // Same field type, so order by field name |
||
34 | /** |
||
35 | * @var SimpleXMLElement $field1 |
||
36 | * @var SimpleXMLElement $field2 |
||
37 | */ |
||
38 | return strcmp((string)$field1->attributes()['Name'], (string)$field2->attributes()['Name']); |
||
39 | } else { |
||
40 | 1 | return $typeComparison; |
|
41 | } |
||
45 |