codemasher 5 лет назад
Родитель
Сommit
04842a3c31
2 измененных файлов с 16 добавлено и 7 удалено
  1. 1 7
      src/Data/QRDataAbstract.php
  2. 15 0
      src/Data/QRMatrix.php

+ 1 - 7
src/Data/QRDataAbstract.php

@@ -101,13 +101,7 @@ abstract class QRDataAbstract implements QRDataInterface{
 	 */
 	 */
 	public function initMatrix(int $maskPattern, bool $test = null):QRMatrix{
 	public function initMatrix(int $maskPattern, bool $test = null):QRMatrix{
 		return (new QRMatrix($this->version, $this->options->eccLevel))
 		return (new QRMatrix($this->version, $this->options->eccLevel))
-			->setFinderPattern()
-			->setSeparators()
-			->setAlignmentPattern()
-			->setTimingPattern()
-			->setVersionNumber($test)
-			->setFormatInfo($maskPattern, $test)
-			->setDarkModule()
+			->init($maskPattern, $test)
 			->mapData($this->matrixdata, $maskPattern)
 			->mapData($this->matrixdata, $maskPattern)
 		;
 		;
 	}
 	}

+ 15 - 0
src/Data/QRMatrix.php

@@ -200,6 +200,21 @@ class QRMatrix{
 		$this->matrix      = array_fill(0, $this->moduleCount, array_fill(0, $this->moduleCount, $this::M_NULL));
 		$this->matrix      = array_fill(0, $this->moduleCount, array_fill(0, $this->moduleCount, $this::M_NULL));
 	}
 	}
 
 
+	/**
+	 * shortcut to initialize the matrix
+	 */
+	public function init(int $maskPattern, bool $test = null):QRMatrix{
+		return $this
+			->setFinderPattern()
+			->setSeparators()
+			->setAlignmentPattern()
+			->setTimingPattern()
+			->setVersionNumber($test)
+			->setFormatInfo($maskPattern, $test)
+			->setDarkModule()
+		;
+	}
+
 	/**
 	/**
 	 *
 	 *
 	 */
 	 */