App_CLI::normalizeName PHP Метод

normalizeName() публичный Метод

This will replace all non alpha-numeric characters with separator. Multiple separators in a row is replaced with one. Separators in beginning and at the end of name are removed. Sample input: "Hello, Dear Jon!" Sample output: "Hello_Dear_Jon"
public normalizeName ( string $name, string $separator = '_' ) : string
$name string String to process
$separator string Character acting as separator
Результат string Normalized string
    public function normalizeName($name, $separator = '_')
    {
        if (strlen($separator) == 0) {
            return preg_replace('|[^a-z0-9]|i', '', $name);
        }
        $s = $separator[0];
        $name = preg_replace('|[^a-z0-9\\' . $s . ']|i', $s, $name);
        $name = trim($name, $s);
        $name = preg_replace('|\\' . $s . '{2,}|', $s, $name);
        return $name;
    }