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

:octocat: proper names for QRMatrix getters

smiley 2 лет назад
Родитель
Сommit
1b2aa52d03

+ 1 - 1
examples/imageWithLogo.php

@@ -52,7 +52,7 @@ class QRImageWithLogo extends QRGdImage{
 		$lh = (($this->options->logoSpaceHeight - 2) * $this->options->scale);
 
 		// get the qrcode size
-		$ql = ($this->matrix->size() * $this->options->scale);
+		$ql = ($this->matrix->getSize() * $this->options->scale);
 
 		// scale the logo and copy it over. done!
 		imagecopyresampled($this->image, $im, (($ql - $lw) / 2), (($ql - $lh) / 2), 0, 0, $lw, $lh, $w, $h);

+ 1 - 1
examples/svgMeltedModules.php

@@ -38,7 +38,7 @@ class MeltedSVGQRCodeOutput extends QRMarkupSVG{
 		$paths = [];
 
 		// collect the modules for each type
-		foreach($this->matrix->matrix() as $y => $row){
+		foreach($this->matrix->getMatrix() as $y => $row){
 			foreach($row as $x => $M_TYPE){
 				$M_TYPE_LAYER = $M_TYPE;
 

+ 1 - 1
examples/svgRandomColoredDots.php

@@ -41,7 +41,7 @@ class RandomDotsSVGOutput extends QRMarkupSVG{
 		$paths = [];
 
 		// collect the modules for each type
-		foreach($this->matrix->matrix() as $y => $row){
+		foreach($this->matrix->getMatrix() as $y => $row){
 			foreach($row as $x => $M_TYPE){
 				$M_TYPE_LAYER = $M_TYPE;
 

+ 2 - 2
examples/svgRoundQuietzone.php

@@ -87,7 +87,7 @@ class RoundQuietzoneSVGoutput extends QRMarkupSVG{
 		// substract 1/2 stroke width and module radius from the circle radius to not cut off modules
 		$r  = ($radius - $this->options->circleRadius * 2);
 
-		foreach($this->matrix->matrix() as $y => $row){
+		foreach($this->matrix->getMatrix() as $y => $row){
 			foreach($row as $x => $value){
 
 				// skip anything that's not quiet zone
@@ -175,7 +175,7 @@ class RoundQuietzoneSVGoutput extends QRMarkupSVG{
 		$paths = [];
 
 		// collect the modules for each type
-		foreach($this->matrix->matrix() as $y => $row){
+		foreach($this->matrix->getMatrix() as $y => $row){
 			foreach($row as $x => $M_TYPE){
 				$M_TYPE_LAYER = $M_TYPE;
 

+ 1 - 1
src/Common/MaskPattern.php

@@ -116,7 +116,7 @@ final class MaskPattern{
 		$penalties = [];
 
 		foreach(self::PATTERNS as $pattern){
-			$matrix  = $dataInterface->writeMatrix(new self($pattern))->matrix(true);
+			$matrix  = $dataInterface->writeMatrix(new self($pattern))->getMatrix(true);
 			$penalty = 0;
 
 			for($level = 1; $level <= 4; $level++){

+ 5 - 5
src/Data/QRMatrix.php

@@ -147,7 +147,7 @@ class QRMatrix{
 	 *
 	 * @return int[][]|bool[][]
 	 */
-	public function matrix(bool $boolean = null):array{
+	public function getMatrix(bool $boolean = null):array{
 
 		if(!$boolean){
 			return $this->matrix;
@@ -169,21 +169,21 @@ class QRMatrix{
 	/**
 	 * Returns the current version number
 	 */
-	public function version():?Version{
+	public function getVersion():?Version{
 		return $this->version;
 	}
 
 	/**
 	 * Returns the current ECC level
 	 */
-	public function eccLevel():?EccLevel{
+	public function getEccLevel():?EccLevel{
 		return $this->eccLevel;
 	}
 
 	/**
 	 * Returns the current mask pattern
 	 */
-	public function maskPattern():?MaskPattern{
+	public function getMaskPattern():?MaskPattern{
 		return $this->maskPattern;
 	}
 
@@ -192,7 +192,7 @@ class QRMatrix{
 	 *
 	 * size = version * 4 + 17 [ + 2 * quietzone size]
 	 */
-	public function size():int{
+	public function getSize():int{
 		return $this->moduleCount;
 	}
 

+ 3 - 3
src/Decoder/Decoder.php

@@ -71,9 +71,9 @@ final class Decoder{
 	private function decodeMatrix(BitMatrix $matrix):DecoderResult{
 		// Read raw codewords
 		$rawCodewords      = $matrix->readCodewords();
-		$this->version     = $matrix->version();
-		$this->eccLevel    = $matrix->eccLevel();
-		$this->maskPattern = $matrix->maskPattern();
+		$this->version     = $matrix->getVersion();
+		$this->eccLevel    = $matrix->getEccLevel();
+		$this->maskPattern = $matrix->getMaskPattern();
 
 		if($this->version === null || $this->eccLevel === null || $this->maskPattern === null){
 			throw new QRCodeDecoderException('unable to read version or format info'); // @codeCoverageIgnore

+ 1 - 1
src/Detector/AlignmentPatternFinder.php

@@ -223,7 +223,7 @@ final class AlignmentPatternFinder{
 	 * @return float|null vertical center of alignment pattern, or null if not found
 	 */
 	private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):?float{
-		$maxI          = $this->matrix->size();
+		$maxI          = $this->matrix->getSize();
 		$stateCount    = [];
 		$stateCount[0] = 0;
 		$stateCount[1] = 0;

+ 2 - 2
src/Detector/Detector.php

@@ -124,7 +124,7 @@ final class Detector{
 	 */
 	private function sizeOfBlackWhiteBlackRunBothWays(float $fromX, float $fromY, float $toX, float $toY):float{
 		$result    = $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, (int)$toX, (int)$toY);
-		$dimension = $this->matrix->size();
+		$dimension = $this->matrix->getSize();
 		// Now count other way -- don't run off image though of course
 		$scale     = 1.0;
 		$otherToX  = ($fromX - ($toX - $fromX));
@@ -278,7 +278,7 @@ final class Detector{
 		float $allowanceFactor
 	):?AlignmentPattern{
 		// Look for an alignment pattern (3 modules in size) around where it should be
-		$dimension           = $this->matrix->size();
+		$dimension           = $this->matrix->getSize();
 		$allowance           = (int)($allowanceFactor * $overallEstModuleSize);
 		$alignmentAreaLeftX  = max(0, ($estAlignmentX - $allowance));
 		$alignmentAreaRightX = min(($dimension - 1), ($estAlignmentX + $allowance));

+ 4 - 4
src/Detector/FinderPatternFinder.php

@@ -49,7 +49,7 @@ final class FinderPatternFinder{
 	 * @return \chillerlan\QRCode\Detector\FinderPattern[]
 	 */
 	public function find():array{
-		$dimension = $this->matrix->size();
+		$dimension = $this->matrix->getSize();
 
 		// We are looking for black/white/black/white/black modules in
 		// 1:1:3:1:1 ratio; this tracks the number of such modules seen so far
@@ -286,7 +286,7 @@ final class FinderPatternFinder{
 			return false;
 		}
 
-		$dimension = $this->matrix->size();
+		$dimension = $this->matrix->getSize();
 
 		// Now also count down, right from center
 		$i = 1;
@@ -331,7 +331,7 @@ final class FinderPatternFinder{
 	 * @noinspection DuplicatedCode
 	 */
 	private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):?float{
-		$maxI       = $this->matrix->size();
+		$maxI       = $this->matrix->getSize();
 		$stateCount = $this->getCrossCheckStateCount();
 
 		// Start counting up from center
@@ -415,7 +415,7 @@ final class FinderPatternFinder{
 	 * @noinspection DuplicatedCode
 	 */
 	private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal):?float{
-		$maxJ       = $this->matrix->size();
+		$maxJ       = $this->matrix->getSize();
 		$stateCount = $this->getCrossCheckStateCount();
 
 		$j = $startJ;

+ 1 - 1
src/Detector/GridSampler.php

@@ -48,7 +48,7 @@ final class GridSampler{
 	 * @throws \chillerlan\QRCode\Detector\QRCodeDetectorException if an endpoint is lies outside the image boundaries
 	 */
 	private function checkAndNudgePoints(BitMatrix $matrix, array $points):void{
-		$dimension = $matrix->size();
+		$dimension = $matrix->getSize();
 		$nudged    = true;
 		$max       = count($points);
 

+ 1 - 1
src/Output/QRFpdf.php

@@ -115,7 +115,7 @@ class QRFpdf extends QROutputAbstract{
 
 		$prevColor = null;
 
-		foreach($this->matrix->matrix() as $y => $row){
+		foreach($this->matrix->getMatrix() as $y => $row){
 
 			foreach($row as $x => $M_TYPE){
 

+ 1 - 1
src/Output/QRGdImage.php

@@ -228,7 +228,7 @@ class QRGdImage extends QROutputAbstract{
 	 * Creates the QR image
 	 */
 	protected function drawImage():void{
-		foreach($this->matrix->matrix() as $y => $row){
+		foreach($this->matrix->getMatrix() as $y => $row){
 			foreach($row as $x => $M_TYPE){
 				$this->setPixel($x, $y, $M_TYPE);
 			}

+ 1 - 1
src/Output/QRImagick.php

@@ -186,7 +186,7 @@ class QRImagick extends QROutputAbstract{
 		$this->imagickDraw = new ImagickDraw;
 		$this->imagickDraw->setStrokeWidth(0);
 
-		foreach($this->matrix->matrix() as $y => $row){
+		foreach($this->matrix->getMatrix() as $y => $row){
 			foreach($row as $x => $M_TYPE){
 				$this->setPixel($x, $y, $M_TYPE);
 			}

+ 1 - 1
src/Output/QRMarkupHTML.php

@@ -27,7 +27,7 @@ class QRMarkupHTML extends QRMarkup{
 
 		$html .= $this->options->eol;
 
-		foreach($this->matrix->matrix() as $row){
+		foreach($this->matrix->getMatrix() as $row){
 			$html .= '<div>';
 
 			foreach($row as $M_TYPE){

+ 3 - 3
src/Output/QROutputAbstract.php

@@ -23,7 +23,7 @@ abstract class QROutputAbstract implements QROutputInterface{
 	/**
 	 * the current size of the QR matrix
 	 *
-	 * @see \chillerlan\QRCode\Data\QRMatrix::size()
+	 * @see \chillerlan\QRCode\Data\QRMatrix::getSize()
 	 */
 	protected int $moduleCount;
 
@@ -71,7 +71,7 @@ abstract class QROutputAbstract implements QROutputInterface{
 	 * Call this method if you modify the matrix from within your custom module in case the dimensions have been changed
 	 */
 	protected function setMatrixDimensions():void{
-		$this->moduleCount = $this->matrix->size();
+		$this->moduleCount = $this->matrix->getSize();
 		$this->scale       = $this->options->scale;
 		$this->length      = ($this->moduleCount * $this->scale);
 	}
@@ -152,7 +152,7 @@ abstract class QROutputAbstract implements QROutputInterface{
 		$paths = [];
 
 		// collect the modules for each type
-		foreach($this->matrix->matrix() as $y => $row){
+		foreach($this->matrix->getMatrix() as $y => $row){
 			foreach($row as $x => $M_TYPE){
 				$M_TYPE_LAYER = $M_TYPE;
 

+ 2 - 2
src/Output/QRString.php

@@ -66,7 +66,7 @@ class QRString extends QROutputAbstract{
 	protected function text():string{
 		$str = [];
 
-		foreach($this->matrix->matrix() as $row){
+		foreach($this->matrix->getMatrix() as $row){
 			$r = [];
 
 			foreach($row as $M_TYPE){
@@ -83,7 +83,7 @@ class QRString extends QROutputAbstract{
 	 * JSON output
 	 */
 	protected function json():string{
-		return json_encode($this->matrix->matrix());
+		return json_encode($this->matrix->getMatrix());
 	}
 
 }

+ 1 - 1
tests/Data/DataInterfaceTestAbstract.php

@@ -73,7 +73,7 @@ abstract class DataInterfaceTestAbstract extends TestCase{
 		$matrix = $this->QRData->writeMatrix(new MaskPattern($maskPattern));
 
 		$this::assertInstanceOf(QRMatrix::class, $matrix);
-		$this::assertSame($maskPattern, $matrix->maskPattern()->getPattern());
+		$this::assertSame($maskPattern, $matrix->getMaskPattern()->getPattern());
 	}
 
 	abstract public static function stringValidateProvider():array;

+ 1 - 1
tests/Data/QRDataTest.php

@@ -46,7 +46,7 @@ final class QRDataTest extends TestCase{
 		$maskPattern = MaskPattern::getBestPattern($QRData);
 		$matrix      = $QRData->writeMatrix($maskPattern);
 
-		$this::assertSame(3, $matrix->version()->getVersionNumber());
+		$this::assertSame(3, $matrix->getVersion()->getVersionNumber());
 
 		// attempt to read
 		$options->imageBase64                 = false;

+ 24 - 24
tests/Data/QRMatrixTest.php

@@ -101,7 +101,7 @@ final class QRMatrixTest extends TestCase{
 	protected function dm(QRMatrix $matrix):void{
 
 		// limit
-		if($matrix->version()->getVersionNumber() !== 7){
+		if($matrix->getVersion()->getVersionNumber() !== 7){
 			return;
 		}
 
@@ -119,21 +119,21 @@ final class QRMatrixTest extends TestCase{
 	 * Tests if size() returns the actual matrix size/count
 	 */
 	public function testSize():void{
-		$this::assertCount($this->matrix->size(), $this->matrix->matrix());
+		$this::assertCount($this->matrix->getSize(), $this->matrix->getMatrix());
 	}
 
 	/**
 	 * Tests if version() returns the current (given) version
 	 */
 	public function testVersion():void{
-		$this::assertSame($this::version, $this->matrix->version()->getVersionNumber());
+		$this::assertSame($this::version, $this->matrix->getVersion()->getVersionNumber());
 	}
 
 	/**
 	 * Tests if eccLevel() returns the current (given) ECC level
 	 */
 	public function testECC():void{
-		$this::assertSame(EccLevel::L, $this->matrix->eccLevel()->getLevel());
+		$this::assertSame(EccLevel::L, $this->matrix->getEccLevel()->getLevel());
 	}
 
 	/**
@@ -143,8 +143,8 @@ final class QRMatrixTest extends TestCase{
 		// set via matrix evaluation
 		$matrix = (new QRCode)->addByteSegment('testdata')->getMatrix();
 
-		$this::assertInstanceOf(MaskPattern::class, $matrix->maskPattern());
-		$this::assertSame(MaskPattern::PATTERN_100, $matrix->maskPattern()->getPattern());
+		$this::assertInstanceOf(MaskPattern::class, $matrix->getMaskPattern());
+		$this::assertSame(MaskPattern::PATTERN_100, $matrix->getMaskPattern()->getPattern());
 	}
 
 	/**
@@ -193,7 +193,7 @@ final class QRMatrixTest extends TestCase{
 
 		$this->dm($matrix);
 
-		$this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get(8, ($matrix->size() - 8)));
+		$this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get(8, ($matrix->getSize() - 8)));
 	}
 
 	/**
@@ -207,8 +207,8 @@ final class QRMatrixTest extends TestCase{
 		$this->dm($matrix);
 
 		$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(0, 0));
-		$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(0, ($matrix->size() - 1)));
-		$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(($matrix->size() - 1), 0));
+		$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(0, ($matrix->getSize() - 1)));
+		$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(($matrix->getSize() - 1), 0));
 	}
 
 	/**
@@ -223,8 +223,8 @@ final class QRMatrixTest extends TestCase{
 
 		$this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(7, 0));
 		$this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(0, 7));
-		$this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(0, ($matrix->size() - 8)));
-		$this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(($matrix->size() - 8), 0));
+		$this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(0, ($matrix->getSize() - 8)));
+		$this::assertSame(QRMatrix::M_SEPARATOR, $matrix->get(($matrix->getSize() - 8), 0));
 	}
 
 	/**
@@ -233,7 +233,7 @@ final class QRMatrixTest extends TestCase{
 	 * @dataProvider matrixProvider
 	 */
 	public function testSetAlignmentPattern(QRMatrix $matrix):void{
-		$version = $matrix->version();
+		$version = $matrix->getVersion();
 
 		if($version->getVersionNumber() === 1){
 			$this::markTestSkipped('N/A (Version 1 has no alignment pattern)');
@@ -274,7 +274,7 @@ final class QRMatrixTest extends TestCase{
 
 		$this->dm($matrix);
 
-		$size = $matrix->size();
+		$size = $matrix->getSize();
 
 		for($i = 7; $i < ($size - 7); $i++){
 			if(($i % 2) === 0){
@@ -295,7 +295,7 @@ final class QRMatrixTest extends TestCase{
 	 */
 	public function testSetVersionNumber(QRMatrix $matrix):void{
 
-		if($matrix->version()->getVersionNumber() < 7){
+		if($matrix->getVersion()->getVersionNumber() < 7){
 			$this::markTestSkipped('N/A (Version < 7)');
 		}
 
@@ -303,10 +303,10 @@ final class QRMatrixTest extends TestCase{
 
 		$this->dm($matrix);
 
-		$this::assertTrue($matrix->checkType(($matrix->size() - 9), 0, QRMatrix::M_VERSION));
-		$this::assertTrue($matrix->checkType(($matrix->size() - 11), 5, QRMatrix::M_VERSION));
-		$this::assertTrue($matrix->checkType(0, ($matrix->size() - 9), QRMatrix::M_VERSION));
-		$this::assertTrue($matrix->checkType(5, ($matrix->size() - 11), QRMatrix::M_VERSION));
+		$this::assertTrue($matrix->checkType(($matrix->getSize() - 9), 0, QRMatrix::M_VERSION));
+		$this::assertTrue($matrix->checkType(($matrix->getSize() - 11), 5, QRMatrix::M_VERSION));
+		$this::assertTrue($matrix->checkType(0, ($matrix->getSize() - 9), QRMatrix::M_VERSION));
+		$this::assertTrue($matrix->checkType(5, ($matrix->getSize() - 11), QRMatrix::M_VERSION));
 	}
 
 	/**
@@ -321,8 +321,8 @@ final class QRMatrixTest extends TestCase{
 
 		$this::assertTrue($matrix->checkType(8, 0, QRMatrix::M_FORMAT));
 		$this::assertTrue($matrix->checkType(0, 8, QRMatrix::M_FORMAT));
-		$this::assertTrue($matrix->checkType(($matrix->size() - 1), 8, QRMatrix::M_FORMAT));
-		$this::assertTrue($matrix->checkType(($matrix->size() - 8), 8, QRMatrix::M_FORMAT));
+		$this::assertTrue($matrix->checkType(($matrix->getSize() - 1), 8, QRMatrix::M_FORMAT));
+		$this::assertTrue($matrix->checkType(($matrix->getSize() - 8), 8, QRMatrix::M_FORMAT));
 	}
 
 	/**
@@ -331,7 +331,7 @@ final class QRMatrixTest extends TestCase{
 	 * @dataProvider matrixProvider
 	 */
 	public function testSetQuietZone(QRMatrix $matrix):void{
-		$size          = $matrix->size();
+		$size          = $matrix->getSize();
 		$quietZoneSize = 5;
 
 		$matrix->set(0, 0, true, QRMatrix::M_TEST);
@@ -341,10 +341,10 @@ final class QRMatrixTest extends TestCase{
 
 		$s = ($size + 2 * $quietZoneSize);
 
-		$this::assertCount($s, $matrix->matrix());
-		$this::assertCount($s, $matrix->matrix()[($size - 1)]);
+		$this::assertCount($s, $matrix->getMatrix());
+		$this::assertCount($s, $matrix->getMatrix()[($size - 1)]);
 
-		$size = $matrix->size();
+		$size = $matrix->getSize();
 
 		$this->dm($matrix);