Просмотр исходного кода

:octocat: separate QR reader options

smiley 1 год назад
Родитель
Сommit
046016e76e
3 измененных файлов с 51 добавлено и 36 удалено
  1. 49 0
      src/QRCodeReaderOptionsTrait.php
  2. 1 1
      src/QROptions.php
  3. 1 35
      src/QROptionsTrait.php

+ 49 - 0
src/QRCodeReaderOptionsTrait.php

@@ -0,0 +1,49 @@
+<?php
+/**
+ * QRCodeReaderOptionsTrait.php
+ *
+ * @created      01.03.2024
+ * @author       smiley <smiley@chillerlan.net>
+ * @copyright    2024 smiley
+ * @license      MIT
+ */
+
+namespace chillerlan\QRCode;
+
+use function extension_loaded;
+
+/**
+ * Trait QRCodeReaderOptionsTrait
+ */
+trait QRCodeReaderOptionsTrait{
+
+	/**
+	 * Use Imagick (if available) when reading QR Codes
+	 */
+	protected bool $readerUseImagickIfAvailable = false;
+
+	/**
+	 * Grayscale the image before reading
+	 */
+	protected bool $readerGrayscale = false;
+
+	/**
+	 * Invert the colors of the image
+	 */
+	protected bool $readerInvertColors = false;
+
+	/**
+	 * Increase the contrast before reading
+	 *
+	 * note that applying contrast works different in GD and Imagick, so mileage may vary
+	 */
+	protected bool $readerIncreaseContrast = false;
+
+	/**
+	 * enables Imagick for the QR Code reader if the extension is available
+	 */
+	protected function set_readerUseImagickIfAvailable(bool $useImagickIfAvailable):void{
+		$this->readerUseImagickIfAvailable = ($useImagickIfAvailable && extension_loaded('imagick'));
+	}
+
+}

+ 1 - 1
src/QROptions.php

@@ -16,5 +16,5 @@ use chillerlan\Settings\SettingsContainerAbstract;
  * The QRCode settings container
  */
 class QROptions extends SettingsContainerAbstract{
-	use QROptionsTrait;
+	use QROptionsTrait, QRCodeReaderOptionsTrait;
 }

+ 1 - 35
src/QROptionsTrait.php

@@ -16,7 +16,7 @@ namespace chillerlan\QRCode;
 
 use chillerlan\QRCode\Common\{EccLevel, MaskPattern, Version};
 use chillerlan\QRCode\Output\QRMarkupSVG;
-use function constant, extension_loaded, in_array, is_string, max, min, sprintf, strtolower, strtoupper, trim;
+use function constant, in_array, is_string, max, min, sprintf, strtolower, strtoupper, trim;
 use const JSON_THROW_ON_ERROR, PHP_EOL;
 
 /**
@@ -427,33 +427,6 @@ trait QROptionsTrait{
 	protected string $fpdfMeasureUnit = 'pt';
 
 
-	/*
-	 * QR Code reader settings
-	 */
-
-	/**
-	 * Use Imagick (if available) when reading QR Codes
-	 */
-	protected bool $readerUseImagickIfAvailable = false;
-
-	/**
-	 * Grayscale the image before reading
-	 */
-	protected bool $readerGrayscale = false;
-
-	/**
-	 * Invert the colors of the image
-	 */
-	protected bool $readerInvertColors = false;
-
-	/**
-	 * Increase the contrast before reading
-	 *
-	 * note that applying contrast works different in GD and Imagick, so mileage may vary
-	 */
-	protected bool $readerIncreaseContrast = false;
-
-
 	/**
 	 * clamp min/max version number
 	 */
@@ -534,13 +507,6 @@ trait QROptionsTrait{
 		// @todo throw or ignore silently?
 	}
 
-	/**
-	 * enables Imagick for the QR Code reader if the extension is available
-	 */
-	protected function set_readerUseImagickIfAvailable(bool $useImagickIfAvailable):void{
-		$this->readerUseImagickIfAvailable = ($useImagickIfAvailable && extension_loaded('imagick'));
-	}
-
 	/**
 	 * clamp the logo space values between 0 and maximum length (177 modules at version 40)
 	 */