Deploying to readthedocs from @ chillerlan/php-qrcode@a301af5b7f 🚀

This commit is contained in:
codemasher
2023-11-24 15:56:50 +00:00
parent 03776aa566
commit 83ebe1462d
4 changed files with 14 additions and 14 deletions
+6 -6
View File
@@ -365,7 +365,7 @@
<section id="custom-qroutputinterface">
<h1>Custom <code class="docutils literal notranslate"><span class="pre">QROutputInterface</span></code><a class="headerlink" href="#custom-qroutputinterface" title="Link to this heading"></a></h1>
<p>Lets suppose that you want to create your own output interface because theres no built-in output class that supports the format you need for your application.
<p>Lets suppose that we want to create our own output interface because theres no built-in output class that supports the format we need for our application.
In this example well create a string output class that outputs the coordinates for each module, separated by module type.</p>
<section id="class-skeleton">
<h2>Class skeleton<a class="headerlink" href="#class-skeleton" title="Link to this heading"></a></h2>
@@ -394,7 +394,7 @@ For example in the built-in GD output it would check if the value is an array th
<span class="p">}</span>
</pre></div>
</div>
<p>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.
<p>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.
In the built-in output for example this means it would return an <code class="docutils literal notranslate"><span class="pre">ImagickPixel</span></code> instance or the integer value returned by <code class="docutils literal notranslate"><span class="pre">imagecolorallocate()</span></code> on the current <code class="docutils literal notranslate"><span class="pre">GdImage</span></code> instance.</p>
<p>For our example, well lowercase the validated string:</p>
<div class="highlight-php notranslate"><div class="highlight"><pre><span></span> <span class="k">protected</span> <span class="k">function</span> <span class="nf">prepareModuleValue</span><span class="p">(</span><span class="nv">$value</span><span class="p">)</span><span class="o">:</span><span class="nx">string</span><span class="p">{</span>
@@ -402,8 +402,8 @@ In the built-in output for example this means it would return an <code class="do
<span class="p">}</span>
</pre></div>
</div>
<p>Finally, we need to provide a default value for dark and light, you can call <code class="docutils literal notranslate"><span class="pre">prepareModuleValue()</span></code> here if necessary.
Well return an empty string <code class="docutils literal notranslate"><span class="pre">''</span></code> here as were going to use the <code class="docutils literal notranslate"><span class="pre">QROutputInterface::LAYERNAMES</span></code> constant for non-existing values
<p>Finally, we need to provide a default value for dark and light, we can call <code class="docutils literal notranslate"><span class="pre">prepareModuleValue()</span></code> here if necessary.
Well return an empty string <code class="docutils literal notranslate"><span class="pre">''</span></code> as were going to use the <code class="docutils literal notranslate"><span class="pre">QROutputInterface::LAYERNAMES</span></code> constant for non-existing values
(returning <code class="docutils literal notranslate"><span class="pre">null</span></code> would run into an exception in <code class="docutils literal notranslate"><span class="pre">QROutputAbstract::getModuleValue()</span></code>).</p>
<div class="highlight-php notranslate"><div class="highlight"><pre><span></span> <span class="k">protected</span> <span class="k">function</span> <span class="nf">getDefaultModuleValue</span><span class="p">(</span><span class="nx">bool</span> <span class="nv">$isDark</span><span class="p">)</span><span class="o">:</span><span class="nx">string</span><span class="p">{</span>
<span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="p">;</span>
@@ -453,14 +453,14 @@ In order to do so, we need to collect the modules per <code class="docutils lite
</div>
<p>Speaking of option settings, theres also <code class="docutils literal notranslate"><span class="pre">QROptions::$connectPaths</span></code> which we havent taken care of yet - the good news is that we dont need to as it is already implemented!
Well modify the above <code class="docutils literal notranslate"><span class="pre">dump()</span></code> method to use <code class="docutils literal notranslate"><span class="pre">QROutputAbstract::collectModules()</span></code> instead.</p>
<p>The module collector accepts a closure as its only parameter, the closure is called with 4 parameters:</p>
<p>The module collector accepts a <code class="docutils literal notranslate"><span class="pre">Closure</span></code> as its only parameter, which is called with 4 parameters:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">$x</span></code> : current column</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">$y</span></code> : current row</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">$M_TYPE</span></code> : field value</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">$M_TYPE_LAYER</span></code>: (possibly modified) field value that acts as layer id</p></li>
</ul>
<p>Well only need the first 3 parameters, so our closure would look as follows:</p>
<p>We only need the first 3 parameters, so our closure would look as follows:</p>
<div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="nv">$closure</span> <span class="o">=</span> <span class="nx">fn</span><span class="p">(</span><span class="nx">int</span> <span class="nv">$x</span><span class="p">,</span> <span class="nx">int</span> <span class="nv">$y</span><span class="p">,</span> <span class="nx">int</span> <span class="nv">$M_TYPE</span><span class="p">)</span><span class="o">:</span><span class="nx">string</span> <span class="o">=&gt;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">module</span><span class="p">(</span><span class="nv">$x</span><span class="p">,</span> <span class="nv">$y</span><span class="p">,</span> <span class="nv">$M_TYPE</span><span class="p">);</span>
</pre></div>
</div>
@@ -1,6 +1,6 @@
# Custom `QROutputInterface`
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.
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.
In this example we'll create a string output class that outputs the coordinates for each module, separated by module type.
@@ -36,7 +36,7 @@ In this example we'll accept string values, the characters `a-z` (case-insensiti
}
```
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.
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.
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.
For our example, we'll lowercase the validated string:
@@ -47,8 +47,8 @@ For our example, we'll lowercase the validated string:
}
```
Finally, we need to provide a default value for dark and light, you can call `prepareModuleValue()` here if necessary.
We'll return an empty string `''` here as we're going to use the `QROutputInterface::LAYERNAMES` constant for non-existing values
Finally, we need to provide a default value for dark and light, we can call `prepareModuleValue()` here if necessary.
We'll return an empty string `''` as we're going to use the `QROutputInterface::LAYERNAMES` constant for non-existing values
(returning `null` would run into an exception in `QROutputAbstract::getModuleValue()`).
```php
@@ -105,14 +105,14 @@ We've introduced another method that handles the module rendering, which incoope
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!
We'll modify the above `dump()` method to use `QROutputAbstract::collectModules()` instead.
The module collector accepts a closure as its only parameter, the closure is called with 4 parameters:
The module collector accepts a `Closure` as its only parameter, which is called with 4 parameters:
- `$x` : current column
- `$y` : current row
- `$M_TYPE` : field value
- `$M_TYPE_LAYER`: (possibly modified) field value that acts as layer id
We'll only need the first 3 parameters, so our closure would look as follows:
We only need the first 3 parameters, so our closure would look as follows:
```php
$closure = fn(int $x, int $y, int $M_TYPE):string => $this->module($x, $y, $M_TYPE);
+1 -1
View File
@@ -364,7 +364,7 @@
<section id="php-qrcode-manual">
<h1>PHP-QRCode Manual<a class="headerlink" href="#php-qrcode-manual" title="Link to this heading"></a></h1>
<p>User manual for <a class="reference external" href="https://github.com/chillerlan/php-qrcode/">chillerlan/php-qrcode</a> [main]. Updated on Nov 23, 2023.</p>
<p>User manual for <a class="reference external" href="https://github.com/chillerlan/php-qrcode/">chillerlan/php-qrcode</a> [main]. Updated on Nov 24, 2023.</p>
<p>The phpDocumentor API documentation can be found at <a class="reference external" href="https://chillerlan.github.io/php-qrcode/">chillerlan.github.io/php-qrcode</a>.</p>
<p>This work is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) License.</p>
<div class="toctree-wrapper compound">
+1 -1
View File
File diff suppressed because one or more lines are too long