src/Url.php
public static function generateSafeSlug($slug)
    {
        $slug = preg_replace('/[^a-zA-Z0-9]/', '-', $slug);
        $slug = strtolower(trim($slug, '-'));
        $slug = preg_replace('/\-{2,}/', '-', $slug);

        return $slug;
    }
public static function generateSafeSlug($slug)
    {
        $slug = preg_replace('/[^a-zA-Z0-9]/', '-', $slug);
        $slug = strtolower(trim($slug, '-'));
        $slug = preg_replace('/\-{2,}/', '-', $slug);

        return $slug;
    }
public static function generateSafeSlug ( $ slug ) { $ slug = preg_replace ( '/[^a-zA-Z0-9]/' , '-' , $ slug ) ; $ slug = strtolower ( trim ( $ slug , '-' ) ) ; $ slug = preg_replace ( '/\-{2,}/' , '-' , $ slug ) ; return $ slug ; }
This function converts and URL segment to an safe one.
For example: `test name @132` will be converted to `test-name--123`.
It will also return all letters in lowercase

@param string $slug → URL slug to clean up

@return string → slug
This function converts and URL segment to an safe one . For example : test name @132 will be converted to test - name -- 123 . It will also return all letters in lowercase