You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Appendix/Contribute.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Please don't just write "headline says all" because the reply will likely be sim
14
14
15
15
So you found a bug or the library code is somehow misbehaving? That's great (well, not that great tho). In that case,
16
16
please [open a bug report and FILL OUT THE ISSUE TEMPLATE](https://github.com/chillerlan/php-qrcode/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=%5BBUG%5D)
17
-
(i have to write that in all caps because nobody actually does it which usually leads to several avoidable follow-up questions that cost both of us precious time).
17
+
(I have to write that in all caps because nobody actually does it which usually leads to several avoidable follow-up questions that cost both of us precious time).
18
18
Below an example of the bug report template (it's not that hard):
Copy file name to clipboardExpand all lines: docs/Appendix/URI-Content.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -253,11 +253,11 @@ END:VCALENDAR
253
253
254
254
## Credit Transfer
255
255
256
-
### SEPA
256
+
### SEPA (European Payments Council)
257
257
-[Guidelines to Enable the Data Capture for the Initiation of a SEPA Credit Transfer](https://www.europeanpaymentscouncil.eu/document-library/guidance-documents/quick-response-code-guidelines-enable-data-capture-initiation)
258
258
-[sepa-qr-data library for PHP (GitHub)](https://github.com/smhg/sepa-qr-data-php)
259
259
260
-
### Pix
260
+
### Pix (Banco Central do Brasil)
261
261
-[Manual de Padrões para Iniciação do Pix (PDF)](https://www.bcb.gov.br/content/estabilidadefinanceira/pix/Regulamento_Pix/II_ManualdePadroesparaIniciacaodoPix.pdf)
Speaking of option settings, there's also `QROptions::$connectPaths` which we haven't taken care of yet - the good news is that we don't need to as it is already implemented!
106
93
We'll modify the above `dump()` method to use `QROutputAbstract::collectModules()` instead.
107
94
108
-
The module collector accepts a `Closure` as its only parameter, which is called with 4 parameters:
95
+
The module collector calls a method `moduleTransform()` internally, which is called with 4 parameters:
109
96
110
97
-`$x` : current column
111
98
-`$y` : current row
112
99
-`$M_TYPE` : field value
113
100
-`$M_TYPE_LAYER`: (possibly modified) field value that acts as layer id
114
101
115
-
We only need the first 3 parameters, so our closure would look as follows:
102
+
We'## introduce another method that handles the module rendering, which incooperates handling of the `QROptions::$drawLightModules` setting:
116
103
117
104
```php
118
-
$closure = fn(int $x, int $y, int $M_TYPE):string => $this->module($x, $y, $M_TYPE);
119
-
```
105
+
protected function moduleTransform(int $x, int $y, int $M_TYPE, int $M_TYPE_LAYER):string{
120
106
121
-
As of PHP 8.1+ we can narrow this down with the [first class callable syntax](https://www.php.net/manual/en/functions.first_class_callable_syntax.php):
Copy file name to clipboardExpand all lines: docs/Customizing/QROutputAbstract.md
+1-4Lines changed: 1 addition & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,7 +117,6 @@ class MyOutput extends QROutputAbstract{
117
117
118
118
Both methods return a module value, the main difference is that `getModuleValueAt()` is a convenience method
119
119
that makes an extra call to retrieve the `$M_TYPE` from the given matrix coordinate to return the value via `getModuleValue()`.
120
-
121
120
A `foreach` loop over the matrix gives you the key (coordinate) *and* value of an array element:
122
121
123
122
```php
@@ -222,6 +221,7 @@ class MyOutput extends QROutputAbstract{
222
221
return implode($this->options->eol, $paths);
223
222
}
224
223
224
+
// this method must be implemented/overridden if your output class uses the module collector
225
225
protected function moduleTransform(int $x, int $y, int $M_TYPE, int $M_TYPE_LAYER):string{
226
226
return sprintf('%d %d %012b', $x, $y, $M_TYPE);
227
227
}
@@ -235,11 +235,8 @@ Sometimes it can be necessary to override `collectModules()` in order to apply s
235
235
### `saveToFile()` and `toBase64DataURI()`
236
236
237
237
The void method `saveToFile()` takes a data blob and the `$file` given in `QROutputInterface::dump()` and save to the path if it is not `null` - the file path itself is not checked except for writability.
238
-
239
238
The final output can be transformed to a [base64 data URI](https://en.wikipedia.org/wiki/Data_URI_scheme) with `toBase64DataURI()`, where the data blob and a valid mime type as parameters - the mime type is not checked.
0 commit comments