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

Enable file save in render method #21

Merged
merged 3 commits into from
Nov 4, 2022

Conversation

ayaseensd
Copy link

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Adding file save feature

What is the current behaviour? (You can also link to an open issue here)

  • the current behaviour it recieve array of options without argument for saving file which provided by chillerlan/php-qrcode

What is the new behaviour? (You can also link to the ticket here)

  • I edit render method of GenerateQrCode class, to accept mixed arguments, I only process on two arguments, if each of one arguments is string I consider it file path, otherwise I consider it array argument for QROptions class.
  • arrangement of two arguments ignored, and more than 2 arguments also ignored.
  • I use this way to make render call clean and to avoid breaking of previous behaviour.

Does this PR introduce a breaking change?

  • No

@ali-alharthi
Copy link
Contributor

Why not add another optional parameter to the render function?

public function render(array $options = [], string $file = null): string {
        $options = new QROptions($options);
        return (new QRCode($options))->render($this->toBase64(), $file ?? null);
}

I think its more IDE friendly and most importantly cleaner.

@ayaseensd
Copy link
Author

@ali-alharthi I first implemented this approach, which is similar to chillerlan/php-qrcode implementation in that I intended to run render method unconditionally params order, so render($options), render($file),render($file,$options) or render($options,$file).

but I think you are right.

@salkhwlani salkhwlani merged commit e8f53ce into SallaApp:master Nov 4, 2022
@salkhwlani
Copy link
Member

@ayaseensd @ali-alharthi thank you for your contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants