public function apply($txt)
    {
        if (!is_string($txt))
            throw new \RuntimeException("Argument should be a string");

        foreach ($this->rules as $pattern => $replacement)
        {
            if (is_callable($replacement))
                $txt = preg_replace_callback($pattern, $replacement, $txt);
            else
                $txt = preg_replace($pattern, $replacement, $txt);
        }

        return $txt;
    }
public function apply($txt)
    {
        if (!is_string($txt))
            throw new \RuntimeException("Argument should be a string");

        foreach ($this->rules as $pattern => $replacement)
        {
            if (is_callable($replacement))
                $txt = preg_replace_callback($pattern, $replacement, $txt);
            else
                $txt = preg_replace($pattern, $replacement, $txt);
        }

        return $txt;
    }
public function apply ( $ txt ) { if ( ! is_string ( $ txt ) ) throw new \ RuntimeException ( "Argument should be a string" ) ; foreach ( $ this -> rules as $ pattern => $ replacement ) { if ( is_callable ( $ replacement ) ) $ txt = preg_replace_callback ( $ pattern , $ replacement , $ txt ) ; else $ txt = preg_replace ( $ pattern , $ replacement , $ txt ) ; } return $ txt ; }
Apply all the configured rules to the provided text and return the result
@param $txt string The text to work on
@return string The text with the patterns replaced by their replacements
Apply all the configured rules to the provided text and return the result