| Conditions | 5 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public static function from(array $data): self |
||
| 18 | { |
||
| 19 | $currencies = array_values(array_map(fn($currency) => RegionCurrency::from($currency), $data)); |
||
| 20 | |||
| 21 | usort($currencies, function (RegionCurrency $a, RegionCurrency $b) { |
||
| 22 | if ($a->from && $b->from) { |
||
| 23 | return $a->from <=> $b->from; |
||
| 24 | } elseif ($a->to && $b->to) { |
||
| 25 | return $b->to <=> $a->to; |
||
| 26 | } |
||
| 27 | |||
| 28 | return -1; |
||
| 29 | }); |
||
| 30 | |||
| 31 | return new self($currencies); |
||
| 32 | } |
||
| 63 |