Skip to content

Commit 046016e

Browse files
committed
:octocat: separate QR reader options
1 parent dfb4ca9 commit 046016e

File tree

3 files changed

+51
-36
lines changed

3 files changed

+51
-36
lines changed

src/QRCodeReaderOptionsTrait.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* QRCodeReaderOptionsTrait.php
4+
*
5+
* @created 01.03.2024
6+
* @author smiley <[email protected]>
7+
* @copyright 2024 smiley
8+
* @license MIT
9+
*/
10+
11+
namespace chillerlan\QRCode;
12+
13+
use function extension_loaded;
14+
15+
/**
16+
* Trait QRCodeReaderOptionsTrait
17+
*/
18+
trait QRCodeReaderOptionsTrait{
19+
20+
/**
21+
* Use Imagick (if available) when reading QR Codes
22+
*/
23+
protected bool $readerUseImagickIfAvailable = false;
24+
25+
/**
26+
* Grayscale the image before reading
27+
*/
28+
protected bool $readerGrayscale = false;
29+
30+
/**
31+
* Invert the colors of the image
32+
*/
33+
protected bool $readerInvertColors = false;
34+
35+
/**
36+
* Increase the contrast before reading
37+
*
38+
* note that applying contrast works different in GD and Imagick, so mileage may vary
39+
*/
40+
protected bool $readerIncreaseContrast = false;
41+
42+
/**
43+
* enables Imagick for the QR Code reader if the extension is available
44+
*/
45+
protected function set_readerUseImagickIfAvailable(bool $useImagickIfAvailable):void{
46+
$this->readerUseImagickIfAvailable = ($useImagickIfAvailable && extension_loaded('imagick'));
47+
}
48+
49+
}

src/QROptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
* The QRCode settings container
1717
*/
1818
class QROptions extends SettingsContainerAbstract{
19-
use QROptionsTrait;
19+
use QROptionsTrait, QRCodeReaderOptionsTrait;
2020
}

src/QROptionsTrait.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
use chillerlan\QRCode\Common\{EccLevel, MaskPattern, Version};
1818
use chillerlan\QRCode\Output\QRMarkupSVG;
19-
use function constant, extension_loaded, in_array, is_string, max, min, sprintf, strtolower, strtoupper, trim;
19+
use function constant, in_array, is_string, max, min, sprintf, strtolower, strtoupper, trim;
2020
use const JSON_THROW_ON_ERROR, PHP_EOL;
2121

2222
/**
@@ -427,33 +427,6 @@ trait QROptionsTrait{
427427
protected string $fpdfMeasureUnit = 'pt';
428428

429429

430-
/*
431-
* QR Code reader settings
432-
*/
433-
434-
/**
435-
* Use Imagick (if available) when reading QR Codes
436-
*/
437-
protected bool $readerUseImagickIfAvailable = false;
438-
439-
/**
440-
* Grayscale the image before reading
441-
*/
442-
protected bool $readerGrayscale = false;
443-
444-
/**
445-
* Invert the colors of the image
446-
*/
447-
protected bool $readerInvertColors = false;
448-
449-
/**
450-
* Increase the contrast before reading
451-
*
452-
* note that applying contrast works different in GD and Imagick, so mileage may vary
453-
*/
454-
protected bool $readerIncreaseContrast = false;
455-
456-
457430
/**
458431
* clamp min/max version number
459432
*/
@@ -534,13 +507,6 @@ protected function set_fpdfMeasureUnit(string $unit):void{
534507
// @todo throw or ignore silently?
535508
}
536509

537-
/**
538-
* enables Imagick for the QR Code reader if the extension is available
539-
*/
540-
protected function set_readerUseImagickIfAvailable(bool $useImagickIfAvailable):void{
541-
$this->readerUseImagickIfAvailable = ($useImagickIfAvailable && extension_loaded('imagick'));
542-
}
543-
544510
/**
545511
* clamp the logo space values between 0 and maximum length (177 modules at version 40)
546512
*/

0 commit comments

Comments
 (0)