public function toSlug(string $separator = '-'): Utility
    {
        $string = mb_convert_encoding($this->string, 'UTF-8', $this->encoding);
        $string = preg_replace('/[^\s\p{L}0-9\-' . $separator . ']/u', '', $string);
        $string = htmlentities($string, ENT_QUOTES, 'UTF-8');
        $string = preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', $string);
        $string = iconv('utf-8', 'ASCII//TRANSLIT//IGNORE', $string);
        $string = html_entity_decode($string, ENT_QUOTES, 'UTF-8');
        $string = preg_replace('~[^0-9a-z]+~i', $separator, $string);
        $string = trim($string, $separator);
        $string = mb_strtolower($string);

        return new static($string, $this->encoding);
    }
public function toSlug(string $separator = '-'): Utility
    {
        $string = mb_convert_encoding($this->string, 'UTF-8', $this->encoding);
        $string = preg_replace('/[^\s\p{L}0-9\-' . $separator . ']/u', '', $string);
        $string = htmlentities($string, ENT_QUOTES, 'UTF-8');
        $string = preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', $string);
        $string = iconv('utf-8', 'ASCII//TRANSLIT//IGNORE', $string);
        $string = html_entity_decode($string, ENT_QUOTES, 'UTF-8');
        $string = preg_replace('~[^0-9a-z]+~i', $separator, $string);
        $string = trim($string, $separator);
        $string = mb_strtolower($string);

        return new static($string, $this->encoding);
    }
public function toSlug ( string $ separator = '-' ) : Utility { $ string = mb_convert_encoding ( $ this -> string , 'UTF-8' , $ this -> encoding ) ; $ string = preg_replace ( '/[^\s\p{L}0-9\-' . $ separator . ']/u' , '' , $ string ) ; $ string = htmlentities ( $ string , ENT_QUOTES , 'UTF-8' ) ; $ string = preg_replace ( '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i' , '$1' , $ string ) ; $ string = iconv ( 'utf-8' , 'ASCII//TRANSLIT//IGNORE' , $ string ) ; $ string = html_entity_decode ( $ string , ENT_QUOTES , 'UTF-8' ) ; $ string = preg_replace ( '~[^0-9a-z]+~i' , $ separator , $ string ) ; $ string = trim ( $ string , $ separator ) ; $ string = mb_strtolower ( $ string ) ; return new static ( $ string , $ this -> encoding ) ; }
Clean a string to only have alpha numeric characters,
turn spaces into a separator slug

@param string $separator Value to separate chunks with

@return $this
Clean a string to only have alpha numeric characters turn spaces into a separator slug