| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | 48 | public function slugify($text) |
|
| 13 | { |
||
| 14 | 48 | $text = URLify::downcode($text); |
|
| 15 | 48 | $text = preg_replace('/\b('.implode('|', URLify::$remove_list).')\b/i', '', $text); |
|
| 16 | |||
| 17 | 48 | $text = preg_replace('/[^\s_\-a-zA-Z0-9]/u', '', $text); // remove unneeded chars |
|
| 18 | 48 | $text = str_replace('_', ' ', $text); // treat underscores as spaces |
|
| 19 | 48 | $text = preg_replace('/^\s+|\s+$/u', '', $text); // trim leading/trailing spaces |
|
| 20 | 48 | $text = preg_replace('/[-\s]+/u', '-', $text); // convert spaces to hyphens |
|
| 21 | 48 | $text = trim($text, '-'); // trim to first $length chars |
|
| 22 | |||
| 23 | 48 | return $text; |
|
| 24 | } |
||
| 25 | } |
||
| 26 |