Skip to content

Commit a301af5

Browse files
committed
📖
1 parent 34820bd commit a301af5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/Customizing/Custom-output-interface.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Custom `QROutputInterface`
22

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.
44
In this example we'll create a string output class that outputs the coordinates for each module, separated by module type.
55

66

@@ -36,7 +36,7 @@ In this example we'll accept string values, the characters `a-z` (case-insensiti
3636
}
3737
```
3838

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.
4040
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.
4141

4242
For our example, we'll lowercase the validated string:
@@ -47,8 +47,8 @@ For our example, we'll lowercase the validated string:
4747
}
4848
```
4949

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
5252
(returning `null` would run into an exception in `QROutputAbstract::getModuleValue()`).
5353

5454
```php
@@ -105,14 +105,14 @@ We've introduced another method that handles the module rendering, which incoope
105105
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!
106106
We'll modify the above `dump()` method to use `QROutputAbstract::collectModules()` instead.
107107

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:
109109

110110
- `$x` : current column
111111
- `$y` : current row
112112
- `$M_TYPE` : field value
113113
- `$M_TYPE_LAYER`: (possibly modified) field value that acts as layer id
114114

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:
116116

117117
```php
118118
$closure = fn(int $x, int $y, int $M_TYPE):string => $this->module($x, $y, $M_TYPE);

0 commit comments

Comments
 (0)