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/Customizing/Custom-output-interface.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Custom `QROutputInterface`
2
2
3
-
Let's suppose that you want to create your own output interface because there's no built-in output class that supports the format you need for your application.
3
+
Let's suppose that we want to create our own output interface because there's no built-in output class that supports the format we need for our application.
4
4
In this example we'll create a string output class that outputs the coordinates for each module, separated by module type.
5
5
6
6
@@ -36,7 +36,7 @@ In this example we'll accept string values, the characters `a-z` (case-insensiti
36
36
}
37
37
```
38
38
39
-
To prepare the final module substitute, you should transform the given (validated) input value in a way so that it can be accessed without any further calls or transformation.
39
+
To prepare the final module substitute, we should transform the given (validated) input value in a way so that it can be accessed without any further calls or transformation.
40
40
In the built-in output for example this means it would return an `ImagickPixel` instance or the integer value returned by `imagecolorallocate()` on the current `GdImage` instance.
41
41
42
42
For our example, we'll lowercase the validated string:
@@ -47,8 +47,8 @@ For our example, we'll lowercase the validated string:
47
47
}
48
48
```
49
49
50
-
Finally, we need to provide a default value for dark and light, you can call `prepareModuleValue()` here if necessary.
51
-
We'll return an empty string `''`here as we're going to use the `QROutputInterface::LAYERNAMES` constant for non-existing values
50
+
Finally, we need to provide a default value for dark and light, we can call `prepareModuleValue()` here if necessary.
51
+
We'll return an empty string `''` as we're going to use the `QROutputInterface::LAYERNAMES` constant for non-existing values
52
52
(returning `null` would run into an exception in `QROutputAbstract::getModuleValue()`).
53
53
54
54
```php
@@ -105,14 +105,14 @@ We've introduced another method that handles the module rendering, which incoope
105
105
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
106
We'll modify the above `dump()` method to use `QROutputAbstract::collectModules()` instead.
107
107
108
-
The module collector accepts a closure as its only parameter, the closure is called with 4 parameters:
108
+
The module collector accepts a `Closure` as its only parameter, which is called with 4 parameters:
109
109
110
110
-`$x` : current column
111
111
-`$y` : current row
112
112
-`$M_TYPE` : field value
113
113
-`$M_TYPE_LAYER`: (possibly modified) field value that acts as layer id
114
114
115
-
We'll only need the first 3 parameters, so our closure would look as follows:
115
+
We only need the first 3 parameters, so our closure would look as follows:
116
116
117
117
```php
118
118
$closure = fn(int $x, int $y, int $M_TYPE):string => $this->module($x, $y, $M_TYPE);
0 commit comments