public function transform($string, array $ruleNames = array())
    {
        $rules = $this->getRules();

        foreach ($ruleNames ?: array_keys($rules) as $ruleName) {
            if (!isset($rules[$ruleName])) {
                // Just continue on unknown rules, or should we throw an error
                // here?
                continue;
            }

            foreach ($rules[$ruleName] as $rule) {
                $string = preg_replace_callback(
                    $rule['regexp'],
                    $rule['callback'],
                    $string
                );
            }
        }

        return $string;
    }
public function transform($string, array $ruleNames = array())
    {
        $rules = $this->getRules();

        foreach ($ruleNames ?: array_keys($rules) as $ruleName) {
            if (!isset($rules[$ruleName])) {
                // Just continue on unknown rules, or should we throw an error
                // here?
                continue;
            }

            foreach ($rules[$ruleName] as $rule) {
                $string = preg_replace_callback(
                    $rule['regexp'],
                    $rule['callback'],
                    $string
                );
            }
        }

        return $string;
    }
public function transform ( $ string , array $ ruleNames = array ( ) ) { $ rules = $ this -> getRules ( ) ; foreach ( $ ruleNames ? : array_keys ( $ rules ) as $ ruleName ) { if ( ! isset ( $ rules [ $ ruleName ] ) ) { // Just continue on unknown rules, or should we throw an error // here? continue ; } foreach ( $ rules [ $ ruleName ] as $ rule ) { $ string = preg_replace_callback ( $ rule [ 'regexp' ] , $ rule [ 'callback' ] , $ string ) ; } } return $ string ; }
Transform the given string.

Transform the given string using the given rules. If no rules are
specified, all available rules will be used for the transformation.

@param string $string
@param array $ruleNames

@return string
Transform the given string .