| Conditions | 6 |
| Paths | 9 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public static function largestNumber(array $nums): string |
||
| 10 | { |
||
| 11 | if (empty($nums)) { |
||
| 12 | return ''; |
||
| 13 | } |
||
| 14 | for ($i = 0, $n = count($nums); $i < $n; $i++) { |
||
| 15 | for ($j = 0; $j < $n - $i - 1; $j++) { |
||
| 16 | if (self::compare($nums[$j], $nums[$j + 1]) < 0) { |
||
| 17 | [$nums[$j], $nums[$j + 1]] = [$nums[$j + 1], $nums[$j]]; |
||
| 18 | } |
||
| 19 | } |
||
| 20 | } |
||
| 21 | if ((int)$nums[0] === 0) { |
||
| 22 | return '0'; |
||
| 23 | } |
||
| 24 | |||
| 25 | return (string)join('', $nums); |
||
| 26 | } |
||
| 48 |