Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to limit number of replacements performed by setValue() method of Template class #52

Closed
ghost opened this issue Jan 16, 2014 · 1 comment
Milestone

Comments

@ghost
Copy link

ghost commented Jan 16, 2014

Sometimes we need to replace only several string occurrences in text. Current implementation of the corresponded method of Template class looks like as followed

/**
 * Set a Template value
 *
 * @param mixed $search
 * @param mixed $replace
 */
public function setValue($search, $replace)
{
    ...

    $this->_documentXML = str_replace($search, $replace, $this->_documentXML);
}

This gives us no chance to replace, for example, the first occcurrence only.

This issue is a proposal of setValue method inhancement by implementing the followed signature:

/**
 * Set a Template value
 *
 * @param mixed $search
 * @param mixed $replace
 * @param integer $limit
 */
public function setValue($search, $replace, $limit = -1) {
    ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant