public function toSlug(string $var, bool $strict = true): string
    {
        $slug = $var; // Initialize.
        $slug = mb_strtolower($this->c::forceAscii($slug));
        $slug = preg_replace('/[^a-z0-9]+/u', '-', $slug);
        $slug = $this->c::mbTrim($slug, '', '-');

        if ($strict && $slug && !preg_match('/^[a-z]/u', $slug)) {
            $slug = 'x'.$slug; // Force `^[a-z]`.
        }
        return $slug;
    }
public function toSlug(string $var, bool $strict = true): string
    {
        $slug = $var; // Initialize.
        $slug = mb_strtolower($this->c::forceAscii($slug));
        $slug = preg_replace('/[^a-z0-9]+/u', '-', $slug);
        $slug = $this->c::mbTrim($slug, '', '-');

        if ($strict && $slug && !preg_match('/^[a-z]/u', $slug)) {
            $slug = 'x'.$slug; // Force `^[a-z]`.
        }
        return $slug;
    }
public function toSlug ( string $ var , bool $ strict = true ) : string { $ slug = $ var ; // Initialize. $ slug = mb_strtolower ( $ this -> c :: forceAscii ( $ slug ) ) ; $ slug = preg_replace ( '/[^a-z0-9]+/u' , '-' , $ slug ) ; $ slug = $ this -> c :: mbTrim ( $ slug , '' , '-' ) ; if ( $ strict && $ slug && ! preg_match ( '/^[a-z]/u' , $ slug ) ) { $ slug = 'x' . $ slug ; // Force `^[a-z]`. } return $ slug ; }
Convert var to slug.

@since 160220 Initial release.

@param string $var    Var.
@param bool   $strict Strict?

@return string Slug; based on var.
Convert var to slug .