public function toVar(string $name, bool $strict = true): string
    {
        $name = $this->stripClean($name);

        $var = $name; // Initialize.
        $var = mb_strtolower($this->c::forceAscii($var));
        $var = preg_replace('/[^a-z0-9]+/u', '_', $var);
        $var = $this->c::mbTrim($var, '', '_');

        if ($strict && $var && !preg_match('/^[a-z]/u', $var)) {
            $var = 'x'.$var; // Force `^[a-z]`.
        }
        return $var;
    }
public function toVar(string $name, bool $strict = true): string
    {
        $name = $this->stripClean($name);

        $var = $name; // Initialize.
        $var = mb_strtolower($this->c::forceAscii($var));
        $var = preg_replace('/[^a-z0-9]+/u', '_', $var);
        $var = $this->c::mbTrim($var, '', '_');

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

@since 160220 Var utils.

@param string $name   Full name.
@param bool   $strict Strict?

@return string Var; based on name.
Convert name to var .