/** * Get slugged index * @param string $value * @param bool $ascii * @return string */ protected function getSluggedIndex($value, $ascii = false) { // Get original $separator = $this->reader->getSeparator(); // Convert to ascii when needed if ($ascii) { $value = $this->getAsciiIndex($value); } // Convert all dashes/underscores into separator $flip = $separator == '-' ? '_' : '-'; $value = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $value); // Remove all characters that are not the separator, letters, numbers, or whitespace. $value = preg_replace('![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u', '', mb_strtolower($value)); // Replace all separator characters and whitespace by a single separator $value = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $value); return trim($value, $separator); }