| Total Complexity | 8 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class StringUtil |
||
| 6 | { |
||
| 7 | public const PATTERN = '/(\w[^,]*)|([#$]\{[^}]*\})/mu'; |
||
| 8 | |||
| 9 | public static function splitCommaSeparatedList(?string $text): array |
||
| 10 | { |
||
| 11 | if (empty($text)) { |
||
| 12 | return []; |
||
| 13 | } |
||
| 14 | preg_match_all(self::PATTERN, $text, $matches); |
||
| 15 | $parts = []; |
||
| 16 | foreach ($matches[0] as $match) { |
||
| 17 | $parts[] = trim($match); |
||
| 18 | } |
||
| 19 | return $parts; |
||
| 20 | } |
||
| 21 | |||
| 22 | public static function joinCommaSeparatedList(?array $list): ?string |
||
| 23 | { |
||
| 24 | return self::joinList($list, ", "); |
||
| 25 | } |
||
| 26 | |||
| 27 | public static function splitListBySeparator(?string $text, string $separator): array |
||
| 33 | } |
||
| 34 | |||
| 35 | public static function joinList(?array $list, string $separator): ?string |
||
| 40 |