| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function normalize(string $text, $context = null): string |
||
| 29 | { |
||
| 30 | // Trim whitespace |
||
| 31 | $slug = \trim($text); |
||
| 32 | // Convert to lowercase |
||
| 33 | $slug = \mb_strtolower($slug); |
||
| 34 | // Try replacing whitespace with a dash |
||
| 35 | $slug = \preg_replace('/\s+/u', '-', $slug) ?? $slug; |
||
| 36 | // Try removing characters other than letters, numbers, and marks. |
||
| 37 | $slug = \preg_replace('/[^\p{L}\p{Nd}\p{Nl}\p{M}-]+/u', '', $slug) ?? $slug; |
||
| 38 | |||
| 39 | return $slug; |
||
| 40 | } |
||
| 41 | } |
||
| 42 |