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

Feature: add limit option to setvalues #2640

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

moghwan
Copy link

@moghwan moghwan commented Aug 4, 2024

Description

This PR adds a limit parameter to the setValues function, which itself is uses within with setValue. This will help to avoid to minimize written if the limit is needed for a bulk search&replace operation.

example:

$templateProcessor = new TemplateProcessor('sample.docx');

$firstname = 'John';
$middlename = 'Mc';
$lastname = 'Doe';

// current
$templateProcessor->setValues([
    "firstname" => $firstname,
    "middlename" => $middlename,
    "lastname" => $lastname,
]);

// assuming we want to change the only the "first" name variables:
// workaround
$templateProcessor->setValue("firstname", $firstname, 1);
$templateProcessor->setValue("middlename", $middlename, 1);
$templateProcessor->setValue("lastname", $lastname, 1);

// improvement
$templateProcessor->setValues([
    "firstname" => $firstname,
    "middlename" => $middlename,
    "lastname" => $lastname,
], 1);

Checklist:

  • My CI is 🟢
  • I have covered by unit tests my new code (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes
  • I have updated the changelog

@moghwan moghwan marked this pull request as ready for review August 4, 2024 15:19
@coveralls
Copy link

coveralls commented Aug 4, 2024

Coverage Status

coverage: 97.04%. remained the same
when pulling 8d5d1aa on moghwan:feat/add-limit-to-setvalues
into 89a202e on PHPOffice:master.

@Progi1984
Copy link
Member

@Progi1984 Progi1984 added the Status: Waiting for feedback Question has been asked, waiting for response from PR author label Aug 7, 2024
@moghwan
Copy link
Author

moghwan commented Aug 26, 2024

sure thing!

@moghwan
Copy link
Author

moghwan commented Aug 27, 2024

done

@Progi1984 Progi1984 removed the Status: Waiting for feedback Question has been asked, waiting for response from PR author label Aug 30, 2024
@Progi1984 Progi1984 added this to the 1.3.1 milestone Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants