Stringy\Stringy::slugify PHP Метод

slugify() публичный метод

Converts the string into an URL slug. This includes replacing non-ASCII characters with their closest ASCII equivalents, removing remaining non-ASCII and non-alphanumeric characters, and replacing whitespace with $replacement. The replacement defaults to a single dash, and the string is also converted to lowercase.
public slugify ( string $replacement = '-' ) : Stringy
$replacement string The string used to replace whitespace
Результат Stringy Object whose $str has been converted to an URL slug
    public function slugify($replacement = '-')
    {
        $stringy = $this->toAscii();
        $quotedReplacement = preg_quote($replacement);
        $pattern = "/[^a-zA-Z\\d\\s-_{$quotedReplacement}]/u";
        $stringy->str = preg_replace($pattern, '', $stringy);
        return $stringy->toLowerCase()->delimit($replacement)->removeLeft($replacement)->removeRight($replacement);
    }