public function sanitizePath($string)
    {
        if (!is_string($string) || empty($string)) {
            return '';
        }

        $replace = [
            '/\s+/'    => '_',
            '/\*{1,}/' => '',
            '/\.{2,}/' => '.',
            '/^\./'    => '',
            '/\.$/'    => '',
        ];

        return preg_replace(
            array_keys($replace),
            array_values($replace),
            trim($string)
        );
    }
public function sanitizePath($string)
    {
        if (!is_string($string) || empty($string)) {
            return '';
        }

        $replace = [
            '/\s+/'    => '_',
            '/\*{1,}/' => '',
            '/\.{2,}/' => '.',
            '/^\./'    => '',
            '/\.$/'    => '',
        ];

        return preg_replace(
            array_keys($replace),
            array_values($replace),
            trim($string)
        );
    }
public function sanitizePath ( $ string ) { if ( ! is_string ( $ string ) || empty ( $ string ) ) { return '' ; } $ replace = [ '/\s+/' => '_' , '/\*{1,}/' => '' , '/\.{2,}/' => '.' , '/^\./' => '' , '/\.$/' => '' , ] ; return preg_replace ( array_keys ( $ replace ) , array_values ( $ replace ) , trim ( $ string ) ) ; }
Sanitizes a path string

Carbon stores metrics using dot delimited paths
{@link http://graphite.readthedocs.org/en/latest/feeding-carbon.html}

Replaces:
- whitespace with undercores
- consecutive dots with a single dot.

Removes:
- the wildcard character (used by graphite)
- leading and trailing dots

@param string $path the path string to sanitize

@return string The sanitized path string or an empty one.
Sanitizes a path string