From 1b2aa52d03244237d3a3310df62b1742998ca110 Mon Sep 17 00:00:00 2001 From: smiley Date: Tue, 4 Apr 2023 15:00:55 +0200 Subject: [PATCH] :octocat: proper names for QRMatrix getters --- examples/imageWithLogo.php | 2 +- examples/svgMeltedModules.php | 2 +- examples/svgRandomColoredDots.php | 2 +- examples/svgRoundQuietzone.php | 4 +- src/Common/MaskPattern.php | 2 +- src/Data/QRMatrix.php | 10 ++--- src/Decoder/Decoder.php | 6 +-- src/Detector/AlignmentPatternFinder.php | 2 +- src/Detector/Detector.php | 4 +- src/Detector/FinderPatternFinder.php | 8 ++-- src/Detector/GridSampler.php | 2 +- src/Output/QRFpdf.php | 2 +- src/Output/QRGdImage.php | 2 +- src/Output/QRImagick.php | 2 +- src/Output/QRMarkupHTML.php | 2 +- src/Output/QROutputAbstract.php | 6 +-- src/Output/QRString.php | 4 +- tests/Data/DataInterfaceTestAbstract.php | 2 +- tests/Data/QRDataTest.php | 2 +- tests/Data/QRMatrixTest.php | 48 ++++++++++++------------ 20 files changed, 57 insertions(+), 57 deletions(-) diff --git a/examples/imageWithLogo.php b/examples/imageWithLogo.php index 7287697ed..fc7b49ff9 100644 --- a/examples/imageWithLogo.php +++ b/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); diff --git a/examples/svgMeltedModules.php b/examples/svgMeltedModules.php index ca9b7ae78..55c682bac 100644 --- a/examples/svgMeltedModules.php +++ b/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; diff --git a/examples/svgRandomColoredDots.php b/examples/svgRandomColoredDots.php index 984a46138..8cd423946 100644 --- a/examples/svgRandomColoredDots.php +++ b/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; diff --git a/examples/svgRoundQuietzone.php b/examples/svgRoundQuietzone.php index dd65431fd..0722e411b 100644 --- a/examples/svgRoundQuietzone.php +++ b/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; diff --git a/src/Common/MaskPattern.php b/src/Common/MaskPattern.php index 99b3d809c..c02a5ad0b 100644 --- a/src/Common/MaskPattern.php +++ b/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++){ diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php index 2e93b4469..124f06571 100755 --- a/src/Data/QRMatrix.php +++ b/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; } diff --git a/src/Decoder/Decoder.php b/src/Decoder/Decoder.php index 6ffb9318b..63839da0c 100644 --- a/src/Decoder/Decoder.php +++ b/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 diff --git a/src/Detector/AlignmentPatternFinder.php b/src/Detector/AlignmentPatternFinder.php index 8718aecc5..ca62c6f36 100644 --- a/src/Detector/AlignmentPatternFinder.php +++ b/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; diff --git a/src/Detector/Detector.php b/src/Detector/Detector.php index d2f459d5f..7f73bdc88 100644 --- a/src/Detector/Detector.php +++ b/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)); diff --git a/src/Detector/FinderPatternFinder.php b/src/Detector/FinderPatternFinder.php index 0221db6c6..fadc0d13e 100644 --- a/src/Detector/FinderPatternFinder.php +++ b/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; diff --git a/src/Detector/GridSampler.php b/src/Detector/GridSampler.php index 6352d09b7..bf5b2b31c 100644 --- a/src/Detector/GridSampler.php +++ b/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); diff --git a/src/Output/QRFpdf.php b/src/Output/QRFpdf.php index 1ecabc540..e22a328f2 100644 --- a/src/Output/QRFpdf.php +++ b/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){ diff --git a/src/Output/QRGdImage.php b/src/Output/QRGdImage.php index 0299ceb9f..78a317677 100644 --- a/src/Output/QRGdImage.php +++ b/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); } diff --git a/src/Output/QRImagick.php b/src/Output/QRImagick.php index d8203ce34..cf31e7773 100644 --- a/src/Output/QRImagick.php +++ b/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); } diff --git a/src/Output/QRMarkupHTML.php b/src/Output/QRMarkupHTML.php index b85c09df2..9cb8dce77 100644 --- a/src/Output/QRMarkupHTML.php +++ b/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 .= '
'; foreach($row as $M_TYPE){ diff --git a/src/Output/QROutputAbstract.php b/src/Output/QROutputAbstract.php index c4b55c136..10752ee07 100644 --- a/src/Output/QROutputAbstract.php +++ b/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; diff --git a/src/Output/QRString.php b/src/Output/QRString.php index 58ff88aea..b8c244237 100644 --- a/src/Output/QRString.php +++ b/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()); } } diff --git a/tests/Data/DataInterfaceTestAbstract.php b/tests/Data/DataInterfaceTestAbstract.php index 73dcbe7c5..56d8b8646 100644 --- a/tests/Data/DataInterfaceTestAbstract.php +++ b/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; diff --git a/tests/Data/QRDataTest.php b/tests/Data/QRDataTest.php index 6ec582d86..4f5174aeb 100644 --- a/tests/Data/QRDataTest.php +++ b/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; diff --git a/tests/Data/QRMatrixTest.php b/tests/Data/QRMatrixTest.php index f40c0ad8d..598b733aa 100755 --- a/tests/Data/QRMatrixTest.php +++ b/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);