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;
    }