| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | 156 | public static function slugifyText(string $text): string |
|
| 37 | { |
||
| 38 | // Trim whitespace |
||
| 39 | 156 | $slug = \trim($text); |
|
| 40 | // Convert to lowercase |
||
| 41 | 156 | $slug = \mb_strtolower($slug); |
|
| 42 | // Try replacing whitespace with a dash |
||
| 43 | 156 | $slug = \preg_replace('/\s+/u', '-', $slug) ?? $slug; |
|
| 44 | // Try removing characters other than letters, numbers, and marks. |
||
| 45 | 156 | $slug = \preg_replace('/[^\p{L}\p{Nd}\p{Nl}\p{M}-]+/u', '', $slug) ?? $slug; |
|
| 46 | |||
| 47 | 156 | return $slug; |
|
| 48 | } |
||
| 49 | } |
||
| 50 |