From 9e484d0c3f0020ed9741cabe0eb86d1ee05e528d Mon Sep 17 00:00:00 2001 From: smiley Date: Fri, 24 Nov 2023 00:16:25 +0100 Subject: [PATCH] :octocat: added QRMatrix::M* constants for dark values, removed M_TEST --- examples/fpdf.php | 32 +++++++------- examples/html.php | 32 +++++++------- examples/image.php | 34 +++++++-------- examples/imagick.php | 32 +++++++------- examples/qrcode-interactive.php | 32 +++++++------- examples/svg.php | 34 +++++++-------- src/Data/QRMatrix.php | 73 ++++++++++++++++++++++++-------- src/Output/QROutputInterface.php | 43 ++++++++++--------- tests/Data/QRMatrixTest.php | 44 +++++++++---------- tests/Output/QRFpdfTest.php | 7 +-- tests/Output/QRImageTest.php | 5 ++- tests/Output/QRImagickTest.php | 5 ++- tests/Output/QRMarkupTest.php | 5 ++- tests/Output/QRStringTest.php | 5 ++- 14 files changed, 215 insertions(+), 168 deletions(-) diff --git a/examples/fpdf.php b/examples/fpdf.php index aab286e2d..8b6efaa56 100644 --- a/examples/fpdf.php +++ b/examples/fpdf.php @@ -18,30 +18,30 @@ $options = new QROptions([ 'imageBase64' => false, 'moduleValues' => [ // finder - (QRMatrix::M_FINDER << 8) => [0, 63, 255], // dark (true) - (QRMatrix::M_FINDER_DOT << 8) => [0, 63, 255], - QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default + QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true) + QRMatrix::M_FINDER_DOT => [0, 63, 255], + QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default // alignment - (QRMatrix::M_ALIGNMENT << 8) => [255, 0, 255], - QRMatrix::M_ALIGNMENT => [255, 255, 255], + QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255], + QRMatrix::M_ALIGNMENT => [255, 255, 255], // timing - (QRMatrix::M_TIMING << 8) => [255, 0, 0], - QRMatrix::M_TIMING => [255, 255, 255], + QRMatrix::M_TIMING_DARK => [255, 0, 0], + QRMatrix::M_TIMING => [255, 255, 255], // format - (QRMatrix::M_FORMAT << 8) => [67, 191, 84], - QRMatrix::M_FORMAT => [255, 255, 255], + QRMatrix::M_FORMAT_DARK => [67, 191, 84], + QRMatrix::M_FORMAT => [255, 255, 255], // version - (QRMatrix::M_VERSION << 8) => [62, 174, 190], - QRMatrix::M_VERSION => [255, 255, 255], + QRMatrix::M_VERSION_DARK => [62, 174, 190], + QRMatrix::M_VERSION => [255, 255, 255], // data - (QRMatrix::M_DATA << 8) => [0, 0, 0], - QRMatrix::M_DATA => [255, 255, 255], + QRMatrix::M_DATA_DARK => [0, 0, 0], + QRMatrix::M_DATA => [255, 255, 255], // darkmodule - (QRMatrix::M_DARKMODULE << 8) => [0, 0, 0], + QRMatrix::M_DARKMODULE => [0, 0, 0], // separator - QRMatrix::M_SEPARATOR => [255, 255, 255], + QRMatrix::M_SEPARATOR => [255, 255, 255], // quietzone - QRMatrix::M_QUIETZONE => [255, 255, 255], + QRMatrix::M_QUIETZONE => [255, 255, 255], ], ]); diff --git a/examples/html.php b/examples/html.php index 46cadd641..796b2892f 100644 --- a/examples/html.php +++ b/examples/html.php @@ -18,30 +18,30 @@ $options = new QROptions([ 'eccLevel' => QRCode::ECC_L, 'moduleValues' => [ // finder - (QRMatrix::M_FINDER << 8) => '#A71111', // dark (true) - (QRMatrix::M_FINDER_DOT << 8) => '#A71111', - QRMatrix::M_FINDER => '#FFBFBF', // light (false) + QRMatrix::M_FINDER_DARK => '#A71111', // dark (true) + QRMatrix::M_FINDER_DOT => '#A71111', + QRMatrix::M_FINDER => '#FFBFBF', // light (false) // alignment - (QRMatrix::M_ALIGNMENT << 8) => '#A70364', - QRMatrix::M_ALIGNMENT => '#FFC9C9', + QRMatrix::M_ALIGNMENT_DARK => '#A70364', + QRMatrix::M_ALIGNMENT => '#FFC9C9', // timing - (QRMatrix::M_TIMING << 8) => '#98005D', - QRMatrix::M_TIMING => '#FFB8E9', + QRMatrix::M_TIMING_DARK => '#98005D', + QRMatrix::M_TIMING => '#FFB8E9', // format - (QRMatrix::M_FORMAT << 8) => '#003804', - QRMatrix::M_FORMAT => '#00FB12', + QRMatrix::M_FORMAT_DARK => '#003804', + QRMatrix::M_FORMAT => '#00FB12', // version - (QRMatrix::M_VERSION << 8) => '#650098', - QRMatrix::M_VERSION => '#E0B8FF', + QRMatrix::M_VERSION_DARK => '#650098', + QRMatrix::M_VERSION => '#E0B8FF', // data - (QRMatrix::M_DATA << 8) => '#4A6000', - QRMatrix::M_DATA => '#ECF9BE', + QRMatrix::M_DATA_DARK => '#4A6000', + QRMatrix::M_DATA => '#ECF9BE', // darkmodule - (QRMatrix::M_DARKMODULE << 8) => '#080063', + QRMatrix::M_DARKMODULE => '#080063', // separator - QRMatrix::M_SEPARATOR => '#AFBFBF', + QRMatrix::M_SEPARATOR => '#AFBFBF', // quietzone - QRMatrix::M_QUIETZONE => '#FFFFFF', + QRMatrix::M_QUIETZONE => '#FFFFFF', ], ]); diff --git a/examples/image.php b/examples/image.php index 7bd5c2f84..1e4890574 100644 --- a/examples/image.php +++ b/examples/image.php @@ -19,32 +19,32 @@ $options = new QROptions([ 'imageBase64' => false, 'moduleValues' => [ // finder - (QRMatrix::M_FINDER << 8) => [0, 63, 255], // dark (true) - (QRMatrix::M_FINDER_DOT << 8) => [241, 28, 163], // finder dot, dark (true) - QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default + QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true) + QRMatrix::M_FINDER_DOT => [241, 28, 163], // finder dot, dark (true) + QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default // alignment - (QRMatrix::M_ALIGNMENT << 8) => [255, 0, 255], - QRMatrix::M_ALIGNMENT => [255, 255, 255], + QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255], + QRMatrix::M_ALIGNMENT => [255, 255, 255], // timing - (QRMatrix::M_TIMING << 8) => [255, 0, 0], - QRMatrix::M_TIMING => [255, 255, 255], + QRMatrix::M_TIMING_DARK => [255, 0, 0], + QRMatrix::M_TIMING => [255, 255, 255], // format - (QRMatrix::M_FORMAT << 8) => [67, 99, 84], - QRMatrix::M_FORMAT => [255, 255, 255], + QRMatrix::M_FORMAT_DARK => [67, 99, 84], + QRMatrix::M_FORMAT => [255, 255, 255], // version - (QRMatrix::M_VERSION << 8) => [62, 174, 190], - QRMatrix::M_VERSION => [255, 255, 255], + QRMatrix::M_VERSION_DARK => [62, 174, 190], + QRMatrix::M_VERSION => [255, 255, 255], // data - (QRMatrix::M_DATA << 8) => [0, 0, 0], - QRMatrix::M_DATA => [255, 255, 255], + QRMatrix::M_DATA_DARK => [0, 0, 0], + QRMatrix::M_DATA => [255, 255, 255], // darkmodule - (QRMatrix::M_DARKMODULE << 8) => [0, 0, 0], + QRMatrix::M_DARKMODULE => [0, 0, 0], // separator - QRMatrix::M_SEPARATOR => [255, 255, 255], + QRMatrix::M_SEPARATOR => [255, 255, 255], // quietzone - QRMatrix::M_QUIETZONE => [255, 255, 255], + QRMatrix::M_QUIETZONE => [255, 255, 255], // logo (requires a call to QRMatrix::setLogoSpace()) - QRMatrix::M_LOGO => [255, 255, 255], + QRMatrix::M_LOGO => [255, 255, 255], ], ]); diff --git a/examples/imagick.php b/examples/imagick.php index 6329b8e4a..ce8aaaee4 100644 --- a/examples/imagick.php +++ b/examples/imagick.php @@ -18,30 +18,30 @@ $options = new QROptions([ 'scale' => 5, 'moduleValues' => [ // finder - (QRMatrix::M_FINDER << 8) => '#A71111', // dark (true) - (QRMatrix::M_FINDER_DOT << 8) => '#A71111', - QRMatrix::M_FINDER => '#FFBFBF', // light (false) + QRMatrix::M_FINDER_DARK => '#A71111', // dark (true) + QRMatrix::M_FINDER_DOT => '#A71111', + QRMatrix::M_FINDER => '#FFBFBF', // light (false) // alignment - (QRMatrix::M_ALIGNMENT << 8) => '#A70364', - QRMatrix::M_ALIGNMENT => '#FFC9C9', + QRMatrix::M_ALIGNMENT_DARK => '#A70364', + QRMatrix::M_ALIGNMENT => '#FFC9C9', // timing - (QRMatrix::M_TIMING << 8) => '#98005D', - QRMatrix::M_TIMING => '#FFB8E9', + QRMatrix::M_TIMING_DARK => '#98005D', + QRMatrix::M_TIMING => '#FFB8E9', // format - (QRMatrix::M_FORMAT << 8) => '#003804', - QRMatrix::M_FORMAT => '#00FB12', + QRMatrix::M_FORMAT_DARK => '#003804', + QRMatrix::M_FORMAT => '#00FB12', // version - (QRMatrix::M_VERSION << 8) => '#650098', - QRMatrix::M_VERSION => '#E0B8FF', + QRMatrix::M_VERSION_DARK => '#650098', + QRMatrix::M_VERSION => '#E0B8FF', // data - (QRMatrix::M_DATA << 8) => '#4A6000', - QRMatrix::M_DATA => '#ECF9BE', + QRMatrix::M_DATA_DARK => '#4A6000', + QRMatrix::M_DATA => '#ECF9BE', // darkmodule - (QRMatrix::M_DARKMODULE << 8) => '#080063', + QRMatrix::M_DARKMODULE => '#080063', // separator - QRMatrix::M_SEPARATOR => '#DDDDDD', + QRMatrix::M_SEPARATOR => '#DDDDDD', // quietzone - QRMatrix::M_QUIETZONE => '#DDDDDD', + QRMatrix::M_QUIETZONE => '#DDDDDD', ], ]); diff --git a/examples/qrcode-interactive.php b/examples/qrcode-interactive.php index 68e074359..9df15d13c 100644 --- a/examples/qrcode-interactive.php +++ b/examples/qrcode-interactive.php @@ -17,30 +17,30 @@ try{ $moduleValues = [ // finder - (QRMatrix::M_FINDER << 8) => $_POST['m_finder_dark'], - (QRMatrix::M_FINDER_DOT << 8) => $_POST['m_finder_dark'], - QRMatrix::M_FINDER => $_POST['m_finder_light'], + QRMatrix::M_FINDER_DARK => $_POST['m_finder_dark'], + QRMatrix::M_FINDER_DOT => $_POST['m_finder_dark'], + QRMatrix::M_FINDER => $_POST['m_finder_light'], // alignment - (QRMatrix::M_ALIGNMENT << 8) => $_POST['m_alignment_dark'], - QRMatrix::M_ALIGNMENT => $_POST['m_alignment_light'], + QRMatrix::M_ALIGNMENT_DARK => $_POST['m_alignment_dark'], + QRMatrix::M_ALIGNMENT => $_POST['m_alignment_light'], // timing - (QRMatrix::M_TIMING << 8) => $_POST['m_timing_dark'], - QRMatrix::M_TIMING => $_POST['m_timing_light'], + QRMatrix::M_TIMING_DARK => $_POST['m_timing_dark'], + QRMatrix::M_TIMING => $_POST['m_timing_light'], // format - (QRMatrix::M_FORMAT << 8) => $_POST['m_format_dark'], - QRMatrix::M_FORMAT => $_POST['m_format_light'], + QRMatrix::M_FORMAT_DARK => $_POST['m_format_dark'], + QRMatrix::M_FORMAT => $_POST['m_format_light'], // version - (QRMatrix::M_VERSION << 8) => $_POST['m_version_dark'], - QRMatrix::M_VERSION => $_POST['m_version_light'], + QRMatrix::M_VERSION_DARK => $_POST['m_version_dark'], + QRMatrix::M_VERSION => $_POST['m_version_light'], // data - (QRMatrix::M_DATA << 8) => $_POST['m_data_dark'], - QRMatrix::M_DATA => $_POST['m_data_light'], + QRMatrix::M_DATA_DARK => $_POST['m_data_dark'], + QRMatrix::M_DATA => $_POST['m_data_light'], // darkmodule - (QRMatrix::M_DARKMODULE << 8) => $_POST['m_darkmodule_dark'], + QRMatrix::M_DARKMODULE => $_POST['m_darkmodule_dark'], // separator - QRMatrix::M_SEPARATOR => $_POST['m_separator_light'], + QRMatrix::M_SEPARATOR => $_POST['m_separator_light'], // quietzone - QRMatrix::M_QUIETZONE => $_POST['m_quietzone_light'], + QRMatrix::M_QUIETZONE => $_POST['m_quietzone_light'], ]; $moduleValues = array_map(function($v){ diff --git a/examples/svg.php b/examples/svg.php index 4e9880109..956057a39 100644 --- a/examples/svg.php +++ b/examples/svg.php @@ -20,7 +20,7 @@ $options = new QROptions([ 'outputType' => QRCode::OUTPUT_MARKUP_SVG, 'imageBase64' => false, 'eccLevel' => QRCode::ECC_L, - 'svgViewBoxSize' => 530, +# 'svgViewBoxSize' => 530, 'addQuietzone' => true, 'svgOpacity' => 1.0, 'svgDefs' => ' @@ -35,30 +35,30 @@ $options = new QROptions([ ', 'moduleValues' => [ // finder - (QRMatrix::M_FINDER << 8) => 'url(#g1)', // dark (true) - (QRMatrix::M_FINDER_DOT << 8) => 'url(#g1)', - QRMatrix::M_FINDER => '#fff', // light (false) + QRMatrix::M_FINDER_DARK => 'url(#g1)', // dark (true) + QRMatrix::M_FINDER_DOT => 'url(#g1)', + QRMatrix::M_FINDER => '#fff', // light (false) // alignment - (QRMatrix::M_ALIGNMENT << 8) => 'url(#g1)', - QRMatrix::M_ALIGNMENT => '#fff', + QRMatrix::M_ALIGNMENT_DARK => 'url(#g1)', + QRMatrix::M_ALIGNMENT => '#fff', // timing - (QRMatrix::M_TIMING << 8) => 'url(#g1)', - QRMatrix::M_TIMING => '#fff', + QRMatrix::M_TIMING_DARK => 'url(#g1)', + QRMatrix::M_TIMING => '#fff', // format - (QRMatrix::M_FORMAT << 8) => 'url(#g1)', - QRMatrix::M_FORMAT => '#fff', + QRMatrix::M_FORMAT_DARK => 'url(#g1)', + QRMatrix::M_FORMAT => '#fff', // version - (QRMatrix::M_VERSION << 8) => 'url(#g1)', - QRMatrix::M_VERSION => '#fff', + QRMatrix::M_VERSION_DARK => 'url(#g1)', + QRMatrix::M_VERSION => '#fff', // data - (QRMatrix::M_DATA << 8) => 'url(#g2)', - QRMatrix::M_DATA => '#fff', + QRMatrix::M_DATA_DARK => 'url(#g2)', + QRMatrix::M_DATA => '#fff', // darkmodule - (QRMatrix::M_DARKMODULE << 8) => 'url(#g1)', + QRMatrix::M_DARKMODULE => 'url(#g1)', // separator - QRMatrix::M_SEPARATOR => '#fff', + QRMatrix::M_SEPARATOR => '#fff', // quietzone - QRMatrix::M_QUIETZONE => '#fff', + QRMatrix::M_QUIETZONE => '#fff', ], ]); diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php index ffd1f306a..9212a609f 100755 --- a/src/Data/QRMatrix.php +++ b/src/Data/QRMatrix.php @@ -25,32 +25,71 @@ use function array_fill, array_key_exists, array_push, array_unshift, count, flo */ final class QRMatrix{ + /* + * special values + */ + /** @var int */ - public const M_NULL = 0x00; + public const M_NULL = 0x00; /** @var int */ - public const M_DARKMODULE = 0x02; + public const M_LOGO = 0x14; /** @var int */ - public const M_DATA = 0x04; + public const M_LOGO_DARK = self::M_LOGO << 8; + + /* + * light values + */ + /** @var int */ - public const M_FINDER = 0x06; + public const M_DATA = 0x04; /** @var int */ - public const M_SEPARATOR = 0x08; + public const M_FINDER = 0x06; /** @var int */ - public const M_ALIGNMENT = 0x0a; + public const M_SEPARATOR = 0x08; /** @var int */ - public const M_TIMING = 0x0c; + public const M_ALIGNMENT = 0x0a; /** @var int */ - public const M_FORMAT = 0x0e; + public const M_TIMING = 0x0c; /** @var int */ - public const M_VERSION = 0x10; + public const M_FORMAT = 0x0e; /** @var int */ - public const M_QUIETZONE = 0x12; + public const M_VERSION = 0x10; /** @var int */ - public const M_LOGO = 0x14; + public const M_QUIETZONE = 0x12; + + /* + * dark values + */ + /** @var int */ - public const M_FINDER_DOT = 0x16; + public const M_DARKMODULE = self::M_DARKMODULE_LIGHT << 8; /** @var int */ - public const M_TEST = 0xff; + public const M_DATA_DARK = self::M_DATA << 8; + /** @var int */ + public const M_FINDER_DARK = self::M_FINDER << 8; + /** @var int */ + public const M_ALIGNMENT_DARK = self::M_ALIGNMENT << 8; + /** @var int */ + public const M_TIMING_DARK = self::M_TIMING << 8; + /** @var int */ + public const M_FORMAT_DARK = self::M_FORMAT << 8; + /** @var int */ + public const M_VERSION_DARK = self::M_VERSION << 8; + /** @var int */ + public const M_FINDER_DOT = self::M_FINDER_DOT_LIGHT << 8; + + /* + * values used for reversed reflectance + */ + + /** @var int */ + public const M_DARKMODULE_LIGHT = 0x02; + /** @var int */ + public const M_FINDER_DOT_LIGHT = 0x16; + /** @var int */ + public const M_SEPARATOR_DARK = self::M_SEPARATOR << 8; + /** @var int */ + public const M_QUIETZONE_DARK = self::M_QUIETZONE << 8; /** * ISO/IEC 18004:2000 Annex E, Table E.1 - Row/column coordinates of center module of Alignment Patterns @@ -350,7 +389,7 @@ final class QRMatrix{ * Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder */ public function setDarkModule():QRMatrix{ - $this->set(8, 4 * $this->version + 9, true, $this::M_DARKMODULE); + $this->set(8, 4 * $this->version + 9, true, $this::M_DARKMODULE_LIGHT); return $this; } @@ -364,8 +403,8 @@ final class QRMatrix{ $pos = [ [0, 0], // top left - [$this->moduleCount - 7, 0], // bottom left - [0, $this->moduleCount - 7], // top right + [$this->moduleCount - 7, 0], // top right + [0, $this->moduleCount - 7], // bottom left ]; foreach($pos as $c){ @@ -381,7 +420,7 @@ final class QRMatrix{ } // 3*3 dot else{ - $this->set($c[0] + $y, $c[1] + $x, true, $this::M_FINDER_DOT); + $this->set($c[0] + $y, $c[1] + $x, true, $this::M_FINDER_DOT_LIGHT); } } } diff --git a/src/Output/QROutputInterface.php b/src/Output/QROutputInterface.php index 82eea2ac3..b492c27a1 100644 --- a/src/Output/QROutputInterface.php +++ b/src/Output/QROutputInterface.php @@ -21,27 +21,30 @@ interface QROutputInterface{ public const DEFAULT_MODULE_VALUES = [ // light - QRMatrix::M_NULL => false, // 0 - QRMatrix::M_DATA => false, // 4 - QRMatrix::M_FINDER => false, // 6 - QRMatrix::M_SEPARATOR => false, // 8 - QRMatrix::M_ALIGNMENT => false, // 10 - QRMatrix::M_TIMING => false, // 12 - QRMatrix::M_FORMAT => false, // 14 - QRMatrix::M_VERSION => false, // 16 - QRMatrix::M_QUIETZONE => false, // 18 - QRMatrix::M_LOGO => false, // 20 - QRMatrix::M_TEST => false, // 255 + QRMatrix::M_NULL => false, + QRMatrix::M_DARKMODULE_LIGHT => false, + QRMatrix::M_DATA => false, + QRMatrix::M_FINDER => false, + QRMatrix::M_SEPARATOR => false, + QRMatrix::M_ALIGNMENT => false, + QRMatrix::M_TIMING => false, + QRMatrix::M_FORMAT => false, + QRMatrix::M_VERSION => false, + QRMatrix::M_QUIETZONE => false, + QRMatrix::M_LOGO => false, + QRMatrix::M_FINDER_DOT_LIGHT => false, // dark - QRMatrix::M_DARKMODULE << 8 => true, // 512 - QRMatrix::M_DATA << 8 => true, // 1024 - QRMatrix::M_FINDER << 8 => true, // 1536 - QRMatrix::M_ALIGNMENT << 8 => true, // 2560 - QRMatrix::M_TIMING << 8 => true, // 3072 - QRMatrix::M_FORMAT << 8 => true, // 3584 - QRMatrix::M_VERSION << 8 => true, // 4096 - QRMatrix::M_FINDER_DOT << 8 => true, // 5632 - QRMatrix::M_TEST << 8 => true, // 65280 + QRMatrix::M_DARKMODULE => true, + QRMatrix::M_DATA_DARK => true, + QRMatrix::M_FINDER_DARK => true, + QRMatrix::M_SEPARATOR_DARK => true, + QRMatrix::M_ALIGNMENT_DARK => true, + QRMatrix::M_TIMING_DARK => true, + QRMatrix::M_FORMAT_DARK => true, + QRMatrix::M_VERSION_DARK => true, + QRMatrix::M_QUIETZONE_DARK => true, + QRMatrix::M_LOGO_DARK => true, + QRMatrix::M_FINDER_DOT => true, ]; /** diff --git a/tests/Data/QRMatrixTest.php b/tests/Data/QRMatrixTest.php index 68b31a5de..991c2666f 100755 --- a/tests/Data/QRMatrixTest.php +++ b/tests/Data/QRMatrixTest.php @@ -107,12 +107,12 @@ final class QRMatrixTest extends TestCase{ * Tests the set(), get() and check() methods */ public function testGetSetCheck():void{ - $this->matrix->set(10, 10, true, QRMatrix::M_TEST); - $this::assertSame(65280, $this->matrix->get(10, 10)); + $this->matrix->set(10, 10, true, QRMatrix::M_DATA); + $this::assertSame(QRMatrix::M_DATA_DARK, $this->matrix->get(10, 10)); $this::assertTrue($this->matrix->check(10, 10)); - $this->matrix->set(20, 20, false, QRMatrix::M_TEST); - $this::assertSame(255, $this->matrix->get(20, 20)); + $this->matrix->set(20, 20, false, QRMatrix::M_DATA); + $this::assertSame(QRMatrix::M_DATA, $this->matrix->get(20, 20)); $this::assertFalse($this->matrix->check(20, 20)); } @@ -140,7 +140,7 @@ final class QRMatrixTest extends TestCase{ public function testSetDarkModule(int $version):void{ $matrix = $this->getMatrix($version)->setDarkModule(); - $this::assertSame(QRMatrix::M_DARKMODULE << 8, $matrix->get(8, $matrix->size() - 8)); + $this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get(8, $matrix->size() - 8)); } /** @@ -151,9 +151,9 @@ final class QRMatrixTest extends TestCase{ public function testSetFinderPattern(int $version):void{ $matrix = $this->getMatrix($version)->setFinderPattern(); - $this::assertSame(QRMatrix::M_FINDER << 8, $matrix->get(0, 0)); - $this::assertSame(QRMatrix::M_FINDER << 8, $matrix->get(0, $matrix->size() - 1)); - $this::assertSame(QRMatrix::M_FINDER << 8, $matrix->get($matrix->size() - 1, 0)); + $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)); } /** @@ -195,12 +195,12 @@ final class QRMatrixTest extends TestCase{ foreach($alignmentPattern as $py){ foreach($alignmentPattern as $px){ - if($matrix->get($px, $py) === QRMatrix::M_FINDER << 8){ - $this::assertSame(QRMatrix::M_FINDER << 8, $matrix->get($px, $py), 'skipped finder pattern'); + if($matrix->get($px, $py) === QRMatrix::M_FINDER_DARK){ + $this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get($px, $py), 'skipped finder pattern'); continue; } - $this::assertSame(QRMatrix::M_ALIGNMENT << 8, $matrix->get($px, $py)); + $this::assertSame(QRMatrix::M_ALIGNMENT_DARK, $matrix->get($px, $py)); } } @@ -225,13 +225,13 @@ final class QRMatrixTest extends TestCase{ if($i % 2 === 0){ $p1 = $matrix->get(6, $i); - if($p1 === QRMatrix::M_ALIGNMENT << 8){ - $this::assertSame(QRMatrix::M_ALIGNMENT << 8, $p1, 'skipped alignment pattern'); + if($p1 === QRMatrix::M_ALIGNMENT_DARK){ + $this::assertSame(QRMatrix::M_ALIGNMENT_DARK, $p1, 'skipped alignment pattern'); continue; } - $this::assertSame(QRMatrix::M_TIMING << 8, $p1); - $this::assertSame(QRMatrix::M_TIMING << 8, $matrix->get($i, 6)); + $this::assertSame(QRMatrix::M_TIMING_DARK, $p1); + $this::assertSame(QRMatrix::M_TIMING_DARK, $matrix->get($i, 6)); } } } @@ -283,8 +283,8 @@ final class QRMatrixTest extends TestCase{ $size = $matrix->size(); $q = 5; - $matrix->set(0, 0, true, QRMatrix::M_TEST); - $matrix->set($size - 1, $size - 1, true, QRMatrix::M_TEST); + $matrix->set(0, 0, true, QRMatrix::M_DATA); + $matrix->set($size - 1, $size - 1, true, QRMatrix::M_DATA); $matrix->setQuietZone($q); @@ -295,8 +295,8 @@ final class QRMatrixTest extends TestCase{ $this::assertSame(QRMatrix::M_QUIETZONE, $matrix->get(0, 0)); $this::assertSame(QRMatrix::M_QUIETZONE, $matrix->get($size - 1, $size - 1)); - $this::assertSame(QRMatrix::M_TEST << 8, $matrix->get($q, $q)); - $this::assertSame(QRMatrix::M_TEST << 8, $matrix->get($size - 1 - $q, $size - 1 - $q)); + $this::assertSame(QRMatrix::M_DATA_DARK, $matrix->get($q, $q)); + $this::assertSame(QRMatrix::M_DATA_DARK, $matrix->get($size - 1 - $q, $size - 1 - $q)); } /** @@ -340,10 +340,10 @@ final class QRMatrixTest extends TestCase{ // logo space should not overwrite quiet zone & function patterns $m->setLogoSpace(21, 21, -10, -10); $this::assertSame(QRMatrix::M_QUIETZONE, $m->get(9, 9)); - $this::assertSame(QRMatrix::M_FINDER << 8, $m->get(10, 10)); - $this::assertSame(QRMatrix::M_FINDER << 8, $m->get(16, 16)); + $this::assertSame(QRMatrix::M_FINDER_DARK, $m->get(10, 10)); + $this::assertSame(QRMatrix::M_FINDER_DARK, $m->get(16, 16)); $this::assertSame(QRMatrix::M_SEPARATOR, $m->get(17, 17)); - $this::assertSame(QRMatrix::M_FORMAT << 8, $m->get(18, 18)); + $this::assertSame(QRMatrix::M_FORMAT_DARK, $m->get(18, 18)); $this::assertSame(QRMatrix::M_LOGO, $m->get(19, 19)); $this::assertSame(QRMatrix::M_LOGO, $m->get(20, 20)); $this::assertNotSame(QRMatrix::M_LOGO, $m->get(21, 21)); diff --git a/tests/Output/QRFpdfTest.php b/tests/Output/QRFpdfTest.php index a3ab0f5b9..b6b463203 100644 --- a/tests/Output/QRFpdfTest.php +++ b/tests/Output/QRFpdfTest.php @@ -13,8 +13,9 @@ namespace chillerlan\QRCodeTest\Output; use FPDF; -use chillerlan\QRCode\Output\{QRFpdf, QROutputInterface}; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Data\QRMatrix; +use chillerlan\QRCode\Output\{QRFpdf, QROutputInterface}; use function class_exists, substr; @@ -64,8 +65,8 @@ class QRFpdfTest extends QROutputTestAbstract{ $this->options->moduleValues = [ // data - 1024 => [0, 0, 0], - 4 => [255, 255, 255], + QRMatrix::M_DATA_DARK => [0, 0, 0], + QRMatrix::M_DATA => [255, 255, 255], ]; $this->outputInterface = $this->getOutputInterface($this->options); diff --git a/tests/Output/QRImageTest.php b/tests/Output/QRImageTest.php index 4da150b83..8ee3a1337 100644 --- a/tests/Output/QRImageTest.php +++ b/tests/Output/QRImageTest.php @@ -13,6 +13,7 @@ namespace chillerlan\QRCodeTest\Output; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Data\QRMatrix; use chillerlan\QRCode\Output\{QROutputInterface, QRImage}; /** @@ -61,8 +62,8 @@ class QRImageTest extends QROutputTestAbstract{ $this->options->moduleValues = [ // data - 1024 => [0, 0, 0], - 4 => [255, 255, 255], + QRMatrix::M_DATA_DARK => [0, 0, 0], + QRMatrix::M_DATA => [255, 255, 255], ]; $this->outputInterface = $this->getOutputInterface($this->options); diff --git a/tests/Output/QRImagickTest.php b/tests/Output/QRImagickTest.php index aeb5109d5..219f657e4 100644 --- a/tests/Output/QRImagickTest.php +++ b/tests/Output/QRImagickTest.php @@ -17,6 +17,7 @@ namespace chillerlan\QRCodeTest\Output; use Imagick; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Data\QRMatrix; use chillerlan\QRCode\Output\{QROutputInterface, QRImagick}; /** @@ -65,8 +66,8 @@ class QRImagickTest extends QROutputTestAbstract{ $this->options->moduleValues = [ // data - 1024 => '#4A6000', - 4 => '#ECF9BE', + QRMatrix::M_DATA_DARK => '#4A6000', + QRMatrix::M_DATA => '#ECF9BE', ]; $this->outputInterface = $this->getOutputInterface($this->options); diff --git a/tests/Output/QRMarkupTest.php b/tests/Output/QRMarkupTest.php index cc18077d5..1b0793264 100644 --- a/tests/Output/QRMarkupTest.php +++ b/tests/Output/QRMarkupTest.php @@ -13,6 +13,7 @@ namespace chillerlan\QRCodeTest\Output; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Data\QRMatrix; use chillerlan\QRCode\Output\{QROutputInterface, QRMarkup}; /** @@ -46,8 +47,8 @@ class QRMarkupTest extends QROutputTestAbstract{ $this->options->imageBase64 = false; $this->options->moduleValues = [ // data - 1024 => '#4A6000', - 4 => '#ECF9BE', + QRMatrix::M_DATA_DARK => '#4A6000', + QRMatrix::M_DATA => '#ECF9BE', ]; $this->outputInterface = $this->getOutputInterface($this->options); diff --git a/tests/Output/QRStringTest.php b/tests/Output/QRStringTest.php index a9590a34b..2a4d620b9 100644 --- a/tests/Output/QRStringTest.php +++ b/tests/Output/QRStringTest.php @@ -13,6 +13,7 @@ namespace chillerlan\QRCodeTest\Output; use chillerlan\QRCode\{QRCode, QROptions}; +use chillerlan\QRCode\Data\QRMatrix; use chillerlan\QRCode\Output\{QROutputInterface, QRString}; /** @@ -46,8 +47,8 @@ class QRStringTest extends QROutputTestAbstract{ $this->options->moduleValues = [ // data - 1024 => 'A', - 4 => 'B', + QRMatrix::M_DATA_DARK => 'A', + QRMatrix::M_DATA => 'B', ]; $this->outputInterface = $this->getOutputInterface($this->options);