| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | public static function toSlug(string $string): string |
||
| 30 | { |
||
| 31 | $string = preg_replace('~[^\pL\d]+~u', '-', $string); |
||
| 32 | $string = iconv('utf-8', 'us-ascii//TRANSLIT', $string); |
||
| 33 | $string = preg_replace('~[^-\w]+~', '', $string); |
||
| 34 | $string = trim($string, '-'); |
||
| 35 | $string = preg_replace('~-+~', '-', $string); |
||
| 36 | $string = strtolower($string); |
||
| 37 | |||
| 38 | if (empty($string)) { |
||
| 39 | return 'n-a'; |
||
| 40 | } |
||
| 41 | |||
| 42 | return $string; |
||
| 43 | } |
||
| 45 |