public function doReplace($data)
    {
        $data = preg_replace_callback(
            '/#([^\s\r#]+)#/',
            function ($matches) {
                if (defined($matches[1])) {
                    return constant($matches[1]);
                }

                return $matches[0];
            },
            $data
        );

        if (isset($this->values)) {
            $values = $this->values;

            $data = preg_replace_callback(
                '/%([^\s\r%]+)%/',
                function ($matches) use ($values) {
                    if (isset($values[$matches[1]])) {
                        return $values[$matches[1]];
                    }

                    return $matches[0];
                },
                $data
            );
        }

        return $data;
    }