WsdlToPhp\PackageGenerator\Generator\Utils::cleanString PHP Méthode

cleanString() public static méthode

Clean a string to make it valid as PHP variable See more about the used regular expression at {@link http://www.regular-expressions.info/unicode.html}: - \p{L} for any valid letter - \p{N} for any valid number - /u for suporting unicode
public static cleanString ( string $string, boolean $keepMultipleUnderscores = true ) : string
$string string the string to clean
$keepMultipleUnderscores boolean optional, allows to keep the multiple consecutive underscores
Résultat string
    public static function cleanString($string, $keepMultipleUnderscores = true)
    {
        $cleanedString = preg_replace('/[^\\p{L}\\p{N}_]/u', '_', $string);
        if (!$keepMultipleUnderscores) {
            $cleanedString = preg_replace('/[_]+/', '_', $cleanedString);
        }
        return $cleanedString;
    }

Usage Example

 /**
  * Clean a string to make it valid as PHP variable
  * @uses GeneratorUtils::cleanString()
  * @param string $string the string to clean
  * @param bool $keepMultipleUnderscores optional, allows to keep the multiple consecutive underscores
  * @return string
  */
 public static function cleanString($string, $keepMultipleUnderscores = true)
 {
     return GeneratorUtils::cleanString($string, $keepMultipleUnderscores);
 }
All Usage Examples Of WsdlToPhp\PackageGenerator\Generator\Utils::cleanString