private function filterPath(?string $path): string
    {
        if (null === $path) {
            throw new SyntaxError('The path can not be null');
        }

        if ('' === $path || ',' === $path) {
            return 'text/plain;charset=us-ascii,';
        }

        if (1 === preg_match(self::REGEXP_DATAPATH, $path)) {
            $path = substr($path, 0, -1).'charset=us-ascii,';
        }

        if (1 === preg_match(self::REGEXP_NON_ASCII_PATTERN, $path) && false === strpos($path, ',')) {
            throw new SyntaxError(sprintf('The path `%s` is invalid according to RFC2937', $path));
        }

        return $path;
    }
private function filterPath(?string $path): string
    {
        if (null === $path) {
            throw new SyntaxError('The path can not be null');
        }

        if ('' === $path || ',' === $path) {
            return 'text/plain;charset=us-ascii,';
        }

        if (1 === preg_match(self::REGEXP_DATAPATH, $path)) {
            $path = substr($path, 0, -1).'charset=us-ascii,';
        }

        if (1 === preg_match(self::REGEXP_NON_ASCII_PATTERN, $path) && false === strpos($path, ',')) {
            throw new SyntaxError(sprintf('The path `%s` is invalid according to RFC2937', $path));
        }

        return $path;
    }
private function filterPath ( ? string $ path ) : string { if ( null === $ path ) { throw new SyntaxError ( 'The path can not be null' ) ; } if ( '' === $ path || ',' === $ path ) { return 'text/plain;charset=us-ascii,' ; } if ( 1 === preg_match ( self :: REGEXP_DATAPATH , $ path ) ) { $ path = substr ( $ path , 0 , - 1 ) . 'charset=us-ascii,' ; } if ( 1 === preg_match ( self :: REGEXP_NON_ASCII_PATTERN , $ path ) && false === strpos ( $ path , ',' ) ) { throw new SyntaxError ( sprintf ( 'The path `%s` is invalid according to RFC2937' , $ path ) ) ; } return $ path ; }
Filter the data path.

@param ?string $path

@throws SyntaxError If the path is null
@throws SyntaxError If the path is not valid according to RFC2937
Filter the data path .