Conditions | 3 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7719 | 2 | public static function str_sort(string $str, bool $unique = false, bool $desc = false): string |
|
7720 | { |
||
7721 | /** @var int[] $array */ |
||
7722 | 2 | $array = self::codepoints($str); |
|
7723 | |||
7724 | 2 | if ($unique) { |
|
7725 | 2 | $array = \array_flip(\array_flip($array)); |
|
7726 | } |
||
7727 | |||
7728 | 2 | if ($desc) { |
|
7729 | 2 | \arsort($array); |
|
7730 | } else { |
||
7731 | 2 | \asort($array); |
|
7732 | } |
||
7733 | |||
7734 | 2 | return self::string($array); |
|
7735 | } |
||
13722 |