From 4edc9e492dbc3401ac5a4f304067fe94f0193abc Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 10:01:56 +0000 Subject: [PATCH 001/100] Require PHP 8+ --- .github/workflows/check.yml | 5 +---- .gitignore | 4 +++- Makefile | 2 +- README.md | 6 +++--- VERSION | 2 +- composer.json | 8 ++++---- phpstan.neon | 2 +- resources/debian/control | 4 ++-- resources/rpm/rpm.spec | 6 +++--- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 671cc402..defda120 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -23,13 +23,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] + php-version: ["8.0", "8.1", "8.2"] experimental: [false] os: [ubuntu-latest] coverage-extension: [pcov] - include: - - { php-version: '5.6', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - - { php-version: '7.1', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } steps: - uses: actions/checkout@v4 - name: Use php ${{ matrix.php-version }} diff --git a/.gitignore b/.gitignore index a7fa8a26..4dd7d5e8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,11 +8,13 @@ **/auth.json **/nbproject **/temp.php +**/test.php .phpdoc .phpunit.cache .phpunit.result.cache composer.lock -example/test.php +ecs.php phpunit.xml +rector.php target vendor diff --git a/Makefile b/Makefile index 2417f236..88aa4005 100644 --- a/Makefile +++ b/Makefile @@ -163,7 +163,7 @@ endif deps: ensuretarget rm -rf ./vendor/* ($(COMPOSER) install -vvv --no-interaction) - curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/1.10.38/phpstan.phar \ + curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/1.10.41/phpstan.phar \ && chmod +x ./vendor/phpstan.phar # Generate source code documentation diff --git a/README.md b/README.md index 8cf85961..85eaa2b9 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ All artifacts are generated in the target directory. Examples are located in the `example` directory. -Start a development server (requires at least PHP 5.6) using the command: +Start a development server (requires PHP 8.0+) using the command: ``` make server @@ -147,7 +147,7 @@ Create a composer.json in your projects root-directory: ```json { "require": { - "tecnickcom/tc-lib-barcode": "^1.18" + "tecnickcom/tc-lib-barcode": "^2.0" } } ``` @@ -155,7 +155,7 @@ Create a composer.json in your projects root-directory: Or add to an existing project with: ```bash -composer require tecnickcom/tc-lib-barcode ^1.18 +composer require tecnickcom/tc-lib-barcode ^2.0 ``` ## Packaging diff --git a/VERSION b/VERSION index a67b05e8..f1547e6d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.4 +2.0.7 diff --git a/composer.json b/composer.json index 48b24a7f..49f123a9 100644 --- a/composer.json +++ b/composer.json @@ -53,18 +53,18 @@ } ], "require": { - "php": ">=5.6", + "php": ">=8.0", "ext-bcmath": "*", "ext-date": "*", "ext-gd": "*", "ext-pcre": "*", - "tecnickcom/tc-lib-color": "^1.14" + "tecnickcom/tc-lib-color": "^2.0" }, "require-dev": { "pdepend/pdepend": "2.13.0", "phpmd/phpmd": "2.13.0", - "phpunit/phpunit": "10.1.2 || 9.6.7 || 8.5.31 || 7.5.20 || 6.5.14 || 5.7.27 || 4.8.36", - "squizlabs/php_codesniffer": "3.7.2 || 2.9.2" + "phpunit/phpunit": "10.1.2 || 9.6.13", + "squizlabs/php_codesniffer": "3.7.2" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index c42b3644..bf592cee 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 5 + level: max paths: - src - test diff --git a/resources/debian/control b/resources/debian/control index 356b1db6..05116b78 100644 --- a/resources/debian/control +++ b/resources/debian/control @@ -10,7 +10,7 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git Package: ~#PKGNAME#~ Provides: php-~#PROJECT#~ Architecture: all -Depends: php (>= 5.6.0), php-bcmath, php-date, php-gd, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 1.14.39), ${misc:Depends} +Depends: php (>= 8.0.0), php-bcmath, php-date, php-gd, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 2.0.4), ${misc:Depends} Description: PHP Barcode library This library includes PHP classes to generate linear and bidimensional barcodes: @@ -20,4 +20,4 @@ Description: PHP Barcode library UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, - PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix ECC200, QR-Code, PDF417. + PHARMACODE, PHARMACODE TWO-TRACKS, AZTEC, Datamatrix ECC200, QR-Code, PDF417. diff --git a/resources/rpm/rpm.spec b/resources/rpm/rpm.spec index a116cf3b..9bcb1ca1 100644 --- a/resources/rpm/rpm.spec +++ b/resources/rpm/rpm.spec @@ -16,9 +16,9 @@ URL: https://github.com/%{gh_owner}/%{gh_project} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) BuildArch: noarch -Requires: php(language) >= 5.6.0 +Requires: php(language) >= 8.0.0 Requires: php-composer(%{c_vendor}/tc-lib-color) < 2.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-color) >= 1.14.39 +Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.0.4 Requires: php-bcmath Requires: php-date Requires: php-gd @@ -35,7 +35,7 @@ Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, -PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix ECC200, QR-Code, PDF417. +PHARMACODE, PHARMACODE TWO-TRACKS, AZTEC, Datamatrix ECC200, QR-Code, PDF417. Optional dependency: php-pecl-imagick From 12e24aa6224cc6c630e8fa67939c0b2ad9c7eb80 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 10:11:36 +0000 Subject: [PATCH 002/100] fixes --- src/Barcode.php | 156 +++++++++++------- src/Type.php | 2 +- src/Type/Linear/Codabar.php | 2 +- src/Type/Linear/CodeNineThree.php | 2 +- src/Type/Linear/CodeOneOne.php | 2 +- src/Type/Linear/CodeOneTwoEight.php | 2 +- src/Type/Linear/CodeThreeNineExtCheck.php | 2 +- src/Type/Linear/EanEight.php | 2 +- src/Type/Linear/EanOneThree.php | 2 +- src/Type/Linear/EanTwo.php | 2 +- src/Type/Linear/Imb.php | 2 +- src/Type/Linear/ImbPre.php | 2 +- src/Type/Linear/InterleavedTwoOfFiveCheck.php | 2 +- src/Type/Linear/KlantIndex.php | 2 +- src/Type/Linear/MsiCheck.php | 2 +- src/Type/Linear/Pharma.php | 2 +- src/Type/Linear/PharmaTwoTracks.php | 2 +- src/Type/Linear/Postnet.php | 2 +- src/Type/Linear/RoyalMailFourCc.php | 2 +- src/Type/Linear/StandardTwoOfFiveCheck.php | 2 +- src/Type/Linear/UpcE.php | 2 +- src/Type/Raw.php | 2 +- src/Type/Square/Aztec.php | 2 +- src/Type/Square/Datamatrix.php | 2 +- src/Type/Square/PdfFourOneSeven.php | 2 +- src/Type/Square/QrCode.php | 2 +- test/BarcodeTest.php | 7 - test/TestUtil.php | 56 +++---- 28 files changed, 145 insertions(+), 124 deletions(-) diff --git a/src/Barcode.php b/src/Barcode.php index 0e5278d1..f8b8dc20 100644 --- a/src/Barcode.php +++ b/src/Barcode.php @@ -34,69 +34,61 @@ class Barcode { /** - * Array containing the map between the barcode type and correspondent class + * List of supported Barcode Types with description. + * + * @var array */ - const TYPECLASS = array( - 'C128' => 'Linear\\CodeOneTwoEight', // CODE 128 - 'C128A' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightA', // CODE 128 A - 'C128B' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightB', // CODE 128 B - 'C128C' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightC', // CODE 128 C - 'C39' => 'Linear\\CodeThreeNine', // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. - 'C39+' => 'Linear\\CodeThreeNineCheck', // CODE 39 + CHECKSUM - 'C39E' => 'Linear\\CodeThreeNineExt', // CODE 39 EXTENDED - 'C39E+' => 'Linear\\CodeThreeNineExtCheck', // CODE 39 EXTENDED + CHECKSUM - 'C93' => 'Linear\\CodeNineThree', // CODE 93 - USS-93 - 'CODABAR' => 'Linear\\Codabar', // CODABAR - 'CODE11' => 'Linear\\CodeOneOne', // CODE 11 - 'EAN13' => 'Linear\\EanOneThree', // EAN 13 - 'EAN2' => 'Linear\\EanTwo', // EAN 2-Digits UPC-Based Extension - 'EAN5' => 'Linear\\EanFive', // EAN 5-Digits UPC-Based Extension - 'EAN8' => 'Linear\\EanEight', // EAN 8 - 'I25' => 'Linear\\InterleavedTwoOfFive', // Interleaved 2 of 5 - 'I25+' => 'Linear\\InterleavedTwoOfFiveCheck', // Interleaved 2 of 5 + CHECKSUM - 'IMB' => 'Linear\\Imb', // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 - 'IMBPRE' => 'Linear\\ImbPre', // IMB - Intelligent Mail Barcode pre-processed - 'KIX' => 'Linear\\KlantIndex', // KIX (Klant index - Customer index) - 'LRAW' => 'Linear\\Raw', // 1D RAW MODE (comma-separated rows of 01 strings) - 'MSI' => 'Linear\\Msi', // MSI (Variation of Plessey code) - 'MSI+' => 'Linear\\MsiCheck', // MSI + CHECKSUM (modulo 11) - 'PHARMA' => 'Linear\\Pharma', // PHARMACODE - 'PHARMA2T' => 'Linear\\PharmaTwoTracks', // PHARMACODE TWO-TRACKS - 'PLANET' => 'Linear\\Planet', // PLANET - 'POSTNET' => 'Linear\\Postnet', // POSTNET - 'RMS4CC' => 'Linear\\RoyalMailFourCc', // RMS4CC (Royal Mail 4-state Customer Bar Code) - 'S25' => 'Linear\\StandardTwoOfFive', // Standard 2 of 5 - 'S25+' => 'Linear\\StandardTwoOfFiveCheck', // Standard 2 of 5 + CHECKSUM - 'UPCA' => 'Linear\\UpcA', // UPC-A - 'UPCE' => 'Linear\\UpcE', // UPC-E - 'AZTEC' => 'Square\\Aztec', // AZTEC Code (ISO/IEC 24778:2008) - 'DATAMATRIX' => 'Square\\Datamatrix', // DATAMATRIX (ISO/IEC 16022) - 'PDF417' => 'Square\\PdfFourOneSeven', // PDF417 (ISO/IEC 15438:2006) - 'QRCODE' => 'Square\\QrCode', // QR-CODE - 'SRAW' => 'Square\\Raw', // 2D RAW MODE (comma-separated rows of 01 strings) + public const BARCODETYPES = array( + 'C128' => 'CODE 128', + 'C128A' => 'CODE 128 A', + 'C128B' => 'CODE 128 B', + 'C128C' => 'CODE 128 C', + 'C39' => 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.', + 'C39+' => 'CODE 39 + CHECKSUM', + 'C39E' => 'CODE 39 EXTENDED', + 'C39E+' => 'CODE 39 EXTENDED + CHECKSUM', + 'C93' => 'CODE 93 - USS-93', + 'CODABAR' => 'CODABAR', + 'CODE11' => 'CODE 11', + 'EAN13' => 'EAN 13', + 'EAN2' => 'EAN 2-Digits UPC-Based Extension', + 'EAN5' => 'EAN 5-Digits UPC-Based Extension', + 'EAN8' => 'EAN 8', + 'I25' => 'Interleaved 2 of 5', + 'I25+' => 'Interleaved 2 of 5 + CHECKSUM', + 'IMB' => 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200', + 'IMBPRE' => 'IMB - Intelligent Mail Barcode pre-processed', + 'KIX' => 'KIX (Klant index - Customer index)', + 'LRAW' => '1D RAW MODE (comma-separated rows of 01 strings)', + 'MSI' => 'MSI (Variation of Plessey code)', + 'MSI+' => 'MSI + CHECKSUM (modulo 11)', + 'PHARMA' => 'PHARMACODE', + 'PHARMA2T' => 'PHARMACODE TWO-TRACKS', + 'PLANET' => 'PLANET', + 'POSTNET' => 'POSTNET', + 'RMS4CC' => 'RMS4CC (Royal Mail 4-state Customer Bar Code)', + 'S25' => 'Standard 2 of 5', + 'S25+' => 'Standard 2 of 5 + CHECKSUM', + 'UPCA' => 'UPC-A', + 'UPCE' => 'UPC-E', + 'AZTEC' => 'AZTEC Code (ISO/IEC 24778:2008)', + 'DATAMATRIX' => 'DATAMATRIX (ISO/IEC 16022)', + 'PDF417' => 'PDF417 (ISO/IEC 15438:2006)', + 'QRCODE' => 'QR-CODE', + 'SRAW' => '2D RAW MODE (comma-separated rows of 01 strings)', ); - /** - * Get the list of supported Barcode types - * - * @return array - */ - public function getTypes() - { - return array_keys(self::TYPECLASS); - } - /** * Get the barcode object * * @param string $type Barcode type - * @param string $code Barcode content + * @param string|array $code Barcode content * @param int $width Barcode width in user units (excluding padding). * A negative value indicates the multiplication factor for each column. * @param int $height Barcode height in user units (excluding padding). * A negative value indicates the multiplication factor for each row. * @param string $color Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax) - * @param array $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. + * @param array{int, int, int, int} $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. * A negative value indicates the multiplication factor for each row or column. * * @return Type @@ -104,21 +96,59 @@ public function getTypes() * @throws BarcodeException in case of error */ public function getBarcodeObj( - $type, - $code, - $width = -1, - $height = -1, - $color = 'black', - $padding = array(0, 0, 0, 0) - ) { + string $type, + string|array $code, + int $width = -1, + int $height = -1, + string $color = 'black', + array $padding = array(0, 0, 0, 0) + ): Type { // extract extra parameters (if any) $params = explode(',', $type); $type = array_shift($params); - if (!array_key_exists($type, self::TYPECLASS)) { - throw new BarcodeException('Unsupported barcode type: ' . $type); - } - $bclass = '\\Com\\Tecnick\\Barcode\\Type\\' . self::TYPECLASS[$type]; - return new $bclass($code, $width, $height, $color, $params, $padding); + $bclass = match($type) { + 'C128' => 'Linear\\CodeOneTwoEight', // CODE 128 + 'C128A' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightA', // CODE 128 A + 'C128B' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightB', // CODE 128 B + 'C128C' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightC', // CODE 128 C + 'C39' => 'Linear\\CodeThreeNine', // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. + 'C39+' => 'Linear\\CodeThreeNineCheck', // CODE 39 + CHECKSUM + 'C39E' => 'Linear\\CodeThreeNineExt', // CODE 39 EXTENDED + 'C39E+' => 'Linear\\CodeThreeNineExtCheck', // CODE 39 EXTENDED + CHECKSUM + 'C93' => 'Linear\\CodeNineThree', // CODE 93 - USS-93 + 'CODABAR' => 'Linear\\Codabar', // CODABAR + 'CODE11' => 'Linear\\CodeOneOne', // CODE 11 + 'EAN13' => 'Linear\\EanOneThree', // EAN 13 + 'EAN2' => 'Linear\\EanTwo', // EAN 2-Digits UPC-Based Extension + 'EAN5' => 'Linear\\EanFive', // EAN 5-Digits UPC-Based Extension + 'EAN8' => 'Linear\\EanEight', // EAN 8 + 'I25' => 'Linear\\InterleavedTwoOfFive', // Interleaved 2 of 5 + 'I25+' => 'Linear\\InterleavedTwoOfFiveCheck', // Interleaved 2 of 5 + CHECKSUM + 'IMB' => 'Linear\\Imb', // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 + 'IMBPRE' => 'Linear\\ImbPre', // IMB - Intelligent Mail Barcode pre-processed + 'KIX' => 'Linear\\KlantIndex', // KIX (Klant index - Customer index) + 'LRAW' => 'Linear\\Raw', // 1D RAW MODE (comma-separated rows of 01 strings) + 'MSI' => 'Linear\\Msi', // MSI (Variation of Plessey code) + 'MSI+' => 'Linear\\MsiCheck', // MSI + CHECKSUM (modulo 11) + 'PHARMA' => 'Linear\\Pharma', // PHARMACODE + 'PHARMA2T' => 'Linear\\PharmaTwoTracks', // PHARMACODE TWO-TRACKS + 'PLANET' => 'Linear\\Planet', // PLANET + 'POSTNET' => 'Linear\\Postnet', // POSTNET + 'RMS4CC' => 'Linear\\RoyalMailFourCc', // RMS4CC (Royal Mail 4-state Customer Bar Code) + 'S25' => 'Linear\\StandardTwoOfFive', // Standard 2 of 5 + 'S25+' => 'Linear\\StandardTwoOfFiveCheck', // Standard 2 of 5 + CHECKSUM + 'UPCA' => 'Linear\\UpcA', // UPC-A + 'UPCE' => 'Linear\\UpcE', // UPC-E + 'AZTEC' => 'Square\\Aztec', // AZTEC Code (ISO/IEC 24778:2008) + 'DATAMATRIX' => 'Square\\Datamatrix', // DATAMATRIX (ISO/IEC 16022) + 'PDF417' => 'Square\\PdfFourOneSeven', // PDF417 (ISO/IEC 15438:2006) + 'QRCODE' => 'Square\\QrCode', // QR-CODE + 'SRAW' => 'Square\\Raw', // 2D RAW MODE (comma-separated rows of 01 strings) + default => throw new BarcodeException('Unsupported barcode type: ' . $type) + }; + + $class = '\\Com\\Tecnick\\Barcode\\Type\\' . $bclass; + return new $class($code, $width, $height, $color, $params, $padding); } } diff --git a/src/Type.php b/src/Type.php index 83f007e9..258f72a7 100644 --- a/src/Type.php +++ b/src/Type.php @@ -79,7 +79,7 @@ protected function setParameters() * * @throws BarcodeException in case of error */ - abstract protected function setBars(); + abstract protected function setBars(): void; /** * Set the size of the barcode to be exported diff --git a/src/Type/Linear/Codabar.php b/src/Type/Linear/Codabar.php index 1f767098..2afd62a7 100644 --- a/src/Type/Linear/Codabar.php +++ b/src/Type/Linear/Codabar.php @@ -81,7 +81,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->ncols = 0; $this->nrows = 1; diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index 5c3a49e7..b47c2f2c 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -215,7 +215,7 @@ protected function getChecksum($code) * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - protected function setBars() + protected function setBars(): void { $this->extcodes = array( chr(131) . 'U', diff --git a/src/Type/Linear/CodeOneOne.php b/src/Type/Linear/CodeOneOne.php index c53c1ec7..de95ba00 100644 --- a/src/Type/Linear/CodeOneOne.php +++ b/src/Type/Linear/CodeOneOne.php @@ -128,7 +128,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->ncols = 0; $this->nrows = 1; diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index dbcd35fe..58e9fb7d 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -217,7 +217,7 @@ protected function processSequenceC(&$sequence, &$code_data, &$startid, $key, $s * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->setAsciiMaps(); $code_data = $this->getCodeData(); diff --git a/src/Type/Linear/CodeThreeNineExtCheck.php b/src/Type/Linear/CodeThreeNineExtCheck.php index f6a9ffbb..4000a1a5 100644 --- a/src/Type/Linear/CodeThreeNineExtCheck.php +++ b/src/Type/Linear/CodeThreeNineExtCheck.php @@ -201,7 +201,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->ncols = 0; $this->nrows = 1; diff --git a/src/Type/Linear/EanEight.php b/src/Type/Linear/EanEight.php index 11f74cdd..86492983 100644 --- a/src/Type/Linear/EanEight.php +++ b/src/Type/Linear/EanEight.php @@ -53,7 +53,7 @@ class EanEight extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->formatCode(); $seq = '101'; // left guard bar diff --git a/src/Type/Linear/EanOneThree.php b/src/Type/Linear/EanOneThree.php index 3835a3ba..3d0b3279 100644 --- a/src/Type/Linear/EanOneThree.php +++ b/src/Type/Linear/EanOneThree.php @@ -172,7 +172,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { if (!is_numeric($this->code)) { throw new BarcodeException('Input code must be a number'); diff --git a/src/Type/Linear/EanTwo.php b/src/Type/Linear/EanTwo.php index a0a43f3e..3b3a0d05 100644 --- a/src/Type/Linear/EanTwo.php +++ b/src/Type/Linear/EanTwo.php @@ -117,7 +117,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->formatCode(); $chk = $this->getChecksum($this->extcode); diff --git a/src/Type/Linear/Imb.php b/src/Type/Linear/Imb.php index ee77386c..58246a94 100644 --- a/src/Type/Linear/Imb.php +++ b/src/Type/Linear/Imb.php @@ -308,7 +308,7 @@ protected function getCharsArray() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $chars = $this->getCharsArray(); for ($pos = 0; $pos < 65; ++$pos) { diff --git a/src/Type/Linear/ImbPre.php b/src/Type/Linear/ImbPre.php index c20080d3..40536f57 100644 --- a/src/Type/Linear/ImbPre.php +++ b/src/Type/Linear/ImbPre.php @@ -46,7 +46,7 @@ class ImbPre extends \Com\Tecnick\Barcode\Type\Linear * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $code = strtolower($this->code); if (preg_match('/^[fadt]{65}$/', $code) != 1) { diff --git a/src/Type/Linear/InterleavedTwoOfFiveCheck.php b/src/Type/Linear/InterleavedTwoOfFiveCheck.php index 9d6512e5..85c36035 100644 --- a/src/Type/Linear/InterleavedTwoOfFiveCheck.php +++ b/src/Type/Linear/InterleavedTwoOfFiveCheck.php @@ -74,7 +74,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->formatCode(); if ((strlen($this->extcode) % 2) != 0) { diff --git a/src/Type/Linear/KlantIndex.php b/src/Type/Linear/KlantIndex.php index ff459d03..46e2165e 100644 --- a/src/Type/Linear/KlantIndex.php +++ b/src/Type/Linear/KlantIndex.php @@ -54,7 +54,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->ncols = 0; $this->nrows = 3; diff --git a/src/Type/Linear/MsiCheck.php b/src/Type/Linear/MsiCheck.php index 8308d881..445dfc07 100644 --- a/src/Type/Linear/MsiCheck.php +++ b/src/Type/Linear/MsiCheck.php @@ -108,7 +108,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->formatCode(); $seq = '110'; // left guard diff --git a/src/Type/Linear/Pharma.php b/src/Type/Linear/Pharma.php index e36efeb5..790e5d88 100644 --- a/src/Type/Linear/Pharma.php +++ b/src/Type/Linear/Pharma.php @@ -46,7 +46,7 @@ class Pharma extends \Com\Tecnick\Barcode\Type\Linear * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $seq = ''; $code = intval($this->code); diff --git a/src/Type/Linear/PharmaTwoTracks.php b/src/Type/Linear/PharmaTwoTracks.php index 590892d3..0e3e2e00 100644 --- a/src/Type/Linear/PharmaTwoTracks.php +++ b/src/Type/Linear/PharmaTwoTracks.php @@ -46,7 +46,7 @@ class PharmaTwoTracks extends \Com\Tecnick\Barcode\Type\Linear * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $seq = ''; $code = intval($this->code); diff --git a/src/Type/Linear/Postnet.php b/src/Type/Linear/Postnet.php index f9d549aa..cd39a6f8 100644 --- a/src/Type/Linear/Postnet.php +++ b/src/Type/Linear/Postnet.php @@ -94,7 +94,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->ncols = 0; $this->nrows = 2; diff --git a/src/Type/Linear/RoyalMailFourCc.php b/src/Type/Linear/RoyalMailFourCc.php index defea9ee..0550d2e5 100644 --- a/src/Type/Linear/RoyalMailFourCc.php +++ b/src/Type/Linear/RoyalMailFourCc.php @@ -202,7 +202,7 @@ protected function getCoreBars() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->ncols = 0; $this->nrows = 3; diff --git a/src/Type/Linear/StandardTwoOfFiveCheck.php b/src/Type/Linear/StandardTwoOfFiveCheck.php index 5da7bed9..50d5746a 100644 --- a/src/Type/Linear/StandardTwoOfFiveCheck.php +++ b/src/Type/Linear/StandardTwoOfFiveCheck.php @@ -97,7 +97,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->formatCode(); if ((strlen($this->extcode) % 2) != 0) { diff --git a/src/Type/Linear/UpcE.php b/src/Type/Linear/UpcE.php index 07db23ed..6c179595 100644 --- a/src/Type/Linear/UpcE.php +++ b/src/Type/Linear/UpcE.php @@ -153,7 +153,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->formatCode(); $upce_code = $this->convertUpcaToUpce($this->extcode); diff --git a/src/Type/Raw.php b/src/Type/Raw.php index fbc35c83..98899667 100644 --- a/src/Type/Raw.php +++ b/src/Type/Raw.php @@ -59,7 +59,7 @@ protected function getCodeRows() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $rows = $this->getCodeRows(); if (empty($rows)) { diff --git a/src/Type/Square/Aztec.php b/src/Type/Square/Aztec.php index 97bfc987..329a483b 100644 --- a/src/Type/Square/Aztec.php +++ b/src/Type/Square/Aztec.php @@ -118,7 +118,7 @@ protected function setParameters() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { if (strlen((string)$this->code) == 0) { throw new BarcodeException('Empty input'); diff --git a/src/Type/Square/Datamatrix.php b/src/Type/Square/Datamatrix.php index 7fc8897e..ca0e99a2 100644 --- a/src/Type/Square/Datamatrix.php +++ b/src/Type/Square/Datamatrix.php @@ -265,7 +265,7 @@ protected function getHighLevelEncoding($data) * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { $this->dmx = new Encode($this->shape); $params = $this->getCodewords(); diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index 2749ed93..d34b95d5 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -146,7 +146,7 @@ protected function setMacroBlockParam() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { if (strlen((string)$this->code) == 0) { throw new BarcodeException('Empty input'); diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 60b08175..6aaec301 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -169,7 +169,7 @@ protected function setParameters() * * @throws BarcodeException in case of error */ - protected function setBars() + protected function setBars(): void { if (strlen((string)$this->code) == 0) { throw new BarcodeException('Empty input'); diff --git a/test/BarcodeTest.php b/test/BarcodeTest.php index c35fa967..6124573f 100644 --- a/test/BarcodeTest.php +++ b/test/BarcodeTest.php @@ -36,13 +36,6 @@ protected function getTestObject() return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetTypes() - { - $testObj = $this->getTestObject(); - $types = $testObj->getTypes(); - $this->assertEquals(37, count($types)); - } - public function testGetBarcodeObjException() { $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); diff --git a/test/TestUtil.php b/test/TestUtil.php index be1560c6..d54cc5b5 100644 --- a/test/TestUtil.php +++ b/test/TestUtil.php @@ -3,13 +3,13 @@ /** * TestUtil.php * - * @since 2020-12-19 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2020-12-19 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode * * This file is part of tc-lib-color software library. */ @@ -21,33 +21,31 @@ /** * Web Color class test * - * @since 2020-12-19 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2020-12-19 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode */ class TestUtil extends TestCase { - public function bcAssertEqualsWithDelta($expected, $actual, $delta = 0.01, $message = '') - { - if (\is_callable([self::class, 'assertEqualsWithDelta'])) { - parent::assertEqualsWithDelta($expected, $actual, $delta, $message); - return; - } - /* @phpstan-ignore-next-line */ - $this->assertEquals($expected, $actual, $message, $delta); + public function bcAssertEqualsWithDelta( + mixed $expected, + mixed $actual, + float $delta = 0.01, + string $message = '' + ): void { + parent::assertEqualsWithDelta($expected, $actual, $delta, $message); } - public function bcExpectException($exception) + /** + * @param class-string<\Throwable> $exception + */ + public function bcExpectException($exception): void { - if (\is_callable([self::class, 'expectException'])) { - parent::expectException($exception); - return; - } - /* @phpstan-ignore-next-line */ - parent::setExpectedException($exception); + parent::expectException($exception); } + } From 257cb2b301229cd7c95146e6c8e03cfaf5a54fd1 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 10:21:09 +0000 Subject: [PATCH 003/100] fixes --- src/Type.php | 2 +- src/Type/Square/Aztec.php | 2 +- src/Type/Square/Datamatrix.php | 2 +- src/Type/Square/PdfFourOneSeven.php | 2 +- src/Type/Square/QrCode.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Type.php b/src/Type.php index 258f72a7..4e543bf7 100644 --- a/src/Type.php +++ b/src/Type.php @@ -70,7 +70,7 @@ public function __construct( /** * Set extra (optional) parameters */ - protected function setParameters() + protected function setParameters(): void { } diff --git a/src/Type/Square/Aztec.php b/src/Type/Square/Aztec.php index 329a483b..8e343a51 100644 --- a/src/Type/Square/Aztec.php +++ b/src/Type/Square/Aztec.php @@ -84,7 +84,7 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square * 3: LAYERS : Custom number of layers (0 = auto). * 4: ECI : Extended Channel Interpretation (ECI) code. Use -1 for FNC1. See $this->eci. */ - protected function setParameters() + protected function setParameters(): void { parent::setParameters(); diff --git a/src/Type/Square/Datamatrix.php b/src/Type/Square/Datamatrix.php index ca0e99a2..fddfe116 100644 --- a/src/Type/Square/Datamatrix.php +++ b/src/Type/Square/Datamatrix.php @@ -83,7 +83,7 @@ class Datamatrix extends \Com\Tecnick\Barcode\Type\Square * 1: SHAPE - S=square (default), R=rectangular * 2: MODE - N=default, GS1 = the FNC1 codeword is added in the first position of Data Matrix ECC 200 version */ - protected function setParameters() + protected function setParameters(): void { parent::setParameters(); diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index d34b95d5..29a93c2d 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -100,7 +100,7 @@ class PdfFourOneSeven extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\C /** * Set extra (optional) parameters */ - protected function setParameters() + protected function setParameters(): void { parent::setParameters(); diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 6aaec301..e807f63f 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -118,7 +118,7 @@ class QrCode extends \Com\Tecnick\Barcode\Type\Square * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - protected function setParameters() + protected function setParameters(): void { parent::setParameters(); From 98eff3fc57961ed842dc7f63d28adca9d64455ec Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 10:25:38 +0000 Subject: [PATCH 004/100] fixes --- src/Type.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Type.php b/src/Type.php index 4e543bf7..1253dbaf 100644 --- a/src/Type.php +++ b/src/Type.php @@ -16,6 +16,8 @@ namespace Com\Tecnick\Barcode; +use Com\Tecnick\Color\Pdf; +use Com\Tecnick\Color\Model\Rgb; use Com\Tecnick\Color\Exception as ColorException; use Com\Tecnick\Barcode\Exception as BarcodeException; @@ -37,7 +39,7 @@ abstract class Type extends \Com\Tecnick\Barcode\Type\Convert /** * Initialize a new barcode object * - * @param string $code Barcode content + * @param string|array $code Barcode content * @param int $width Barcode width in user units (excluding padding). * A negative value indicates the multiplication factor for each column. * @param int $height Barcode height in user units (excluding padding). @@ -88,10 +90,14 @@ abstract protected function setBars(): void; * A negative value indicates the multiplication factor for each column. * @param int $height Barcode height in user units (excluding padding). * A negative value indicates the multiplication factor for each row. - * @param array $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. + * @param array{int, int, int, int} $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. * A negative value indicates the number or rows or columns. */ - public function setSize($width, $height, $padding = array(0, 0, 0, 0)) + public function setSize( + $width, + $height, + $padding = array(0, 0, 0, 0) + ): static { $this->width = intval($width); if ($this->width <= 0) { @@ -119,7 +125,7 @@ public function setSize($width, $height, $padding = array(0, 0, 0, 0)) * * @throws BarcodeException in case of error */ - protected function setPadding($padding) + protected function setPadding(array $padding): static { if (!is_array($padding) || (count($padding) != 4)) { throw new BarcodeException('Invalid padding, expecting an array of 4 numbers (top, right, bottom, left)'); @@ -150,7 +156,7 @@ protected function setPadding($padding) * @throws ColorException in case of color error * @throws BarcodeException in case of empty or transparent color */ - public function setColor($color) + public function setColor(string $color): static { $this->color_obj = $this->getRgbColorObject($color); if ($this->color_obj === null) { @@ -166,7 +172,7 @@ public function setColor($color) * * @throws ColorException in case of color error */ - public function setBackgroundColor($color) + public function setBackgroundColor(string $color): static { $this->bg_color_obj = $this->getRgbColorObject($color); return $this; @@ -181,12 +187,12 @@ public function setBackgroundColor($color) * * @throws ColorException in case of color error */ - protected function getRgbColorObject($color) + protected function getRgbColorObject(string $color): ?Rgb { - $conv = new \Com\Tecnick\Color\Pdf(); + $conv = new Pdf(); $cobj = $conv->getColorObject($color); if ($cobj !== null) { - return new \Com\Tecnick\Color\Model\Rgb($cobj->toRgbArray()); + return new Rgb($cobj->toRgbArray()); } return null; } From 58e4b68f6a64ebb96bd2a0863ab7a70c5e66d109 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 10:28:46 +0000 Subject: [PATCH 005/100] fixes --- src/Type.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Type.php b/src/Type.php index 1253dbaf..e7de6066 100644 --- a/src/Type.php +++ b/src/Type.php @@ -202,7 +202,7 @@ protected function getRgbColorObject(string $color): ?Rgb * * @return array */ - public function getArray() + public function getArray(): array { return array( 'type' => $this->type, @@ -230,7 +230,7 @@ public function getArray() * * @return string */ - public function getExtendedCode() + public function getExtendedCode(): string { return $this->extcode; } @@ -238,7 +238,7 @@ public function getExtendedCode() /** * Get the barcode as SVG image object */ - public function getSvg() + public function getSvg(): void { $data = $this->getSvgCode(); header('Content-Type: application/svg+xml'); @@ -259,7 +259,7 @@ public function getSvg() * * @return string SVG code */ - public function getSvgCode() + public function getSvgCode(): string { // flags for htmlspecialchars $hflag = ENT_NOQUOTES; @@ -317,7 +317,7 @@ public function getSvgCode() * * @return string HTML code (DIV block) */ - public function getHtmlDiv() + public function getHtmlDiv(): string { $html = '
?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_' @@ -56,7 +56,7 @@ protected function setAsciiMaps() * * @throws BarcodeException in case of error */ - protected function getCodeData() + protected function getCodeData(): array { $code = $this->code; // array of symbols @@ -79,11 +79,17 @@ protected function getCodeData() * @param array $code_data Array of codepoints to alter * @param int $startid Start ID * @param int $key Sequence current key - * @param string $seq Sequence current value + * @param array $seq Sequence current value * * @throws BarcodeException in case of error */ - protected function processSequenceA(&$sequence, &$code_data, &$startid, $key, $seq) + protected function processSequenceA( + array &$sequence, + array &$code_data, + int &$startid, + int $key, + array $seq + ): void { if ($key == 0) { $startid = 103; From 5edaf52ba95574dab6b75d4fc7f77e48b95c31d2 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 12:06:06 +0000 Subject: [PATCH 020/100] fixes --- src/Type/Linear/CodeOneTwoEight.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index b6160cfd..2d0cc35c 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -118,7 +118,7 @@ protected function processSequenceA( * @param array $code_data Array of codepoints to alter * @param int $startid Start ID * @param int $key Sequence current key - * @param string $seq Sequence current value + * @param array $seq Sequence current value * * @throws BarcodeException in case of error */ @@ -139,7 +139,7 @@ protected function processSequenceB(&$sequence, &$code_data, &$startid, $key, $s * @param array $code_data Array of codepoints to alter * @param int $startid Start ID * @param int $key Sequence current key - * @param string $seq Sequence current value + * @param array $seq Sequence current value * * @throws BarcodeException in case of error */ @@ -176,7 +176,7 @@ protected function processSequenceBA(&$sequence, &$code_data, &$startid, $key, $ * @param array $sequence Sequence to process * @param array $code_data Array of codepoints to alter * @param int $key Sequence current key - * @param string $seq Sequence current value + * @param array $seq Sequence current value * * @throws BarcodeException in case of error */ @@ -204,7 +204,7 @@ protected function processSequenceBB(&$sequence, &$code_data, $key, $seq) * @param array $code_data Array of codepoints to alter * @param int $startid Start ID * @param int $key Sequence current key - * @param string $seq Sequence current value + * @param array $seq Sequence current value * * @throws BarcodeException in case of error */ From 09fe41fa4527287bedeabd289cdd7b077c453927 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 12:07:40 +0000 Subject: [PATCH 021/100] fixes --- src/Type/Linear/CodeOneTwoEight.php | 31 +++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index 2d0cc35c..d8a2ea28 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -122,7 +122,13 @@ protected function processSequenceA( * * @throws BarcodeException in case of error */ - protected function processSequenceB(&$sequence, &$code_data, &$startid, $key, $seq) + protected function processSequenceB( + array &$sequence, + array &$code_data, + int &$startid, + int $key, + array $seq + ): void { if ($key == 0) { $this->processSequenceBA($sequence, $code_data, $startid, $key, $seq); @@ -143,7 +149,13 @@ protected function processSequenceB(&$sequence, &$code_data, &$startid, $key, $s * * @throws BarcodeException in case of error */ - protected function processSequenceBA(&$sequence, &$code_data, &$startid, $key, $seq) + protected function processSequenceBA( + array &$sequence, + array &$code_data, + int &$startid, + int $key, + array $seq + ): void { $tmpchr = ord($seq[1][0]); if ( @@ -180,7 +192,12 @@ protected function processSequenceBA(&$sequence, &$code_data, &$startid, $key, $ * * @throws BarcodeException in case of error */ - protected function processSequenceBB(&$sequence, &$code_data, $key, $seq) + protected function processSequenceBB( + array &$sequence, + array &$code_data, + int $key, + array $seq + ): void { if ( ($seq[2] == 1) @@ -208,7 +225,13 @@ protected function processSequenceBB(&$sequence, &$code_data, $key, $seq) * * @throws BarcodeException in case of error */ - protected function processSequenceC(&$sequence, &$code_data, &$startid, $key, $seq) + protected function processSequenceC( + array &$sequence, + array &$code_data, + int &$startid, + int $key, + array $seq + ): void { if ($key == 0) { $startid = 105; From 90dfb88577e92e529348f372010a1785dff54979 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 12:12:15 +0000 Subject: [PATCH 022/100] fixes --- src/Type/Linear/EanEight.php | 2 +- src/Type/Linear/EanFive.php | 8 ++++---- src/Type/Linear/EanOneThree.php | 16 ++++++++-------- src/Type/Linear/EanTwo.php | 14 +++++++------- src/Type/Linear/UpcA.php | 4 ++-- src/Type/Linear/UpcE.php | 12 ++++++------ 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Type/Linear/EanEight.php b/src/Type/Linear/EanEight.php index 6d2b10d0..3e21f804 100644 --- a/src/Type/Linear/EanEight.php +++ b/src/Type/Linear/EanEight.php @@ -46,7 +46,7 @@ class EanEight extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree * * @var int */ - protected $code_length = 8; + protected int $code_length = 8; /** * Set the bars array. diff --git a/src/Type/Linear/EanFive.php b/src/Type/Linear/EanFive.php index 69f6cce8..91fae29d 100644 --- a/src/Type/Linear/EanFive.php +++ b/src/Type/Linear/EanFive.php @@ -46,14 +46,14 @@ class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo * * @var int */ - protected $code_length = 5; + protected int $code_length = 5; /** * Map parities * - * @var array + * @var array> */ - protected $parities = array( + protected array $parities = array( '0' => array('B','B','A','A','A'), '1' => array('B','A','B','A','A'), '2' => array('B','A','A','B','A'), @@ -73,7 +73,7 @@ class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo * * @return int char checksum. */ - protected function getChecksum($code) + protected function getChecksum(string $code): int { return (((3 * (intval($code[0]) + intval($code[2]) + intval($code[4]))) + (9 * (intval($code[1]) + intval($code[3])))) % 10); diff --git a/src/Type/Linear/EanOneThree.php b/src/Type/Linear/EanOneThree.php index daf9252e..f6750830 100644 --- a/src/Type/Linear/EanOneThree.php +++ b/src/Type/Linear/EanOneThree.php @@ -46,21 +46,21 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear * * @var int */ - protected $code_length = 13; + protected int $code_length = 13; /** * Check digit * * @var int */ - protected $check = 0; + protected int $check = 0; /** * Map characters to barcodes * - * @var array + * @var array> */ - protected $chbar = array( + protected array $chbar = array( 'A' => array( // left odd parity '0' => '0001101', '1' => '0011001', @@ -102,9 +102,9 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear /** * Map parities * - * @var array + * @var array */ - protected $parities = array( + protected array $parities = array( '0' => 'AAAAAA', '1' => 'AABABB', '2' => 'AABBAB', @@ -126,7 +126,7 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear * * @throws BarcodeException in case of error */ - protected function getChecksum($code) + protected function getChecksum(string $code): int { $data_len = ($this->code_length - 1); $code_len = strlen($code); @@ -161,7 +161,7 @@ protected function getChecksum($code) /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $code = str_pad($this->code, ($this->code_length - 1), '0', STR_PAD_LEFT); $this->extcode = $code . $this->getChecksum($code); diff --git a/src/Type/Linear/EanTwo.php b/src/Type/Linear/EanTwo.php index 8ed3bc3e..80456b58 100644 --- a/src/Type/Linear/EanTwo.php +++ b/src/Type/Linear/EanTwo.php @@ -46,14 +46,14 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear * * @var int */ - protected $code_length = 2; + protected int $code_length = 2; /** * Map characters to barcodes * - * @var array + * @var array> */ - protected $chbar = array( + protected array $chbar = array( 'A' => array( // left odd parity '0' => '0001101', '1' => '0011001', @@ -83,9 +83,9 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear /** * Map parities * - * @var array + * @var array> */ - protected $parities = array( + protected array $parities = array( '0' => array('A','A'), '1' => array('A','B'), '2' => array('B','A'), @@ -99,7 +99,7 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear * * @return int char checksum. */ - protected function getChecksum($code) + protected function getChecksum(string $code): int { return (intval($code) % 4); } @@ -107,7 +107,7 @@ protected function getChecksum($code) /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $this->extcode = str_pad($this->code, $this->code_length, '0', STR_PAD_LEFT); } diff --git a/src/Type/Linear/UpcA.php b/src/Type/Linear/UpcA.php index 43ffe41f..165c8c56 100644 --- a/src/Type/Linear/UpcA.php +++ b/src/Type/Linear/UpcA.php @@ -46,12 +46,12 @@ class UpcA extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree * * @var int */ - protected $code_length = 12; + protected int $code_length = 12; /** * Format the code */ - protected function formatCode() + protected function formatCode(): void { $code = str_pad($this->code, ($this->code_length - 1), '0', STR_PAD_LEFT); $code .= $this->getChecksum($code); diff --git a/src/Type/Linear/UpcE.php b/src/Type/Linear/UpcE.php index ef7134b3..997d8bf0 100644 --- a/src/Type/Linear/UpcE.php +++ b/src/Type/Linear/UpcE.php @@ -50,14 +50,14 @@ class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA * * @var int */ - protected $code_length = 12; + protected int $code_length = 12; /** * Map parities * - * @var array + * @var array>> */ - protected $parities = array( + protected array $parities = array( 0 => array( '0' => array('B','B','B','A','A','A'), '1' => array('B','B','A','B','A','A'), @@ -91,7 +91,7 @@ class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA * * @return string */ - protected function convertUpceToUpca($code) + protected function convertUpceToUpca(string $code): string { if ($code[5] < 3) { return '0' . $code[0] . $code[1] . $code[5] . '0000' . $code[2] . $code[3] . $code[4]; @@ -112,7 +112,7 @@ protected function convertUpceToUpca($code) * * @return string */ - protected function convertUpcaToUpce($code) + protected function convertUpcaToUpce(string $code): string { $tmp = substr($code, 4, 3); if (($tmp == '000') || ($tmp == '100') || ($tmp == '200')) { @@ -136,7 +136,7 @@ protected function convertUpcaToUpce($code) /** * Format the code */ - protected function formatCode() + protected function formatCode(): void { $code = $this->code; if (strlen($code) == 6) { From eecf07b7e873a90e4aee8633901b04659fdbf243 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:06:27 +0000 Subject: [PATCH 023/100] fixes --- src/Type/Linear/Imb.php | 26 +++++++++---------- src/Type/Linear/InterleavedTwoOfFive.php | 2 +- src/Type/Linear/InterleavedTwoOfFiveCheck.php | 6 ++--- src/Type/Linear/KlantIndex.php | 2 +- src/Type/Linear/StandardTwoOfFive.php | 2 +- src/Type/Linear/StandardTwoOfFiveCheck.php | 8 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Type/Linear/Imb.php b/src/Type/Linear/Imb.php index 142fd738..0d6988af 100644 --- a/src/Type/Linear/Imb.php +++ b/src/Type/Linear/Imb.php @@ -65,9 +65,9 @@ class Imb extends \Com\Tecnick\Barcode\Type\Linear /** * ASC characters * - * @var array + * @var array */ - const ASC_CHR = array( + protected const ASC_CHR = array( 4,0,2,6,3,5,1,9,8,7, 1,2,0,6,4,8,2,9,5,3, 0,1,3,7,4,6,8,9,2,0, @@ -80,9 +80,9 @@ class Imb extends \Com\Tecnick\Barcode\Type\Linear /** * DSC characters * - * @var array + * @var array */ - const DSC_CHR = array( + protected const DSC_CHR = array( 7,1,9,5,8,0,2,4,6,3, 5,8,9,7,3,0,6,1,7,4, 6,8,9,2,5,1,7,5,4,3, @@ -94,18 +94,18 @@ class Imb extends \Com\Tecnick\Barcode\Type\Linear /** * ASC positions * - * @var array + * @var array */ - const ASC_POS = array( + protected const ASC_POS = array( 3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9, 6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2); /** * DSC positions * - * @var array + * @var array */ - const DSC_POS = array( + protected const DSC_POS = array( 2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11, 0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10); @@ -116,7 +116,7 @@ class Imb extends \Com\Tecnick\Barcode\Type\Linear * * @return int reversed value */ - protected function getReversedUnsignedShort($num) + protected function getReversedUnsignedShort(int $num): int { $rev = 0; for ($pos = 0; $pos < 16; ++$pos) { @@ -134,7 +134,7 @@ protected function getReversedUnsignedShort($num) * * @return int 11 bit Frame Check Sequence as integer (decimal base) */ - protected function getFrameCheckSequence($code_arr) + protected function getFrameCheckSequence(array $code_arr): int { $genpoly = 0x0F35; // generator polynomial $fcs = 0x07FF; // Frame Check Sequence @@ -173,7 +173,7 @@ protected function getFrameCheckSequence($code_arr) * * @return array requested table */ - protected function getTables($type, $size) + protected function getTables(int $type, int $size): array { $table = array(); $lli = 0; // LUT lower index @@ -215,7 +215,7 @@ protected function getTables($type, $size) * * @throws BarcodeException in case of error */ - protected function getRoutingCode($routing_code) + protected function getRoutingCode(string $routing_code): string { // Conversion of Routing Code switch (strlen($routing_code)) { @@ -238,7 +238,7 @@ protected function getRoutingCode($routing_code) * * @throws BarcodeException in case of error */ - protected function getCharsArray() + protected function getCharsArray(): array { $this->ncols = 0; $this->nrows = 3; diff --git a/src/Type/Linear/InterleavedTwoOfFive.php b/src/Type/Linear/InterleavedTwoOfFive.php index 6bf41b52..d833839c 100644 --- a/src/Type/Linear/InterleavedTwoOfFive.php +++ b/src/Type/Linear/InterleavedTwoOfFive.php @@ -44,7 +44,7 @@ class InterleavedTwoOfFive extends \Com\Tecnick\Barcode\Type\Linear\InterleavedT /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $this->extcode = $this->code; } diff --git a/src/Type/Linear/InterleavedTwoOfFiveCheck.php b/src/Type/Linear/InterleavedTwoOfFiveCheck.php index 5ffa0500..9cb5f249 100644 --- a/src/Type/Linear/InterleavedTwoOfFiveCheck.php +++ b/src/Type/Linear/InterleavedTwoOfFiveCheck.php @@ -44,9 +44,9 @@ class InterleavedTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear\Standar /** * Map characters to barcodes * - * @var array + * @var array */ - protected $chbar = array( + protected array $chbar = array( '0' => '11221', '1' => '21112', '2' => '12112', @@ -64,7 +64,7 @@ class InterleavedTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear\Standar /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $this->extcode = $this->code . $this->getChecksum($this->code); } diff --git a/src/Type/Linear/KlantIndex.php b/src/Type/Linear/KlantIndex.php index 503a8068..73e095af 100644 --- a/src/Type/Linear/KlantIndex.php +++ b/src/Type/Linear/KlantIndex.php @@ -44,7 +44,7 @@ class KlantIndex extends \Com\Tecnick\Barcode\Type\Linear\RoyalMailFourCc /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $this->extcode = strtoupper($this->code); } diff --git a/src/Type/Linear/StandardTwoOfFive.php b/src/Type/Linear/StandardTwoOfFive.php index 19203b2d..30537702 100644 --- a/src/Type/Linear/StandardTwoOfFive.php +++ b/src/Type/Linear/StandardTwoOfFive.php @@ -44,7 +44,7 @@ class StandardTwoOfFive extends \Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFi /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $this->extcode = $this->code; } diff --git a/src/Type/Linear/StandardTwoOfFiveCheck.php b/src/Type/Linear/StandardTwoOfFiveCheck.php index e6e34ddb..ee73e75d 100644 --- a/src/Type/Linear/StandardTwoOfFiveCheck.php +++ b/src/Type/Linear/StandardTwoOfFiveCheck.php @@ -44,9 +44,9 @@ class StandardTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear /** * Map characters to barcodes * - * @var array + * @var array */ - protected $chbar = array( + protected array $chbar = array( '0' => '10101110111010', '1' => '11101010101110', '2' => '10111010101110', @@ -66,7 +66,7 @@ class StandardTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear * * @return int char checksum. */ - protected function getChecksum($code) + protected function getChecksum(string $code): int { $clen = strlen($code); $sum = 0; @@ -87,7 +87,7 @@ protected function getChecksum($code) /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $this->extcode = $this->code . $this->getChecksum($this->code); } From 128c36b383c6422d53c3476734be42396b14580d Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:09:21 +0000 Subject: [PATCH 024/100] fixes --- src/Type/Linear/Msi.php | 2 +- src/Type/Linear/MsiCheck.php | 8 ++++---- src/Type/Linear/Planet.php | 4 ++-- src/Type/Linear/Postnet.php | 8 ++++---- src/Type/Linear/RoyalMailFourCc.php | 14 +++++++------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Type/Linear/Msi.php b/src/Type/Linear/Msi.php index bd2ee590..4a9ea375 100644 --- a/src/Type/Linear/Msi.php +++ b/src/Type/Linear/Msi.php @@ -44,7 +44,7 @@ class Msi extends \Com\Tecnick\Barcode\Type\Linear\MsiCheck /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $this->extcode = $this->code; } diff --git a/src/Type/Linear/MsiCheck.php b/src/Type/Linear/MsiCheck.php index e5fbfb76..6e96ff5f 100644 --- a/src/Type/Linear/MsiCheck.php +++ b/src/Type/Linear/MsiCheck.php @@ -44,9 +44,9 @@ class MsiCheck extends \Com\Tecnick\Barcode\Type\Linear /** * Map characters to barcodes * - * @var array + * @var array */ - protected $chbar = array( + protected array $chbar = array( '0' => '100100100100', '1' => '100100100110', '2' => '100100110100', @@ -72,7 +72,7 @@ class MsiCheck extends \Com\Tecnick\Barcode\Type\Linear * * @return int char checksum. */ - protected function getChecksum($code) + protected function getChecksum(string $code): int { $clen = strlen($code); $pix = 2; @@ -98,7 +98,7 @@ protected function getChecksum($code) /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $this->extcode = $this->code . $this->getChecksum($this->code); } diff --git a/src/Type/Linear/Planet.php b/src/Type/Linear/Planet.php index ce49a87d..0777f302 100644 --- a/src/Type/Linear/Planet.php +++ b/src/Type/Linear/Planet.php @@ -44,9 +44,9 @@ class Planet extends \Com\Tecnick\Barcode\Type\Linear\Postnet /** * Map characters to barcodes * - * @var array + * @var array */ - protected $chbar = array( + protected array $chbar = array( '0' => '11222', '1' => '22211', '2' => '22121', diff --git a/src/Type/Linear/Postnet.php b/src/Type/Linear/Postnet.php index a7b2dca6..be8a5b33 100644 --- a/src/Type/Linear/Postnet.php +++ b/src/Type/Linear/Postnet.php @@ -44,9 +44,9 @@ class Postnet extends \Com\Tecnick\Barcode\Type\Linear /** * Map characters to barcodes * - * @var array + * @var array */ - protected $chbar = array( + protected array $chbar = array( '0' => '22111', '1' => '11122', '2' => '11212', @@ -66,7 +66,7 @@ class Postnet extends \Com\Tecnick\Barcode\Type\Linear * * @return int char checksum. */ - protected function getChecksum($code) + protected function getChecksum(string $code): int { $sum = 0; $len = strlen($code); @@ -83,7 +83,7 @@ protected function getChecksum($code) /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $code = preg_replace('/[-\s]+/', '', $this->code); $this->extcode = $code . $this->getChecksum($code); diff --git a/src/Type/Linear/RoyalMailFourCc.php b/src/Type/Linear/RoyalMailFourCc.php index b3d8430f..14eeaba7 100644 --- a/src/Type/Linear/RoyalMailFourCc.php +++ b/src/Type/Linear/RoyalMailFourCc.php @@ -44,9 +44,9 @@ class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear /** * Map characters to barcodes * - * @var array + * @var array */ - protected $chbar = array( + protected array $chbar = array( '0' => '3322', '1' => '3412', '2' => '3421', @@ -88,9 +88,9 @@ class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear /** * Characters used for checksum * - * @var array + * @var array */ - protected $chksum = array( + protected array $chksum = array( '0' => '11', '1' => '12', '2' => '13', @@ -138,7 +138,7 @@ class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear * * @throws BarcodeException in case of error */ - protected function getChecksum($code) + protected function getChecksum(string $code): int { $row = 0; $col = 0; @@ -160,7 +160,7 @@ protected function getChecksum($code) /** * Format code */ - protected function formatCode() + protected function formatCode(): void { $code = strtoupper($this->code); $this->extcode = $code . $this->getChecksum($code); @@ -171,7 +171,7 @@ protected function formatCode() * * @throws BarcodeException in case of error */ - protected function getCoreBars() + protected function getCoreBars(): void { $this->formatCode(); $clen = strlen($this->extcode); From 5992c4705a542e27b11413c1d3b993a804c58f35 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:16:11 +0000 Subject: [PATCH 025/100] fixes --- src/Type/Linear/EanEight.php | 4 ++-- src/Type/Linear/EanOneThree.php | 6 +++--- src/Type/Linear/UpcE.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Type/Linear/EanEight.php b/src/Type/Linear/EanEight.php index 3e21f804..135428f2 100644 --- a/src/Type/Linear/EanEight.php +++ b/src/Type/Linear/EanEight.php @@ -59,11 +59,11 @@ protected function setBars(): void $seq = '101'; // left guard bar $half_len = intval(ceil($this->code_length / 2)); for ($pos = 0; $pos < $half_len; ++$pos) { - $seq .= $this->chbar['A'][$this->extcode[$pos]]; + $seq .= self::CHBAR['A'][$this->extcode[$pos]]; } $seq .= '01010'; // center guard bar for ($pos = $half_len; $pos < $this->code_length; ++$pos) { - $seq .= $this->chbar['C'][$this->extcode[$pos]]; + $seq .= self::CHBAR['C'][$this->extcode[$pos]]; } $seq .= '101'; // right guard bar $this->processBinarySequence($seq); diff --git a/src/Type/Linear/EanOneThree.php b/src/Type/Linear/EanOneThree.php index f6750830..1a1e543c 100644 --- a/src/Type/Linear/EanOneThree.php +++ b/src/Type/Linear/EanOneThree.php @@ -60,7 +60,7 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear * * @var array> */ - protected array $chbar = array( + protected const CHBAR = array( 'A' => array( // left odd parity '0' => '0001101', '1' => '0011001', @@ -182,11 +182,11 @@ protected function setBars(): void $half_len = intval(ceil($this->code_length / 2)); $parity = $this->parities[$this->extcode[0]]; for ($pos = 1; $pos < $half_len; ++$pos) { - $seq .= $this->chbar[$parity[($pos - 1)]][$this->extcode[$pos]]; + $seq .= self::CHBAR[$parity[($pos - 1)]][$this->extcode[$pos]]; } $seq .= '01010'; // center guard bar for ($pos = $half_len; $pos < $this->code_length; ++$pos) { - $seq .= $this->chbar['C'][$this->extcode[$pos]]; + $seq .= self::CHBAR['C'][$this->extcode[$pos]]; } $seq .= '101'; // right guard bar $this->processBinarySequence($seq); diff --git a/src/Type/Linear/UpcE.php b/src/Type/Linear/UpcE.php index 997d8bf0..6209042a 100644 --- a/src/Type/Linear/UpcE.php +++ b/src/Type/Linear/UpcE.php @@ -160,7 +160,7 @@ protected function setBars(): void $seq = '101'; // left guard bar $parity = $this->parities[$this->extcode[1]][$this->check]; for ($pos = 0; $pos < 6; ++$pos) { - $seq .= $this->chbar[$parity[$pos]][$upce_code[$pos]]; + $seq .= self::CHBAR[$parity[$pos]][$upce_code[$pos]]; } $seq .= '010101'; // right guard bar $this->processBinarySequence($seq); From 2e52ceb69370626423140ef279739f98c86d5562 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:19:46 +0000 Subject: [PATCH 026/100] fixes --- src/Type/Linear/CodeOneTwoEight.php | 2 +- src/Type/Linear/CodeOneTwoEight/Process.php | 2 +- src/Type/Linear/EanTwo.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index d8a2ea28..e74bbea0 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -254,7 +254,7 @@ protected function setBars(): void $this->nrows = 1; $this->bars = array(); foreach ($code_data as $val) { - $seq = $this->chbar[$val]; + $seq = self::CHBAR[$val]; for ($pos = 0; $pos < 6; ++$pos) { $bar_width = intval($seq[$pos]); if ((($pos % 2) == 0) && ($bar_width > 0)) { diff --git a/src/Type/Linear/CodeOneTwoEight/Process.php b/src/Type/Linear/CodeOneTwoEight/Process.php index 3ca1966a..cf86d6d4 100644 --- a/src/Type/Linear/CodeOneTwoEight/Process.php +++ b/src/Type/Linear/CodeOneTwoEight/Process.php @@ -46,7 +46,7 @@ abstract class Process extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected $chbar = array( + protected const CHBAR = array( '212222', // 00 '222122', // 01 '222221', // 02 diff --git a/src/Type/Linear/EanTwo.php b/src/Type/Linear/EanTwo.php index 80456b58..e102e39d 100644 --- a/src/Type/Linear/EanTwo.php +++ b/src/Type/Linear/EanTwo.php @@ -53,7 +53,7 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear * * @var array> */ - protected array $chbar = array( + protected const CHBAR = array( 'A' => array( // left odd parity '0' => '0001101', '1' => '0011001', @@ -123,11 +123,11 @@ protected function setBars(): void $chk = $this->getChecksum($this->extcode); $parity = $this->parities[$chk]; $seq = '1011'; // left guard bar - $seq .= $this->chbar[$parity[0]][$this->extcode[0]]; + $seq .= self::CHBAR[$parity[0]][$this->extcode[0]]; $len = strlen($this->extcode); for ($pos = 1; $pos < $len; ++$pos) { $seq .= '01'; // separator - $seq .= $this->chbar[$parity[$pos]][$this->extcode[$pos]]; + $seq .= self::CHBAR[$parity[$pos]][$this->extcode[$pos]]; } $this->processBinarySequence($seq); } From dabc4120eecaecc3dcf30a0422ba6c92aa3d4080 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:20:40 +0000 Subject: [PATCH 027/100] fixes --- src/Type/Linear/InterleavedTwoOfFiveCheck.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Type/Linear/InterleavedTwoOfFiveCheck.php b/src/Type/Linear/InterleavedTwoOfFiveCheck.php index 9cb5f249..a07f0121 100644 --- a/src/Type/Linear/InterleavedTwoOfFiveCheck.php +++ b/src/Type/Linear/InterleavedTwoOfFiveCheck.php @@ -46,7 +46,7 @@ class InterleavedTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear\Standar * * @var array */ - protected array $chbar = array( + protected const CHBAR= array( '0' => '11221', '1' => '21112', '2' => '12112', @@ -90,14 +90,14 @@ protected function setBars(): void for ($idx = 0; $idx < $clen; $idx = ($idx + 2)) { $char_bar = $this->extcode[$idx]; $char_space = $this->extcode[($idx + 1)]; - if ((!isset($this->chbar[$char_bar])) || (!isset($this->chbar[$char_space]))) { + if ((!isset(self::CHBAR[$char_bar])) || (!isset(self::CHBAR[$char_space]))) { throw new BarcodeException('Invalid character sequence: ' . $char_bar . $char_space); } // create a bar-space sequence $seq = ''; - $chrlen = strlen($this->chbar[$char_bar]); + $chrlen = strlen(self::CHBAR[$char_bar]); for ($pos = 0; $pos < $chrlen; ++$pos) { - $seq .= $this->chbar[$char_bar][$pos] . $this->chbar[$char_space][$pos]; + $seq .= self::CHBAR[$char_bar][$pos] . self::CHBAR[$char_space][$pos]; } $seqlen = strlen($seq); for ($pos = 0; $pos < $seqlen; ++$pos) { From c5c610ce56c54427849b625f9f75c3ba703361f4 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:21:07 +0000 Subject: [PATCH 028/100] fixes --- src/Type/Linear/MsiCheck.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Type/Linear/MsiCheck.php b/src/Type/Linear/MsiCheck.php index 6e96ff5f..0284bab6 100644 --- a/src/Type/Linear/MsiCheck.php +++ b/src/Type/Linear/MsiCheck.php @@ -46,7 +46,7 @@ class MsiCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected array $chbar = array( + protected const CHBAR = array( '0' => '100100100100', '1' => '100100100110', '2' => '100100110100', @@ -115,10 +115,10 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($pos = 0; $pos < $clen; ++$pos) { $digit = $this->extcode[$pos]; - if (!isset($this->chbar[$digit])) { + if (!isset(self::CHBAR[$digit])) { throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')'); } - $seq .= $this->chbar[$digit]; + $seq .= self::CHBAR[$digit]; } $seq .= '1001'; // right guard $this->processBinarySequence($seq); From 36dcbd0aa3ddfa239d0cd0db820c2098341ace57 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:23:34 +0000 Subject: [PATCH 029/100] fixes --- src/Type/Linear/Planet.php | 2 +- src/Type/Linear/Postnet.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Type/Linear/Planet.php b/src/Type/Linear/Planet.php index 0777f302..8616b87b 100644 --- a/src/Type/Linear/Planet.php +++ b/src/Type/Linear/Planet.php @@ -46,7 +46,7 @@ class Planet extends \Com\Tecnick\Barcode\Type\Linear\Postnet * * @var array */ - protected array $chbar = array( + protected const CHBAR = array( '0' => '11222', '1' => '22211', '2' => '22121', diff --git a/src/Type/Linear/Postnet.php b/src/Type/Linear/Postnet.php index be8a5b33..476f8de7 100644 --- a/src/Type/Linear/Postnet.php +++ b/src/Type/Linear/Postnet.php @@ -46,7 +46,7 @@ class Postnet extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected array $chbar = array( + protected const CHBAR = array( '0' => '22111', '1' => '11122', '2' => '11212', @@ -106,11 +106,11 @@ protected function setBars(): void $this->ncols += 2; for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset($this->chbar[$char])) { + if (!isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } for ($pos = 0; $pos < 5; ++$pos) { - $bar_height = intval($this->chbar[$char][$pos]); + $bar_height = intval($this::CHBAR[$char][$pos]); $this->bars[] = array($this->ncols, floor(1 / $bar_height), 1, $bar_height); $this->ncols += 2; } From 7e50b77ae6d6ccc0330e72524b9dfe11b80fd002 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:24:18 +0000 Subject: [PATCH 030/100] fixes --- src/Type/Linear/Codabar.php | 4 ++-- src/Type/Linear/CodeNineThree.php | 2 +- src/Type/Linear/CodeOneOne.php | 4 ++-- src/Type/Linear/CodeOneTwoEight.php | 2 +- src/Type/Linear/CodeThreeNineExtCheck.php | 4 ++-- src/Type/Linear/EanEight.php | 4 ++-- src/Type/Linear/EanOneThree.php | 4 ++-- src/Type/Linear/EanTwo.php | 4 ++-- src/Type/Linear/InterleavedTwoOfFiveCheck.php | 6 +++--- src/Type/Linear/MsiCheck.php | 4 ++-- src/Type/Linear/UpcE.php | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Type/Linear/Codabar.php b/src/Type/Linear/Codabar.php index 1e581a54..d0a344dd 100644 --- a/src/Type/Linear/Codabar.php +++ b/src/Type/Linear/Codabar.php @@ -90,11 +90,11 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset(self::CHBAR[$char])) { + if (!isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } for ($pos = 0; $pos < 8; ++$pos) { - $bar_width = intval(self::CHBAR[$char][$pos]); + $bar_width = intval($this::CHBAR[$char][$pos]); if (($pos % 2) == 0) { $this->bars[] = array($this->ncols, 0, $bar_width, 1); } diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index 82ca127a..39fcc03f 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -355,7 +355,7 @@ protected function setBars(): void for ($chr = 0; $chr < $clen; ++$chr) { $char = ord($this->extcode[$chr]); for ($pos = 0; $pos < 6; ++$pos) { - $bar_width = intval(self::CHBAR[$char][$pos]); + $bar_width = intval($this::CHBAR[$char][$pos]); if (($pos % 2) == 0) { $this->bars[] = array($this->ncols, 0, $bar_width, 1); } diff --git a/src/Type/Linear/CodeOneOne.php b/src/Type/Linear/CodeOneOne.php index 2fa94c46..0efb7dbd 100644 --- a/src/Type/Linear/CodeOneOne.php +++ b/src/Type/Linear/CodeOneOne.php @@ -137,11 +137,11 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset(self::CHBAR[$char])) { + if (!isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } for ($pos = 0; $pos < 6; ++$pos) { - $bar_width = intval(self::CHBAR[$char][$pos]); + $bar_width = intval($this::CHBAR[$char][$pos]); if ((($pos % 2) == 0) && ($bar_width > 0)) { $this->bars[] = array($this->ncols, 0, $bar_width, 1); } diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index e74bbea0..48a6dcce 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -254,7 +254,7 @@ protected function setBars(): void $this->nrows = 1; $this->bars = array(); foreach ($code_data as $val) { - $seq = self::CHBAR[$val]; + $seq = $this::CHBAR[$val]; for ($pos = 0; $pos < 6; ++$pos) { $bar_width = intval($seq[$pos]); if ((($pos % 2) == 0) && ($bar_width > 0)) { diff --git a/src/Type/Linear/CodeThreeNineExtCheck.php b/src/Type/Linear/CodeThreeNineExtCheck.php index 260620ec..485f374f 100644 --- a/src/Type/Linear/CodeThreeNineExtCheck.php +++ b/src/Type/Linear/CodeThreeNineExtCheck.php @@ -210,11 +210,11 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset(self::CHBAREXCHK[$char])) { + if (!isset($this::CHBAREXCHK[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } for ($pos = 0; $pos < 9; ++$pos) { - $bar_width = intval(self::CHBAREXCHK[$char][$pos]); + $bar_width = intval($this::CHBAREXCHK[$char][$pos]); if ((($pos % 2) == 0) && ($bar_width > 0)) { $this->bars[] = array($this->ncols, 0, $bar_width, 1); } diff --git a/src/Type/Linear/EanEight.php b/src/Type/Linear/EanEight.php index 135428f2..733c065a 100644 --- a/src/Type/Linear/EanEight.php +++ b/src/Type/Linear/EanEight.php @@ -59,11 +59,11 @@ protected function setBars(): void $seq = '101'; // left guard bar $half_len = intval(ceil($this->code_length / 2)); for ($pos = 0; $pos < $half_len; ++$pos) { - $seq .= self::CHBAR['A'][$this->extcode[$pos]]; + $seq .= $this::CHBAR['A'][$this->extcode[$pos]]; } $seq .= '01010'; // center guard bar for ($pos = $half_len; $pos < $this->code_length; ++$pos) { - $seq .= self::CHBAR['C'][$this->extcode[$pos]]; + $seq .= $this::CHBAR['C'][$this->extcode[$pos]]; } $seq .= '101'; // right guard bar $this->processBinarySequence($seq); diff --git a/src/Type/Linear/EanOneThree.php b/src/Type/Linear/EanOneThree.php index 1a1e543c..60131ceb 100644 --- a/src/Type/Linear/EanOneThree.php +++ b/src/Type/Linear/EanOneThree.php @@ -182,11 +182,11 @@ protected function setBars(): void $half_len = intval(ceil($this->code_length / 2)); $parity = $this->parities[$this->extcode[0]]; for ($pos = 1; $pos < $half_len; ++$pos) { - $seq .= self::CHBAR[$parity[($pos - 1)]][$this->extcode[$pos]]; + $seq .= $this::CHBAR[$parity[($pos - 1)]][$this->extcode[$pos]]; } $seq .= '01010'; // center guard bar for ($pos = $half_len; $pos < $this->code_length; ++$pos) { - $seq .= self::CHBAR['C'][$this->extcode[$pos]]; + $seq .= $this::CHBAR['C'][$this->extcode[$pos]]; } $seq .= '101'; // right guard bar $this->processBinarySequence($seq); diff --git a/src/Type/Linear/EanTwo.php b/src/Type/Linear/EanTwo.php index e102e39d..f39ddeba 100644 --- a/src/Type/Linear/EanTwo.php +++ b/src/Type/Linear/EanTwo.php @@ -123,11 +123,11 @@ protected function setBars(): void $chk = $this->getChecksum($this->extcode); $parity = $this->parities[$chk]; $seq = '1011'; // left guard bar - $seq .= self::CHBAR[$parity[0]][$this->extcode[0]]; + $seq .= $this::CHBAR[$parity[0]][$this->extcode[0]]; $len = strlen($this->extcode); for ($pos = 1; $pos < $len; ++$pos) { $seq .= '01'; // separator - $seq .= self::CHBAR[$parity[$pos]][$this->extcode[$pos]]; + $seq .= $this::CHBAR[$parity[$pos]][$this->extcode[$pos]]; } $this->processBinarySequence($seq); } diff --git a/src/Type/Linear/InterleavedTwoOfFiveCheck.php b/src/Type/Linear/InterleavedTwoOfFiveCheck.php index a07f0121..2881ec22 100644 --- a/src/Type/Linear/InterleavedTwoOfFiveCheck.php +++ b/src/Type/Linear/InterleavedTwoOfFiveCheck.php @@ -90,14 +90,14 @@ protected function setBars(): void for ($idx = 0; $idx < $clen; $idx = ($idx + 2)) { $char_bar = $this->extcode[$idx]; $char_space = $this->extcode[($idx + 1)]; - if ((!isset(self::CHBAR[$char_bar])) || (!isset(self::CHBAR[$char_space]))) { + if ((!isset($this::CHBAR[$char_bar])) || (!isset($this::CHBAR[$char_space]))) { throw new BarcodeException('Invalid character sequence: ' . $char_bar . $char_space); } // create a bar-space sequence $seq = ''; - $chrlen = strlen(self::CHBAR[$char_bar]); + $chrlen = strlen($this::CHBAR[$char_bar]); for ($pos = 0; $pos < $chrlen; ++$pos) { - $seq .= self::CHBAR[$char_bar][$pos] . self::CHBAR[$char_space][$pos]; + $seq .= $this::CHBAR[$char_bar][$pos] . $this::CHBAR[$char_space][$pos]; } $seqlen = strlen($seq); for ($pos = 0; $pos < $seqlen; ++$pos) { diff --git a/src/Type/Linear/MsiCheck.php b/src/Type/Linear/MsiCheck.php index 0284bab6..7a4be2a8 100644 --- a/src/Type/Linear/MsiCheck.php +++ b/src/Type/Linear/MsiCheck.php @@ -115,10 +115,10 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($pos = 0; $pos < $clen; ++$pos) { $digit = $this->extcode[$pos]; - if (!isset(self::CHBAR[$digit])) { + if (!isset($this::CHBAR[$digit])) { throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')'); } - $seq .= self::CHBAR[$digit]; + $seq .= $this::CHBAR[$digit]; } $seq .= '1001'; // right guard $this->processBinarySequence($seq); diff --git a/src/Type/Linear/UpcE.php b/src/Type/Linear/UpcE.php index 6209042a..883df672 100644 --- a/src/Type/Linear/UpcE.php +++ b/src/Type/Linear/UpcE.php @@ -160,7 +160,7 @@ protected function setBars(): void $seq = '101'; // left guard bar $parity = $this->parities[$this->extcode[1]][$this->check]; for ($pos = 0; $pos < 6; ++$pos) { - $seq .= self::CHBAR[$parity[$pos]][$upce_code[$pos]]; + $seq .= $this::CHBAR[$parity[$pos]][$upce_code[$pos]]; } $seq .= '010101'; // right guard bar $this->processBinarySequence($seq); From 3b8244a7acf430cd3563e05cc7d8aaa3a77be8dc Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:25:23 +0000 Subject: [PATCH 031/100] fixes --- src/Type/Linear/CodeThreeNineExtCheck.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Type/Linear/CodeThreeNineExtCheck.php b/src/Type/Linear/CodeThreeNineExtCheck.php index 485f374f..9d905b8d 100644 --- a/src/Type/Linear/CodeThreeNineExtCheck.php +++ b/src/Type/Linear/CodeThreeNineExtCheck.php @@ -46,7 +46,7 @@ class CodeThreeNineExtCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAREXCHK = array( + protected const CHBAR = array( '0' => '111331311', '1' => '311311113', '2' => '113311113', @@ -210,11 +210,11 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset($this::CHBAREXCHK[$char])) { + if (!isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } for ($pos = 0; $pos < 9; ++$pos) { - $bar_width = intval($this::CHBAREXCHK[$char][$pos]); + $bar_width = intval($this::CHBAR[$char][$pos]); if ((($pos % 2) == 0) && ($bar_width > 0)) { $this->bars[] = array($this->ncols, 0, $bar_width, 1); } From d298d9a836437943a83a46de6277b48d55deef88 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:27:10 +0000 Subject: [PATCH 032/100] fixes --- src/Type.php | 2 +- src/Type/Convert.php | 2 +- src/Type/Linear.php | 2 +- src/Type/Linear/Raw.php | 2 +- src/Type/Square.php | 2 +- src/Type/Square/Raw.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Type.php b/src/Type.php index a8b8c28d..2145ffc0 100644 --- a/src/Type.php +++ b/src/Type.php @@ -205,7 +205,7 @@ protected function getRgbColorObject(string $color): ?Rgb public function getArray(): array { return array( - 'type' => $this->type, + 'type' => $this::TYPE, 'format' => $this->format, 'params' => $this->params, 'code' => $this->code, diff --git a/src/Type/Convert.php b/src/Type/Convert.php index aca42615..8150963c 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -39,7 +39,7 @@ abstract class Convert * * @var string */ - protected string $type = ''; + protected const TYPE = ''; /** * Barcode format diff --git a/src/Type/Linear.php b/src/Type/Linear.php index 5b4ed5fd..cc26a052 100644 --- a/src/Type/Linear.php +++ b/src/Type/Linear.php @@ -36,5 +36,5 @@ abstract class Linear extends \Com\Tecnick\Barcode\Type * * @var string */ - protected string $type = 'linear'; + protected const TYPE = 'linear'; } diff --git a/src/Type/Linear/Raw.php b/src/Type/Linear/Raw.php index 162cc06a..86dc4895 100644 --- a/src/Type/Linear/Raw.php +++ b/src/Type/Linear/Raw.php @@ -39,7 +39,7 @@ class Raw extends \Com\Tecnick\Barcode\Type\Raw * * @var string */ - protected string $type = 'linear'; + protected const TYPE = 'linear'; /** * Barcode format diff --git a/src/Type/Square.php b/src/Type/Square.php index 4f1ff422..0077d8bf 100644 --- a/src/Type/Square.php +++ b/src/Type/Square.php @@ -36,5 +36,5 @@ abstract class Square extends \Com\Tecnick\Barcode\Type * * @var string */ - protected string $type = 'square'; + protected const TYPE = 'square'; } diff --git a/src/Type/Square/Raw.php b/src/Type/Square/Raw.php index 645fd8c3..092f9a5a 100644 --- a/src/Type/Square/Raw.php +++ b/src/Type/Square/Raw.php @@ -39,7 +39,7 @@ class Raw extends \Com\Tecnick\Barcode\Type\Raw * * @var string */ - protected string $type = 'square'; + protected const TYPE = 'square'; /** * Barcode format From 2727a04c10c08567f5860c43599b70f3c662dcf8 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:28:30 +0000 Subject: [PATCH 033/100] fixes --- src/Type.php | 2 +- src/Type/Convert.php | 2 +- src/Type/Linear/Codabar.php | 4 ++-- src/Type/Linear/CodeNineThree.php | 4 ++-- src/Type/Linear/CodeOneOne.php | 4 ++-- src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php | 2 +- src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php | 2 +- src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php | 2 +- src/Type/Linear/CodeOneTwoEight/Process.php | 2 +- src/Type/Linear/CodeThreeNine.php | 2 +- src/Type/Linear/CodeThreeNineCheck.php | 2 +- src/Type/Linear/CodeThreeNineExt.php | 2 +- src/Type/Linear/CodeThreeNineExtCheck.php | 4 ++-- src/Type/Linear/EanEight.php | 4 ++-- src/Type/Linear/EanFive.php | 2 +- src/Type/Linear/EanOneThree.php | 4 ++-- src/Type/Linear/EanTwo.php | 4 ++-- src/Type/Linear/Imb.php | 2 +- src/Type/Linear/ImbPre.php | 2 +- src/Type/Linear/InterleavedTwoOfFive.php | 2 +- src/Type/Linear/InterleavedTwoOfFiveCheck.php | 4 ++-- src/Type/Linear/KlantIndex.php | 2 +- src/Type/Linear/Msi.php | 2 +- src/Type/Linear/MsiCheck.php | 4 ++-- src/Type/Linear/Pharma.php | 2 +- src/Type/Linear/PharmaTwoTracks.php | 2 +- src/Type/Linear/Planet.php | 2 +- src/Type/Linear/Postnet.php | 4 ++-- src/Type/Linear/Raw.php | 2 +- src/Type/Linear/RoyalMailFourCc.php | 4 ++-- src/Type/Linear/StandardTwoOfFive.php | 2 +- src/Type/Linear/StandardTwoOfFiveCheck.php | 4 ++-- src/Type/Linear/UpcA.php | 2 +- src/Type/Linear/UpcE.php | 4 ++-- src/Type/Square/Aztec.php | 2 +- src/Type/Square/Datamatrix.php | 2 +- src/Type/Square/PdfFourOneSeven.php | 2 +- src/Type/Square/QrCode.php | 2 +- src/Type/Square/Raw.php | 2 +- 39 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/Type.php b/src/Type.php index 2145ffc0..6c3e0954 100644 --- a/src/Type.php +++ b/src/Type.php @@ -206,7 +206,7 @@ public function getArray(): array { return array( 'type' => $this::TYPE, - 'format' => $this->format, + 'format' => $this::FORMAT, 'params' => $this->params, 'code' => $this->code, 'extcode' => $this->extcode, diff --git a/src/Type/Convert.php b/src/Type/Convert.php index 8150963c..c670bc52 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -46,7 +46,7 @@ abstract class Convert * * @var string */ - protected string $format = ''; + protected const FORMAT = ''; /** * Array containing extra parameters for the specified barcode type diff --git a/src/Type/Linear/Codabar.php b/src/Type/Linear/Codabar.php index d0a344dd..eb1e2d55 100644 --- a/src/Type/Linear/Codabar.php +++ b/src/Type/Linear/Codabar.php @@ -38,7 +38,7 @@ class Codabar extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'CODABAR'; + protected const FORMAT = 'CODABAR'; /** * Map characters to barcodes @@ -86,7 +86,7 @@ protected function setBars(): void $this->ncols = 0; $this->nrows = 1; $this->bars = array(); - $this->formatCode(); + $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index 39fcc03f..1f1630da 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -39,7 +39,7 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * * @var string */ - protected string $format = 'C93'; + protected const FORMAT = 'C93'; /** * Map characters to barcodes @@ -350,7 +350,7 @@ protected function setBars(): void $this->ncols = 0; $this->nrows = 1; $this->bars = array(); - $this->formatCode(); + $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = ord($this->extcode[$chr]); diff --git a/src/Type/Linear/CodeOneOne.php b/src/Type/Linear/CodeOneOne.php index 0efb7dbd..604c8a2f 100644 --- a/src/Type/Linear/CodeOneOne.php +++ b/src/Type/Linear/CodeOneOne.php @@ -39,7 +39,7 @@ class CodeOneOne extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'CODE11'; + protected const FORMAT = 'CODE11'; /** * Map characters to barcodes @@ -133,7 +133,7 @@ protected function setBars(): void $this->ncols = 0; $this->nrows = 1; $this->bars = array(); - $this->formatCode(); + $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php index 1dcab675..361ed6de 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php @@ -39,7 +39,7 @@ class CodeOneTwoEightA extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight * * @var string */ - protected string $format = 'C128A'; + protected const FORMAT = 'C128A'; /** * Get the code point array diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php index 1778425e..8f8cdd03 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php @@ -39,7 +39,7 @@ class CodeOneTwoEightB extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight * * @var string */ - protected string $format = 'C128B'; + protected const FORMAT = 'C128B'; /** * Get the code point array diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php index 2c883464..61970a1e 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php @@ -39,7 +39,7 @@ class CodeOneTwoEightC extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight * * @var string */ - protected string $format = 'C128C'; + protected const FORMAT = 'C128C'; /** * Get the code point array diff --git a/src/Type/Linear/CodeOneTwoEight/Process.php b/src/Type/Linear/CodeOneTwoEight/Process.php index cf86d6d4..ecbf77f7 100644 --- a/src/Type/Linear/CodeOneTwoEight/Process.php +++ b/src/Type/Linear/CodeOneTwoEight/Process.php @@ -39,7 +39,7 @@ abstract class Process extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'C128'; + protected const FORMAT = 'C128'; /** * Map characters to barcodes diff --git a/src/Type/Linear/CodeThreeNine.php b/src/Type/Linear/CodeThreeNine.php index 110ec656..06695c99 100644 --- a/src/Type/Linear/CodeThreeNine.php +++ b/src/Type/Linear/CodeThreeNine.php @@ -39,7 +39,7 @@ class CodeThreeNine extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * * @var string */ - protected string $format = 'C39'; + protected const FORMAT = 'C39'; /** * Format code diff --git a/src/Type/Linear/CodeThreeNineCheck.php b/src/Type/Linear/CodeThreeNineCheck.php index b2406b99..d5cb9ca4 100644 --- a/src/Type/Linear/CodeThreeNineCheck.php +++ b/src/Type/Linear/CodeThreeNineCheck.php @@ -39,7 +39,7 @@ class CodeThreeNineCheck extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineE * * @var string */ - protected string $format = 'C39+'; + protected const FORMAT = 'C39+'; /** * Format code diff --git a/src/Type/Linear/CodeThreeNineExt.php b/src/Type/Linear/CodeThreeNineExt.php index f8920faf..0bff4e75 100644 --- a/src/Type/Linear/CodeThreeNineExt.php +++ b/src/Type/Linear/CodeThreeNineExt.php @@ -39,7 +39,7 @@ class CodeThreeNineExt extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExt * * @var string */ - protected string $format = 'C39E'; + protected const FORMAT = 'C39E'; /** * Format code diff --git a/src/Type/Linear/CodeThreeNineExtCheck.php b/src/Type/Linear/CodeThreeNineExtCheck.php index 9d905b8d..39bd755f 100644 --- a/src/Type/Linear/CodeThreeNineExtCheck.php +++ b/src/Type/Linear/CodeThreeNineExtCheck.php @@ -39,7 +39,7 @@ class CodeThreeNineExtCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'C39E+'; + protected const FORMAT = 'C39E+'; /** * Map characters to barcodes @@ -206,7 +206,7 @@ protected function setBars(): void $this->ncols = 0; $this->nrows = 1; $this->bars = array(); - $this->formatCode(); + $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; diff --git a/src/Type/Linear/EanEight.php b/src/Type/Linear/EanEight.php index 733c065a..19455665 100644 --- a/src/Type/Linear/EanEight.php +++ b/src/Type/Linear/EanEight.php @@ -39,7 +39,7 @@ class EanEight extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree * * @var string */ - protected string $format = 'EAN8'; + protected const FORMAT = 'EAN8'; /** * Fixed code length @@ -55,7 +55,7 @@ class EanEight extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree */ protected function setBars(): void { - $this->formatCode(); + $this::FORMATCode(); $seq = '101'; // left guard bar $half_len = intval(ceil($this->code_length / 2)); for ($pos = 0; $pos < $half_len; ++$pos) { diff --git a/src/Type/Linear/EanFive.php b/src/Type/Linear/EanFive.php index 91fae29d..2fde9da1 100644 --- a/src/Type/Linear/EanFive.php +++ b/src/Type/Linear/EanFive.php @@ -39,7 +39,7 @@ class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo * * @var string */ - protected string $format = 'EAN5'; + protected const FORMAT = 'EAN5'; /** * Fixed code length diff --git a/src/Type/Linear/EanOneThree.php b/src/Type/Linear/EanOneThree.php index 60131ceb..354b5925 100644 --- a/src/Type/Linear/EanOneThree.php +++ b/src/Type/Linear/EanOneThree.php @@ -39,7 +39,7 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'EAN13'; + protected const FORMAT = 'EAN13'; /** * Fixed code length @@ -177,7 +177,7 @@ protected function setBars(): void if (!is_numeric($this->code)) { throw new BarcodeException('Input code must be a number'); } - $this->formatCode(); + $this::FORMATCode(); $seq = '101'; // left guard bar $half_len = intval(ceil($this->code_length / 2)); $parity = $this->parities[$this->extcode[0]]; diff --git a/src/Type/Linear/EanTwo.php b/src/Type/Linear/EanTwo.php index f39ddeba..8ae4f68c 100644 --- a/src/Type/Linear/EanTwo.php +++ b/src/Type/Linear/EanTwo.php @@ -39,7 +39,7 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'EAN2'; + protected const FORMAT = 'EAN2'; /** * Fixed code length @@ -119,7 +119,7 @@ protected function formatCode(): void */ protected function setBars(): void { - $this->formatCode(); + $this::FORMATCode(); $chk = $this->getChecksum($this->extcode); $parity = $this->parities[$chk]; $seq = '1011'; // left guard bar diff --git a/src/Type/Linear/Imb.php b/src/Type/Linear/Imb.php index 0d6988af..84d66e74 100644 --- a/src/Type/Linear/Imb.php +++ b/src/Type/Linear/Imb.php @@ -60,7 +60,7 @@ class Imb extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'IMB'; + protected const FORMAT = 'IMB'; /** * ASC characters diff --git a/src/Type/Linear/ImbPre.php b/src/Type/Linear/ImbPre.php index 18b10af4..a935639f 100644 --- a/src/Type/Linear/ImbPre.php +++ b/src/Type/Linear/ImbPre.php @@ -39,7 +39,7 @@ class ImbPre extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'IMBPRE'; + protected const FORMAT = 'IMBPRE'; /** * Set the bars array. diff --git a/src/Type/Linear/InterleavedTwoOfFive.php b/src/Type/Linear/InterleavedTwoOfFive.php index d833839c..0c76e0e1 100644 --- a/src/Type/Linear/InterleavedTwoOfFive.php +++ b/src/Type/Linear/InterleavedTwoOfFive.php @@ -39,7 +39,7 @@ class InterleavedTwoOfFive extends \Com\Tecnick\Barcode\Type\Linear\InterleavedT * * @var string */ - protected string $format = 'I25'; + protected const FORMAT = 'I25'; /** * Format code diff --git a/src/Type/Linear/InterleavedTwoOfFiveCheck.php b/src/Type/Linear/InterleavedTwoOfFiveCheck.php index 2881ec22..dc2edd4d 100644 --- a/src/Type/Linear/InterleavedTwoOfFiveCheck.php +++ b/src/Type/Linear/InterleavedTwoOfFiveCheck.php @@ -39,7 +39,7 @@ class InterleavedTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear\Standar * * @var string */ - protected string $format = 'I25+'; + protected const FORMAT = 'I25+'; /** * Map characters to barcodes @@ -76,7 +76,7 @@ protected function formatCode(): void */ protected function setBars(): void { - $this->formatCode(); + $this::FORMATCode(); if ((strlen($this->extcode) % 2) != 0) { // add leading zero if code-length is odd $this->extcode = '0' . $this->extcode; diff --git a/src/Type/Linear/KlantIndex.php b/src/Type/Linear/KlantIndex.php index 73e095af..4afb6430 100644 --- a/src/Type/Linear/KlantIndex.php +++ b/src/Type/Linear/KlantIndex.php @@ -39,7 +39,7 @@ class KlantIndex extends \Com\Tecnick\Barcode\Type\Linear\RoyalMailFourCc * * @var string */ - protected string $format = 'KIX'; + protected const FORMAT = 'KIX'; /** * Format code diff --git a/src/Type/Linear/Msi.php b/src/Type/Linear/Msi.php index 4a9ea375..0f3fc9e4 100644 --- a/src/Type/Linear/Msi.php +++ b/src/Type/Linear/Msi.php @@ -39,7 +39,7 @@ class Msi extends \Com\Tecnick\Barcode\Type\Linear\MsiCheck * * @var string */ - protected string $format = 'MSI'; + protected const FORMAT = 'MSI'; /** * Format code diff --git a/src/Type/Linear/MsiCheck.php b/src/Type/Linear/MsiCheck.php index 7a4be2a8..44c07ee5 100644 --- a/src/Type/Linear/MsiCheck.php +++ b/src/Type/Linear/MsiCheck.php @@ -39,7 +39,7 @@ class MsiCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'MSI+'; + protected const FORMAT = 'MSI+'; /** * Map characters to barcodes @@ -110,7 +110,7 @@ protected function formatCode(): void */ protected function setBars(): void { - $this->formatCode(); + $this::FORMATCode(); $seq = '110'; // left guard $clen = strlen($this->extcode); for ($pos = 0; $pos < $clen; ++$pos) { diff --git a/src/Type/Linear/Pharma.php b/src/Type/Linear/Pharma.php index 9e4177d3..725d837a 100644 --- a/src/Type/Linear/Pharma.php +++ b/src/Type/Linear/Pharma.php @@ -39,7 +39,7 @@ class Pharma extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'PHARMA'; + protected const FORMAT = 'PHARMA'; /** * Set the bars array. diff --git a/src/Type/Linear/PharmaTwoTracks.php b/src/Type/Linear/PharmaTwoTracks.php index 5f2d1e90..088e1893 100644 --- a/src/Type/Linear/PharmaTwoTracks.php +++ b/src/Type/Linear/PharmaTwoTracks.php @@ -39,7 +39,7 @@ class PharmaTwoTracks extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'PHARMA2T'; + protected const FORMAT = 'PHARMA2T'; /** * Set the bars array. diff --git a/src/Type/Linear/Planet.php b/src/Type/Linear/Planet.php index 8616b87b..684e8a50 100644 --- a/src/Type/Linear/Planet.php +++ b/src/Type/Linear/Planet.php @@ -39,7 +39,7 @@ class Planet extends \Com\Tecnick\Barcode\Type\Linear\Postnet * * @var string */ - protected string $format = 'PLANET'; + protected const FORMAT = 'PLANET'; /** * Map characters to barcodes diff --git a/src/Type/Linear/Postnet.php b/src/Type/Linear/Postnet.php index 476f8de7..97ef5d23 100644 --- a/src/Type/Linear/Postnet.php +++ b/src/Type/Linear/Postnet.php @@ -39,7 +39,7 @@ class Postnet extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'POSTNET'; + protected const FORMAT = 'POSTNET'; /** * Map characters to barcodes @@ -99,7 +99,7 @@ protected function setBars(): void $this->ncols = 0; $this->nrows = 2; $this->bars = array(); - $this->formatCode(); + $this::FORMATCode(); $clen = strlen($this->extcode); // start bar $this->bars[] = array($this->ncols, 0, 1, 2); diff --git a/src/Type/Linear/Raw.php b/src/Type/Linear/Raw.php index 86dc4895..f89b3b0c 100644 --- a/src/Type/Linear/Raw.php +++ b/src/Type/Linear/Raw.php @@ -46,5 +46,5 @@ class Raw extends \Com\Tecnick\Barcode\Type\Raw * * @var string */ - protected string $format = 'LRAW'; + protected const FORMAT = 'LRAW'; } diff --git a/src/Type/Linear/RoyalMailFourCc.php b/src/Type/Linear/RoyalMailFourCc.php index 14eeaba7..b4601fd9 100644 --- a/src/Type/Linear/RoyalMailFourCc.php +++ b/src/Type/Linear/RoyalMailFourCc.php @@ -39,7 +39,7 @@ class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'RMS4CC'; + protected const FORMAT = 'RMS4CC'; /** * Map characters to barcodes @@ -173,7 +173,7 @@ protected function formatCode(): void */ protected function getCoreBars(): void { - $this->formatCode(); + $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; diff --git a/src/Type/Linear/StandardTwoOfFive.php b/src/Type/Linear/StandardTwoOfFive.php index 30537702..2e0e8213 100644 --- a/src/Type/Linear/StandardTwoOfFive.php +++ b/src/Type/Linear/StandardTwoOfFive.php @@ -39,7 +39,7 @@ class StandardTwoOfFive extends \Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFi * * @var string */ - protected string $format = 'S25'; + protected const FORMAT = 'S25'; /** * Format code diff --git a/src/Type/Linear/StandardTwoOfFiveCheck.php b/src/Type/Linear/StandardTwoOfFiveCheck.php index ee73e75d..35016cb2 100644 --- a/src/Type/Linear/StandardTwoOfFiveCheck.php +++ b/src/Type/Linear/StandardTwoOfFiveCheck.php @@ -39,7 +39,7 @@ class StandardTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var string */ - protected string $format = 'S25+'; + protected const FORMAT = 'S25+'; /** * Map characters to barcodes @@ -99,7 +99,7 @@ protected function formatCode(): void */ protected function setBars(): void { - $this->formatCode(); + $this::FORMATCode(); if ((strlen($this->extcode) % 2) != 0) { // add leading zero if code-length is odd $this->extcode = '0' . $this->extcode; diff --git a/src/Type/Linear/UpcA.php b/src/Type/Linear/UpcA.php index 165c8c56..aef079c5 100644 --- a/src/Type/Linear/UpcA.php +++ b/src/Type/Linear/UpcA.php @@ -39,7 +39,7 @@ class UpcA extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree * * @var string */ - protected string $format = 'UPCA'; + protected const FORMAT = 'UPCA'; /** * Fixed code length diff --git a/src/Type/Linear/UpcE.php b/src/Type/Linear/UpcE.php index 883df672..9bb78e6f 100644 --- a/src/Type/Linear/UpcE.php +++ b/src/Type/Linear/UpcE.php @@ -43,7 +43,7 @@ class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA * * @var string */ - protected string $format = 'UPCE'; + protected const FORMAT = 'UPCE'; /** * Fixed code length @@ -155,7 +155,7 @@ protected function formatCode(): void */ protected function setBars(): void { - $this->formatCode(); + $this::FORMATCode(); $upce_code = $this->convertUpcaToUpce($this->extcode); $seq = '101'; // left guard bar $parity = $this->parities[$this->extcode[1]][$this->check]; diff --git a/src/Type/Square/Aztec.php b/src/Type/Square/Aztec.php index f949518a..d9e52c61 100644 --- a/src/Type/Square/Aztec.php +++ b/src/Type/Square/Aztec.php @@ -40,7 +40,7 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square * * @var string */ - protected string $format = 'AZTEC'; + protected const FORMAT = 'AZTEC'; /** * Error correction code percentage of error check words. diff --git a/src/Type/Square/Datamatrix.php b/src/Type/Square/Datamatrix.php index fd651be3..59257029 100644 --- a/src/Type/Square/Datamatrix.php +++ b/src/Type/Square/Datamatrix.php @@ -41,7 +41,7 @@ class Datamatrix extends \Com\Tecnick\Barcode\Type\Square * * @var string */ - protected string $format = 'DATAMATRIX'; + protected const FORMAT = 'DATAMATRIX'; /** * Array of codewords. diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index 4c9adda6..66d6ee48 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -52,7 +52,7 @@ class PdfFourOneSeven extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\C * * @var string */ - protected string $format = 'PDF417'; + protected const FORMAT = 'PDF417'; /** * Row height respect X dimension of single module diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 33fa4952..3dc994b6 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -42,7 +42,7 @@ class QrCode extends \Com\Tecnick\Barcode\Type\Square * * @var string */ - protected string $format = 'QRCODE'; + protected const FORMAT = 'QRCODE'; /** * QR code version. diff --git a/src/Type/Square/Raw.php b/src/Type/Square/Raw.php index 092f9a5a..dffcee2f 100644 --- a/src/Type/Square/Raw.php +++ b/src/Type/Square/Raw.php @@ -46,5 +46,5 @@ class Raw extends \Com\Tecnick\Barcode\Type\Raw * * @var string */ - protected string $format = 'SRAW'; + protected const FORMAT = 'SRAW'; } From 23c503f2a3dcaa77107577cea4a88412cec31908 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:30:28 +0000 Subject: [PATCH 034/100] fixes --- src/Type/Linear/CodeOneTwoEight.php | 4 ++-- src/Type/Linear/CodeOneTwoEight/Process.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index 48a6dcce..b4d208a3 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -169,12 +169,12 @@ protected function processSequenceBA( case 'A': $startid = 103; $sequence[$key][0] = 'A'; - $code_data[] = $this->fnc_a[$tmpchr]; + $code_data[] = $this::FNC_A[$tmpchr]; break; case 'C': $startid = 105; $sequence[$key][0] = 'C'; - $code_data[] = $this->fnc_a[$tmpchr]; + $code_data[] = $this::FNC_A[$tmpchr]; break; } } else { diff --git a/src/Type/Linear/CodeOneTwoEight/Process.php b/src/Type/Linear/CodeOneTwoEight/Process.php index ecbf77f7..1b3deb50 100644 --- a/src/Type/Linear/CodeOneTwoEight/Process.php +++ b/src/Type/Linear/CodeOneTwoEight/Process.php @@ -176,14 +176,14 @@ abstract class Process extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected array $fnc_a = array(241 => 102, 242 => 97, 243 => 96, 244 => 101); + protected const FNC_A = array(241 => 102, 242 => 97, 243 => 96, 244 => 101); /** * Map special FNC codes for Code Set B (FNC 1-4) * * @var array */ - protected array $fnc_b = array(241 => 102, 242 => 97, 243 => 96, 244 => 100); + protected const FNC_B = array(241 => 102, 242 => 97, 243 => 96, 244 => 100); /** * Get the numeric sequence (if any) @@ -299,7 +299,7 @@ protected function getCodeDataA( $char = $code[$pos]; $char_id = ord($char); if (($char_id >= 241) && ($char_id <= 244)) { - $code_data[] = $this->fnc_a[$char_id]; + $code_data[] = $this::FNC_A[$char_id]; } elseif ($char_id <= 95) { $code_data[] = strpos($this->keys_a, $char); } else { @@ -327,7 +327,7 @@ protected function getCodeDataB( $char = $code[$pos]; $char_id = ord($char); if (($char_id >= 241) && ($char_id <= 244)) { - $code_data[] = $this->fnc_b[$char_id]; + $code_data[] = $this::FNC_B[$char_id]; } elseif (($char_id >= 32) && ($char_id <= 127)) { $code_data[] = strpos($this->keys_b, $char); } else { From e928f8340b760291c470e3af1924e5fb80932db9 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:40:32 +0000 Subject: [PATCH 035/100] fixes --- src/Type/Linear/CodeNineThree.php | 261 +++++++++++----------- src/Type/Linear/CodeThreeNineExtCheck.php | 4 +- 2 files changed, 132 insertions(+), 133 deletions(-) diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index 1f1630da..c583ff56 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -102,7 +102,136 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * * @var array */ - protected $extcodes = array(); + protected const EXTCODES = array( + "\83U", + "\80A", + "\80B", + "\80C", + "\80D", + "\80E", + "\80F", + "\80G", + "\80H", + "\80I", + "\80J", + "\80K", + "\80L", + "\80M", + "\80N", + "\80O", + "\80P", + "\80Q", + "\80R", + "\80S", + "\80T", + "\80U", + "\80V", + "\80W", + "\80X", + "\80Y", + "\80Z", + "\83A", + "\83B", + "\83C", + "\83D", + "\83E", + " ", + "\81A", + "\81B", + "\81C", + "\81D", + "\81E", + "\81F", + "\81G", + "\81H", + "\81I", + "\81J", + "\81K", + "\81L", + "-", + ".", + "\81O", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "\81Z", + "\83F", + "\83G", + "\83H", + "\83I", + "\83J", + "\83V", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "\83K", + "\83L", + "\83M", + "\83N", + "\83O", + "\83W", + "\82A", + "\82B", + "\82C", + "\82D", + "\82E", + "\82F", + "\82G", + "\82H", + "\82I", + "\82J", + "\82K", + "\82L", + "\82M", + "\82N", + "\82O", + "\82P", + "\82Q", + "\82R", + "\82S", + "\82T", + "\82U", + "\82V", + "\82W", + "\82X", + "\82Y", + "\82Z", + "\83P", + "\83Q", + "\83R", + "\83S", + "\83T" + ); /** * Characters used for checksum @@ -217,136 +346,6 @@ protected function getChecksum(string $code): string */ protected function setBars(): void { - $this->extcodes = array( - chr(131) . 'U', - chr(128) . 'A', - chr(128) . 'B', - chr(128) . 'C', - chr(128) . 'D', - chr(128) . 'E', - chr(128) . 'F', - chr(128) . 'G', - chr(128) . 'H', - chr(128) . 'I', - chr(128) . 'J', - chr(128) . 'K', - chr(128) . 'L', - chr(128) . 'M', - chr(128) . 'N', - chr(128) . 'O', - chr(128) . 'P', - chr(128) . 'Q', - chr(128) . 'R', - chr(128) . 'S', - chr(128) . 'T', - chr(128) . 'U', - chr(128) . 'V', - chr(128) . 'W', - chr(128) . 'X', - chr(128) . 'Y', - chr(128) . 'Z', - chr(131) . 'A', - chr(131) . 'B', - chr(131) . 'C', - chr(131) . 'D', - chr(131) . 'E', - ' ', - chr(129) . 'A', - chr(129) . 'B', - chr(129) . 'C', - chr(129) . 'D', - chr(129) . 'E', - chr(129) . 'F', - chr(129) . 'G', - chr(129) . 'H', - chr(129) . 'I', - chr(129) . 'J', - chr(129) . 'K', - chr(129) . 'L', - '-', - '.', - chr(129) . 'O', - '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - chr(129) . 'Z', - chr(131) . 'F', - chr(131) . 'G', - chr(131) . 'H', - chr(131) . 'I', - chr(131) . 'J', - chr(131) . 'V', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'G', - 'H', - 'I', - 'J', - 'K', - 'L', - 'M', - 'N', - 'O', - 'P', - 'Q', - 'R', - 'S', - 'T', - 'U', - 'V', - 'W', - 'X', - 'Y', - 'Z', - chr(131) . 'K', - chr(131) . 'L', - chr(131) . 'M', - chr(131) . 'N', - chr(131) . 'O', - chr(131) . 'W', - chr(130) . 'A', - chr(130) . 'B', - chr(130) . 'C', - chr(130) . 'D', - chr(130) . 'E', - chr(130) . 'F', - chr(130) . 'G', - chr(130) . 'H', - chr(130) . 'I', - chr(130) . 'J', - chr(130) . 'K', - chr(130) . 'L', - chr(130) . 'M', - chr(130) . 'N', - chr(130) . 'O', - chr(130) . 'P', - chr(130) . 'Q', - chr(130) . 'R', - chr(130) . 'S', - chr(130) . 'T', - chr(130) . 'U', - chr(130) . 'V', - chr(130) . 'W', - chr(130) . 'X', - chr(130) . 'Y', - chr(130) . 'Z', - chr(131) . 'P', - chr(131) . 'Q', - chr(131) . 'R', - chr(131) . 'S', - chr(131) . 'T' - ); $this->ncols = 0; $this->nrows = 1; $this->bars = array(); diff --git a/src/Type/Linear/CodeThreeNineExtCheck.php b/src/Type/Linear/CodeThreeNineExtCheck.php index 39bd755f..77093307 100644 --- a/src/Type/Linear/CodeThreeNineExtCheck.php +++ b/src/Type/Linear/CodeThreeNineExtCheck.php @@ -98,7 +98,7 @@ class CodeThreeNineExtCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected $extcodes = array( + protected const EXTCODES = array( '%U', '$A', '$B', '$C', '$D', '$E', '$F', '$G', '$H', '$I', '$J', '$K', @@ -163,7 +163,7 @@ protected function getExtendCode(string $code): string if ($item > 127) { throw new BarcodeException('Invalid character: chr(' . $item . ')'); } - $ext .= $this->extcodes[$item]; + $ext .= $this::EXTCODES[$item]; } return $ext; } From ff91a4e08c999bed263710a35637620e617e46e3 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:43:18 +0000 Subject: [PATCH 036/100] fixes --- src/Type/Linear/CodeNineThree.php | 14 +++++++------- src/Type/Linear/CodeThreeNineExtCheck.php | 6 +++--- src/Type/Linear/RoyalMailFourCc.php | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index c583ff56..ccec8c84 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -46,7 +46,7 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * * @var array */ - protected const CHBAR = array( + protected const CHBAR = [ 32 => '311211', // space 36 => '321111', // $ 37 => '211131', // % @@ -95,7 +95,7 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe 129 => '311121', // (/) 130 => '122211', // (+) 131 => '312111' // (%) - ); + ]; /** * Map for extended characters @@ -238,7 +238,7 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * * @var array */ - protected $chksum = array( + protected const CHKSUM = array( '0', '1', '2', @@ -304,7 +304,7 @@ protected function getChecksum(string $code): string $pck = 1; $check = 0; for ($idx = ($clen - 1); $idx >= 0; --$idx) { - $key = array_keys($this->chksum, $code[$idx]); + $key = array_keys($this::CHKSUM, $code[$idx]); $check += ($key[0] * $pck); ++$pck; if ($pck > 20) { @@ -312,13 +312,13 @@ protected function getChecksum(string $code): string } } $check %= 47; - $chk = $this->chksum[$check]; + $chk = $this::CHKSUM[$check]; $code .= $chk; // calculate check digit K $pck = 1; $check = 0; for ($idx = $clen; $idx >= 0; --$idx) { - $key = array_keys($this->chksum, $code[$idx]); + $key = array_keys($this::CHKSUM, $code[$idx]); $check += ($key[0] * $pck); ++$pck; if ($pck > 15) { @@ -326,7 +326,7 @@ protected function getChecksum(string $code): string } } $check %= 47; - $key = $this->chksum[$check]; + $key = $this::CHKSUM[$check]; $checksum = $chk . $key; // restore special characters $checksum = strtr( diff --git a/src/Type/Linear/CodeThreeNineExtCheck.php b/src/Type/Linear/CodeThreeNineExtCheck.php index 77093307..bed5d292 100644 --- a/src/Type/Linear/CodeThreeNineExtCheck.php +++ b/src/Type/Linear/CodeThreeNineExtCheck.php @@ -138,7 +138,7 @@ class CodeThreeNineExtCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected $chksum = array( + protected const CHKSUM = array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', @@ -180,11 +180,11 @@ protected function getChecksum(string $code): string $sum = 0; $clen = strlen($code); for ($chr = 0; $chr < $clen; ++$chr) { - $key = array_keys($this->chksum, $code[$chr]); + $key = array_keys($this::CHKSUM, $code[$chr]); $sum += $key[0]; } $idx = ($sum % 43); - return $this->chksum[$idx]; + return $this::CHKSUM[$idx]; } /** diff --git a/src/Type/Linear/RoyalMailFourCc.php b/src/Type/Linear/RoyalMailFourCc.php index b4601fd9..788a7499 100644 --- a/src/Type/Linear/RoyalMailFourCc.php +++ b/src/Type/Linear/RoyalMailFourCc.php @@ -90,7 +90,7 @@ class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected array $chksum = array( + protected const CHKSUM= array( '0' => '11', '1' => '12', '2' => '13', @@ -145,15 +145,15 @@ protected function getChecksum(string $code): int $len = strlen($code); for ($pos = 0; $pos < $len; ++$pos) { $char = $code[$pos]; - if (!isset($this->chksum[$char])) { + if (!isset($this::CHKSUM[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } - $row += intval($this->chksum[$char][0]); - $col += intval($this->chksum[$char][1]); + $row += intval($this::CHKSUM[$char][0]); + $col += intval($this::CHKSUM[$char][1]); } $row %= 6; $col %= 6; - $check = array_keys($this->chksum, $row . $col); + $check = array_keys($this::CHKSUM, $row . $col); return $check[0]; } From 7bdbaba49ce6342ae4e00446b7465ad8964065a7 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:45:12 +0000 Subject: [PATCH 037/100] fixes --- src/Type/Linear/EanFive.php | 2 +- src/Type/Linear/EanOneThree.php | 4 ++-- src/Type/Linear/EanTwo.php | 4 ++-- src/Type/Linear/UpcE.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Type/Linear/EanFive.php b/src/Type/Linear/EanFive.php index 2fde9da1..2fc18faa 100644 --- a/src/Type/Linear/EanFive.php +++ b/src/Type/Linear/EanFive.php @@ -53,7 +53,7 @@ class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo * * @var array> */ - protected array $parities = array( + protected const PARITIES = array( '0' => array('B','B','A','A','A'), '1' => array('B','A','B','A','A'), '2' => array('B','A','A','B','A'), diff --git a/src/Type/Linear/EanOneThree.php b/src/Type/Linear/EanOneThree.php index 354b5925..9b62325e 100644 --- a/src/Type/Linear/EanOneThree.php +++ b/src/Type/Linear/EanOneThree.php @@ -104,7 +104,7 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected array $parities = array( + protected const PARITIES = array( '0' => 'AAAAAA', '1' => 'AABABB', '2' => 'AABBAB', @@ -180,7 +180,7 @@ protected function setBars(): void $this::FORMATCode(); $seq = '101'; // left guard bar $half_len = intval(ceil($this->code_length / 2)); - $parity = $this->parities[$this->extcode[0]]; + $parity = $this::PARITIES[$this->extcode[0]]; for ($pos = 1; $pos < $half_len; ++$pos) { $seq .= $this::CHBAR[$parity[($pos - 1)]][$this->extcode[$pos]]; } diff --git a/src/Type/Linear/EanTwo.php b/src/Type/Linear/EanTwo.php index 8ae4f68c..b6a9d410 100644 --- a/src/Type/Linear/EanTwo.php +++ b/src/Type/Linear/EanTwo.php @@ -85,7 +85,7 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear * * @var array> */ - protected array $parities = array( + protected const PARITIES = array( '0' => array('A','A'), '1' => array('A','B'), '2' => array('B','A'), @@ -121,7 +121,7 @@ protected function setBars(): void { $this::FORMATCode(); $chk = $this->getChecksum($this->extcode); - $parity = $this->parities[$chk]; + $parity = $this::PARITIES[$chk]; $seq = '1011'; // left guard bar $seq .= $this::CHBAR[$parity[0]][$this->extcode[0]]; $len = strlen($this->extcode); diff --git a/src/Type/Linear/UpcE.php b/src/Type/Linear/UpcE.php index 9bb78e6f..3ec89de2 100644 --- a/src/Type/Linear/UpcE.php +++ b/src/Type/Linear/UpcE.php @@ -57,7 +57,7 @@ class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA * * @var array>> */ - protected array $parities = array( + protected const PARITIES = array( 0 => array( '0' => array('B','B','B','A','A','A'), '1' => array('B','B','A','B','A','A'), @@ -158,7 +158,7 @@ protected function setBars(): void $this::FORMATCode(); $upce_code = $this->convertUpcaToUpce($this->extcode); $seq = '101'; // left guard bar - $parity = $this->parities[$this->extcode[1]][$this->check]; + $parity = $this::PARITIES[$this->extcode[1]][$this->check]; for ($pos = 0; $pos < 6; ++$pos) { $seq .= $this::CHBAR[$parity[$pos]][$upce_code[$pos]]; } From 90188a5f9f37460b5573883efe6210ed297c3ae9 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:47:20 +0000 Subject: [PATCH 038/100] fixes --- src/Type/Linear/RoyalMailFourCc.php | 4 ++-- src/Type/Linear/StandardTwoOfFiveCheck.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Type/Linear/RoyalMailFourCc.php b/src/Type/Linear/RoyalMailFourCc.php index 788a7499..1b4aab27 100644 --- a/src/Type/Linear/RoyalMailFourCc.php +++ b/src/Type/Linear/RoyalMailFourCc.php @@ -46,7 +46,7 @@ class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected array $chbar = array( + protected const CHBAR = array( '0' => '3322', '1' => '3412', '2' => '3421', @@ -178,7 +178,7 @@ protected function getCoreBars(): void for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; for ($pos = 0; $pos < 4; ++$pos) { - switch ($this->chbar[$char][$pos]) { + switch ($this::CHBAR[$char][$pos]) { case '1': $this->bars[] = array($this->ncols, 0, 1, 2); break; diff --git a/src/Type/Linear/StandardTwoOfFiveCheck.php b/src/Type/Linear/StandardTwoOfFiveCheck.php index 35016cb2..dbdc99c6 100644 --- a/src/Type/Linear/StandardTwoOfFiveCheck.php +++ b/src/Type/Linear/StandardTwoOfFiveCheck.php @@ -46,7 +46,7 @@ class StandardTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected array $chbar = array( + protected const CHBAR = array( '0' => '10101110111010', '1' => '11101010101110', '2' => '10111010101110', @@ -108,10 +108,10 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($idx = 0; $idx < $clen; ++$idx) { $digit = $this->extcode[$idx]; - if (!isset($this->chbar[$digit])) { + if (!isset($this::CHBAR[$digit])) { throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')'); } - $seq .= $this->chbar[$digit]; + $seq .= $this::CHBAR[$digit]; } $seq .= '111010111'; $this->processBinarySequence($seq); From ad1a39656554ca105ccc6d23976f95a65dafdec6 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:50:41 +0000 Subject: [PATCH 039/100] fixes --- src/Type/Linear/CodeNineThree.php | 178 ++++++++++++++-------------- src/Type/Linear/CodeOneTwoEight.php | 2 +- 2 files changed, 90 insertions(+), 90 deletions(-) diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index ccec8c84..a82c29bd 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -103,54 +103,54 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * @var array */ protected const EXTCODES = array( - "\83U", - "\80A", - "\80B", - "\80C", - "\80D", - "\80E", - "\80F", - "\80G", - "\80H", - "\80I", - "\80J", - "\80K", - "\80L", - "\80M", - "\80N", - "\80O", - "\80P", - "\80Q", - "\80R", - "\80S", - "\80T", - "\80U", - "\80V", - "\80W", - "\80X", - "\80Y", - "\80Z", - "\83A", - "\83B", - "\83C", - "\83D", - "\83E", + "\x83U", + "\x80A", + "\x80B", + "\x80C", + "\x80D", + "\x80E", + "\x80F", + "\x80G", + "\x80H", + "\x80I", + "\x80J", + "\x80K", + "\x80L", + "\x80M", + "\x80N", + "\x80O", + "\x80P", + "\x80Q", + "\x80R", + "\x80S", + "\x80T", + "\x80U", + "\x80V", + "\x80W", + "\x80X", + "\x80Y", + "\x80Z", + "\x83A", + "\x83B", + "\x83C", + "\x83D", + "\x83E", " ", - "\81A", - "\81B", - "\81C", - "\81D", - "\81E", - "\81F", - "\81G", - "\81H", - "\81I", - "\81J", - "\81K", - "\81L", + "\x81A", + "\x81B", + "\x81C", + "\x81D", + "\x81E", + "\x81F", + "\x81G", + "\x81H", + "\x81I", + "\x81J", + "\x81K", + "\x81L", "-", ".", - "\81O", + "\x81O", "0", "1", "2", @@ -161,13 +161,13 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe "7", "8", "9", - "\81Z", - "\83F", - "\83G", - "\83H", - "\83I", - "\83J", - "\83V", + "\x81Z", + "\x83F", + "\x83G", + "\x83H", + "\x83I", + "\x83J", + "\x83V", "A", "B", "C", @@ -194,43 +194,43 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe "X", "Y", "Z", - "\83K", - "\83L", - "\83M", - "\83N", - "\83O", - "\83W", - "\82A", - "\82B", - "\82C", - "\82D", - "\82E", - "\82F", - "\82G", - "\82H", - "\82I", - "\82J", - "\82K", - "\82L", - "\82M", - "\82N", - "\82O", - "\82P", - "\82Q", - "\82R", - "\82S", - "\82T", - "\82U", - "\82V", - "\82W", - "\82X", - "\82Y", - "\82Z", - "\83P", - "\83Q", - "\83R", - "\83S", - "\83T" + "\x83K", + "\x83L", + "\x83M", + "\x83N", + "\x83O", + "\x83W", + "\x82A", + "\x82B", + "\x82C", + "\x82D", + "\x82E", + "\x82F", + "\x82G", + "\x82H", + "\x82I", + "\x82J", + "\x82K", + "\x82L", + "\x82M", + "\x82N", + "\x82O", + "\x82P", + "\x82Q", + "\x82R", + "\x82S", + "\x82T", + "\x82U", + "\x82V", + "\x82W", + "\x82X", + "\x82Y", + "\x82Z", + "\x83P", + "\x83Q", + "\x83R", + "\x83S", + "\x83T" ); /** diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index b4d208a3..da868b50 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -48,7 +48,7 @@ protected function setAsciiMaps(): void // 128B (Code Set B) - ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters $this->keys_b = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]' - . '^_`abcdefghijklmnopqrstuvwxyz{|}~' . chr(127); + . '^_`abcdefghijklmnopqrstuvwxyz{|}~' . "\x7F"; } /** From 9cf6898fdf6dc7713ff184be6cca29d9b27c87b7 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 16:57:10 +0000 Subject: [PATCH 040/100] fixes --- src/Type/Linear/CodeOneTwoEight.php | 18 ------------------ src/Type/Linear/CodeOneTwoEight/Process.php | 12 ++++++++---- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index da868b50..497f227d 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -34,23 +34,6 @@ */ class CodeOneTwoEight extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\Process { - /** - * Set the ASCII maps values - */ - protected function setAsciiMaps(): void - { - // 128A (Code Set A) - ASCII characters 00 to 95 (0-9, A-Z and control codes), special characters - $this->keys_a = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_' - . chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . chr(6) . chr(7) . chr(8) . chr(9) - . chr(10) . chr(11) . chr(12) . chr(13) . chr(14) . chr(15) . chr(16) . chr(17) . chr(18) . chr(19) - . chr(20) . chr(21) . chr(22) . chr(23) . chr(24) . chr(25) . chr(26) . chr(27) . chr(28) . chr(29) - . chr(30) . chr(31); - - // 128B (Code Set B) - ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters - $this->keys_b = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]' - . '^_`abcdefghijklmnopqrstuvwxyz{|}~' . "\x7F"; - } - /** * Get the coe point array * @@ -248,7 +231,6 @@ protected function processSequenceC( */ protected function setBars(): void { - $this->setAsciiMaps(); $code_data = $this->getCodeData(); $this->ncols = 0; $this->nrows = 1; diff --git a/src/Type/Linear/CodeOneTwoEight/Process.php b/src/Type/Linear/CodeOneTwoEight/Process.php index 1b3deb50..6390aceb 100644 --- a/src/Type/Linear/CodeOneTwoEight/Process.php +++ b/src/Type/Linear/CodeOneTwoEight/Process.php @@ -159,17 +159,21 @@ abstract class Process extends \Com\Tecnick\Barcode\Type\Linear /** * Map ASCII characters for code A (ASCII 00 - 95) + * // 128A (Code Set A) - ASCII characters 00 to 95 (0-9, A-Z and control codes), special characters * * @var string */ - protected string $keys_a = ''; + protected const KEYS_A = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_' + . "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; /** * Map ASCII characters for code B (ASCII 32 - 127) + * // 128B (Code Set B) - ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters * * @var string */ - protected string $keys_b = ''; + protected const KEYS_B = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]' + . '^_`abcdefghijklmnopqrstuvwxyz{|}~' . "\x7F"; /** * Map special FNC codes for Code Set A (FNC 1-4) @@ -301,7 +305,7 @@ protected function getCodeDataA( if (($char_id >= 241) && ($char_id <= 244)) { $code_data[] = $this::FNC_A[$char_id]; } elseif ($char_id <= 95) { - $code_data[] = strpos($this->keys_a, $char); + $code_data[] = strpos($this::KEYS_A, $char); } else { throw new BarcodeException('Invalid character sequence'); } @@ -329,7 +333,7 @@ protected function getCodeDataB( if (($char_id >= 241) && ($char_id <= 244)) { $code_data[] = $this::FNC_B[$char_id]; } elseif (($char_id >= 32) && ($char_id <= 127)) { - $code_data[] = strpos($this->keys_b, $char); + $code_data[] = strpos($this::KEYS_B, $char); } else { throw new BarcodeException('Invalid character sequence: ' . $char_id); } From 60b5923ae745b5b0b0c913144e95b618a5a929ad Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 17:05:53 +0000 Subject: [PATCH 041/100] fixes --- src/Type/Square/Aztec.php | 8 ++++---- src/Type/Square/Datamatrix.php | 31 +++++++++++++++++++---------- src/Type/Square/PdfFourOneSeven.php | 24 ++++++++++++---------- src/Type/Square/QrCode.php | 26 ++++++++++++------------ 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/src/Type/Square/Aztec.php b/src/Type/Square/Aztec.php index d9e52c61..0d3660f7 100644 --- a/src/Type/Square/Aztec.php +++ b/src/Type/Square/Aztec.php @@ -48,14 +48,14 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square * * @var int */ - protected $ecc = 33; + protected int $ecc = 33; /** * Encoding mode * * @var string */ - protected $hint = 'A'; + protected string $hint = 'A'; /** * Mode: @@ -64,7 +64,7 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square * * @var string */ - protected $mode = 'A'; + protected string $mode = 'A'; /** * Extended Channel Interpretation (ECI) code to be added at the beginning of the stream. @@ -74,7 +74,7 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square * * @var int */ - protected $eci = -1; + protected int $eci = -1; /** * Set extra (optional) parameters: diff --git a/src/Type/Square/Datamatrix.php b/src/Type/Square/Datamatrix.php index 59257029..35647a19 100644 --- a/src/Type/Square/Datamatrix.php +++ b/src/Type/Square/Datamatrix.php @@ -48,35 +48,35 @@ class Datamatrix extends \Com\Tecnick\Barcode\Type\Square * * @var array */ - protected $cdw = array(); + protected array $cdw = array(); /** * Binary grid * * @var array */ - protected $grid = array(); + protected array $grid = array(); /** * Datamatrix Encoding object * - * @var \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode + * @var Encode */ - protected $dmx; + protected Encode $dmx; /** * Datamatrix shape key (S=square, R=rectangular) * * @var string */ - protected $shape = 'S'; + protected string $shape = 'S'; /** * Datamatrix variant (N=default, GS1=FNC1 codeword in first place) * * @var bool */ - protected $gsonemode = false; + protected bool $gsonemode = false; /** * Set extra (optional) parameters: @@ -106,7 +106,7 @@ protected function setParameters(): void * * @throws BarcodeException in case of error */ - protected function addPadding($size, $ncw) + protected function addPadding(int $size, int $ncw): void { if ($size <= $ncw) { return; @@ -138,7 +138,7 @@ protected function addPadding($size, $ncw) * * @throws BarcodeException in case of error */ - protected function getCodewords() + protected function getCodewords(): array { if (strlen((string)$this->code) == 0) { throw new BarcodeException('Empty input'); @@ -177,7 +177,16 @@ protected function getCodewords() * @param int $rdri * @param int $rdci */ - protected function setGrid(&$idx, &$places, &$row, &$col, &$rdx, &$cdx, &$rdri, &$rdci) + protected function setGrid( + int &$idx, + array &$places, + int &$row, + int &$col, + int &$rdx, + int &$cdx, + int &$rdri, + int &$rdci + ): void { // braw bits by case if ($rdx == 0) { @@ -210,13 +219,13 @@ protected function setGrid(&$idx, &$places, &$row, &$col, &$rdx, &$cdx, &$rdri, /** * Get high level encoding using the minimum symbol data characters for ECC 200 * - * @param $data (string) data to encode + * @param string $data data to encode * * @return array of codewords * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function getHighLevelEncoding($data) + protected function getHighLevelEncoding(string $data): array { // STEP A. Start in ASCII encodation. $enc = Data::ENC_ASCII; // current encoding mode diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index 66d6ee48..98ec6970 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -59,28 +59,28 @@ class PdfFourOneSeven extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\C * * @var int */ - protected $row_height = 2; + protected int $row_height = 2; /** * Horizontal quiet zone in modules * * @var int */ - protected $quiet_vertical = 2; + protected int $quiet_vertical = 2; /** * Vertical quiet zone in modules * * @var int */ - protected $quiet_horizontal = 2; + protected int $quiet_horizontal = 2; /** * Aspect ratio (width / height) * * @var float */ - protected $aspectratio = 2; + protected float $aspectratio = 2; /** * Error correction level (0-8); @@ -88,14 +88,14 @@ class PdfFourOneSeven extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\C * * @var int */ - protected $ecl = -1; + protected int $ecl = -1; /** * Information for macro block * * @var array */ - protected $macro = array(); + protected array $macro = array(); /** * Set extra (optional) parameters @@ -121,7 +121,7 @@ protected function setParameters(): void /** * Set macro block parameter */ - protected function setMacroBlockParam() + protected function setMacroBlockParam(): void { if ( isset($this->params[4]) @@ -162,7 +162,7 @@ protected function setBars(): void * * @return array */ - protected function getMacroBlock(&$numcw) + protected function getMacroBlock(int &$numcw): array { if (empty($this->macro)) { return array(); @@ -212,7 +212,11 @@ protected function getMacroBlock(&$numcw) * * @throws BarcodeException in case of error */ - public function getCodewords(&$rows, &$cols, &$ecl) + public function getCodewords( + int &$rows, + int &$cols, + int &$ecl + ): array { $codewords = array(); // array of code-words // get the input sequence array @@ -278,7 +282,7 @@ public function getCodewords(&$rows, &$cols, &$ecl) * * @throws BarcodeException in case of error */ - public function getBinSequence() + public function getBinSequence(): string { $rows = 0; $cols = 0; diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 3dc994b6..9afbe6fc 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -52,28 +52,28 @@ class QrCode extends \Com\Tecnick\Barcode\Type\Square * * @var int */ - protected $version = 0; + protected int $version = 0; /** * Error correction level * * @var int */ - protected $level = 0; + protected int $level = 0; /** * Encoding mode * * @var int */ - protected $hint = 2; + protected int $hint = 2; /** * Boolean flag, if false the input string will be converted to uppercase. * - * @var boolean + * @var bool */ - protected $case_sensitive = true; + protected bool $case_sensitive = true; /** * If false, checks all masks available, @@ -81,7 +81,7 @@ class QrCode extends \Com\Tecnick\Barcode\Type\Square * * @var int|bool */ - protected $random_mask = false; + protected int|bool $random_mask = false; /** * If true, estimates best mask (spec. default, but extremally slow; @@ -89,21 +89,21 @@ class QrCode extends \Com\Tecnick\Barcode\Type\Square * * @var bool */ - protected $best_mask = true; + protected bool $best_mask = true; /** * Default mask used when $this->best_mask === false * * @var int */ - protected $default_mask = 2; + protected int $default_mask = 2; /** * ByteStream class object * - * @var \Com\Tecnick\Barcode\Type\Square\QrCode\ByteStream + * @var ByteStream */ - protected $bsObj; + protected ByteStream $bsObj; /** * Set extra (optional) parameters: @@ -190,7 +190,7 @@ protected function setBars(): void * * @return array frame in binary form */ - protected function binarize($frame) + protected function binarize(array $frame): array { $len = count($frame); // the frame is square (width = height) @@ -207,7 +207,7 @@ protected function binarize($frame) * * @param string $data input string to encode */ - protected function encodeString($data) + protected function encodeString(string $data): array { if (!$this->case_sensitive) { $data = $this->toUpper($data); @@ -232,7 +232,7 @@ protected function encodeString($data) * * @return string */ - protected function toUpper($data) + protected function toUpper(string $data): string { $len = strlen($data); $pos = 0; From 6612c2c74e065a16aaa9524f751cda2fc41e9538 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 17:11:59 +0000 Subject: [PATCH 042/100] fixes --- src/Type/Square/Aztec/Data.php | 28 ++++++++-------- src/Type/Square/Datamatrix/Data.php | 22 ++++++------- src/Type/Square/PdfFourOneSeven/Data.php | 10 +++--- src/Type/Square/QrCode/Data.php | 42 ++++++++++++------------ 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/Type/Square/Aztec/Data.php b/src/Type/Square/Aztec/Data.php index a516f1a6..024283be 100644 --- a/src/Type/Square/Aztec/Data.php +++ b/src/Type/Square/Aztec/Data.php @@ -36,37 +36,37 @@ class Data /** * Code character encoding mode for uppercase letters. */ - const MODE_UPPER = 0; + public const MODE_UPPER = 0; /** * Code character encoding mode for lowercase letters. */ - const MODE_LOWER = 1; + public const MODE_LOWER = 1; /** * Code character encoding mode for digits. */ - const MODE_DIGIT = 2; + public const MODE_DIGIT = 2; /** * Code character encoding mode for mixed cases. */ - const MODE_MIXED = 3; + public const MODE_MIXED = 3; /** * Code character encoding mode for punctuation. */ - const MODE_PUNCT = 4; + public const MODE_PUNCT = 4; /** * Code character encoding mode for binary. */ - const MODE_BINARY = 5; + public const MODE_BINARY = 5; /** * Number of bits for each character encoding mode. */ - const MODE_BITS = array( + public const MODE_BITS = array( 5, // 0 = MODE_UPPER 5, // 1 = MODE_LOWER 4, // 2 = MODE_DIGIT @@ -78,7 +78,7 @@ class Data /** * Code character encoding for each mode. */ - const CHAR_ENC = array( + public const CHAR_ENC = array( // MODE_UPPER (initial mode) 0 => array( 32 => 1, // ' ' (SP) @@ -224,7 +224,7 @@ class Data * - the carriage return '\r' character (13) that maps for modes 3,4. * - the comma ',' and dot '.' characters (44,46) that map for modes 2,4. */ - const CHAR_MODES = array( + public const CHAR_MODES = array( 1 => 3, // '^A' (SOH) 2 => 3, // '^B' (STX) 3 => 3, // '^C' (ETX) @@ -345,7 +345,7 @@ class Data * Latch map for changing character encoding mode. * Numbers represent: [number of bits to change, latch code value]. */ - const LATCH_MAP = array( + public const LATCH_MAP = array( // MODE_UPPER 0 => array ( 1 => array(array(5,28)), // -> LOWER @@ -387,7 +387,7 @@ class Data * Shift map for changing character encoding mode. * Numbers represent: [number of bits to change, shift code value]. */ - const SHIFT_MAP = array( + public const SHIFT_MAP = array( // MODE_UPPER 0 => array( 1 => array(), @@ -433,7 +433,7 @@ class Data /** * Extended Channel Interpretation (ECI) codes. */ - const ECI = array( + public const ECI = array( 0 => 'FNC1', // Function 1 character 2 => 'Cp437', // Code page 437 3 => 'ISO-8859-1', // ISO/IEC 8859-1 - Latin-1 (Default encoding) @@ -475,7 +475,7 @@ class Data * - 5: symbol data text capacity; * - 6: symbol data bytes capacity. */ - const SIZE_COMPACT = array( + public const SIZE_COMPACT = array( 1 => array(15, 17, 6, 102, 13, 12, 6), 2 => array(19, 40, 6, 240, 40, 33, 19), 3 => array(23, 51, 8, 408, 70, 57, 33), @@ -493,7 +493,7 @@ class Data * - 5: symbol data text capacity; * - 6: symbol data bytes capacity. */ - const SIZE_FULL = array( + public const SIZE_FULL = array( 1 => array( 19, 21, 6, 126, 18, 15, 8), 2 => array( 23, 48, 6, 288, 49, 40, 24), 3 => array( 27, 60, 8, 480, 84, 68, 40), diff --git a/src/Type/Square/Datamatrix/Data.php b/src/Type/Square/Datamatrix/Data.php index 9169117d..8f7f9515 100644 --- a/src/Type/Square/Datamatrix/Data.php +++ b/src/Type/Square/Datamatrix/Data.php @@ -36,42 +36,42 @@ class Data /** * ASCII encoding: ASCII character 0 to 127 (1 byte per CW) */ - const ENC_ASCII = 0; + public const ENC_ASCII = 0; /** * C40 encoding: Upper-case alphanumeric (3/2 bytes per CW) */ - const ENC_C40 = 1; + public const ENC_C40 = 1; /** * TEXT encoding: Lower-case alphanumeric (3/2 bytes per CW) */ - const ENC_TXT = 2; + public const ENC_TXT = 2; /** * X12 encoding: ANSI X12 (3/2 byte per CW) */ - const ENC_X12 = 3; + public const ENC_X12 = 3; /** * EDIFACT encoding: ASCII character 32 to 94 (4/3 bytes per CW) */ - const ENC_EDF = 4; + public const ENC_EDF = 4; /** * BASE 256 encoding: ASCII character 0 to 255 (1 byte per CW) */ - const ENC_BASE256 = 5; + public const ENC_BASE256 = 5; /** * ASCII extended encoding: ASCII character 128 to 255 (1/2 byte per CW) */ - const ENC_ASCII_EXT = 6; + public const ENC_ASCII_EXT = 6; /** * ASCII number encoding: ASCII digits (2 bytes per CW) */ - const ENC_ASCII_NUM = 7; + public const ENC_ASCII_NUM = 7; /** * Table of Data Matrix ECC 200 Symbol Attributes: @@ -94,7 +94,7 @@ class Data *
  • error codewords per block
  • * */ - const SYMBATTR = array( + public const SYMBATTR = array( 'S' => array( // square form // 10x10 array( @@ -674,7 +674,7 @@ class Data /** * Map encodation modes whit character sets. */ - const CHSET_ID = array( + public const CHSET_ID = array( self::ENC_C40 => 'C40', self::ENC_TXT => 'TXT', self::ENC_X12 => 'X12' @@ -683,7 +683,7 @@ class Data /** * Basic set of characters for each encodation mode. */ - const CHSET = array( + public const CHSET = array( 'C40' => array( // Basic set for C40 'S1' => 0x00, 'S2' => 0x01, diff --git a/src/Type/Square/PdfFourOneSeven/Data.php b/src/Type/Square/PdfFourOneSeven/Data.php index 0068118c..2b1834c0 100644 --- a/src/Type/Square/PdfFourOneSeven/Data.php +++ b/src/Type/Square/PdfFourOneSeven/Data.php @@ -34,17 +34,17 @@ abstract class Data /** * Start pattern */ - const START_PATTERN = '11111111010101000'; + public const START_PATTERN = '11111111010101000'; /** * Stop pattern */ - const STOP_PATTERN = '111111101000101001'; + public const STOP_PATTERN = '111111101000101001'; /** * Array of text Compaction Sub-Modes (values 0xFB - 0xFF are used for submode changers) */ - const TEXT_SUB_MODES = array( + public const TEXT_SUB_MODES = array( array( // Alpha 0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a, 0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54, @@ -70,7 +70,7 @@ abstract class Data /** * Array of switching codes for Text Compaction Sub-Modes */ - const TEXT_LATCH = array( + public const TEXT_LATCH = array( '01' => array(27), '02' => array(28), '03' => array(28,25), @@ -106,7 +106,7 @@ abstract class Data * 927 : Identifier for an ECI of a character set or code page * 928 : Macro marker codeword to indicate the beginning of a Macro PDF Control Block */ - const CLUSTERS = array( + public const CLUSTERS = array( array( // cluster 0 ----------------------------------------------------------------------- 0x1d5c0,0x1eaf0,0x1f57c,0x1d4e0,0x1ea78,0x1f53e,0x1a8c0,0x1d470,0x1a860,0x15040, // 10 0x1a830,0x15020,0x1adc0,0x1d6f0,0x1eb7c,0x1ace0,0x1d678,0x1eb3e,0x158c0,0x1ac70, // 20 diff --git a/src/Type/Square/QrCode/Data.php b/src/Type/Square/QrCode/Data.php index c159b9cb..841ccf63 100644 --- a/src/Type/Square/QrCode/Data.php +++ b/src/Type/Square/QrCode/Data.php @@ -36,34 +36,34 @@ class Data /** * Maximum QR Code version. */ - const QRSPEC_VERSION_MAX = 40; + public const QRSPEC_VERSION_MAX = 40; /** * Maximum matrix size for maximum version (version 40 is 177*177 matrix). */ - const QRSPEC_WIDTH_MAX = 177; + public const QRSPEC_WIDTH_MAX = 177; // ----------------------------------------------------- /** * Matrix index to get width from CAPACITY array. */ - const QRCAP_WIDTH = 0; + public const QRCAP_WIDTH = 0; /** * Matrix index to get number of words from CAPACITY array. */ - const QRCAP_WORDS = 1; + public const QRCAP_WORDS = 1; /** * Matrix index to get remainder from CAPACITY array. */ - const QRCAP_REMINDER = 2; + public const QRCAP_REMINDER = 2; /** * Matrix index to get error correction level from CAPACITY array. */ - const QRCAP_EC = 3; + public const QRCAP_EC = 3; // ----------------------------------------------------- @@ -72,12 +72,12 @@ class Data /** * Number of header bits for structured mode */ - const STRUCTURE_HEADER_BITS = 20; + public const STRUCTURE_HEADER_BITS = 20; /** * Max number of symbols for structured mode */ - const MAX_STRUCTURED_SYMBOLS = 16; + public const MAX_STRUCTURED_SYMBOLS = 16; // ----------------------------------------------------- @@ -86,23 +86,23 @@ class Data /** * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column) */ - const N1 = 3; + public const N1 = 3; /** * Down point base value for case 2 mask pattern (module block of same color) */ - const N2 = 3; + public const N2 = 3; /** * Down point base value for case 3 mask pattern * (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column) */ - const N3 = 40; + public const N3 = 40; /** * Down point base value for case 4 mask pattern (ration of dark modules in whole) */ - const N4 = 10; + public const N4 = 10; /** * Encoding modes (characters which can be encoded in QRcode) @@ -114,7 +114,7 @@ class Data * KJ : Encoding mode KANJI. A KANJI character (multibyte character) is encoded to 13bit length. * ST : Encoding mode STRUCTURED */ - const ENC_MODES = array('NL' => -1, 'NM' => 0, 'AN' => 1, '8B' => 2, 'KJ' => 3, 'ST' => 4); + public const ENC_MODES = array('NL' => -1, 'NM' => 0, 'AN' => 1, '8B' => 2, 'KJ' => 3, 'ST' => 4); /** * Array of valid error correction levels @@ -125,12 +125,12 @@ class Data * Q : About 25% or less errors can be corrected. * H : About 30% or less errors can be corrected. */ - const ECC_LEVELS = array('L' => 0, 'M' => 1, 'Q' => 2, 'H' => 3); + public const ECC_LEVELS = array('L' => 0, 'M' => 1, 'Q' => 2, 'H' => 3); /** * Alphabet-numeric conversion table. */ - const AN_TABLE = array( + public const AN_TABLE = array( -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, // @@ -145,7 +145,7 @@ class Data * Array Table of the capacity of symbols. * See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004. */ - const CAPACITY = array( + public const CAPACITY = array( array( 0, 0, 0, array( 0, 0, 0, 0)), // array( 21, 26, 0, array( 7, 10, 13, 17)), // 1 array( 25, 44, 7, array( 10, 16, 22, 28)), // @@ -192,7 +192,7 @@ class Data /** * Array Length indicator. */ - const LEN_TABLE_BITS = array( + public const LEN_TABLE_BITS = array( array(10, 12, 14), array( 9, 11, 13), array( 8, 16, 16), @@ -203,7 +203,7 @@ class Data * Array Table of the error correction code (Reed-Solomon block). * See Table 12-16 (pp.30-36), JIS X0510:2004. */ - const ECC_TABLE = array( + public const ECC_TABLE = array( array(array( 0, 0), array( 0, 0), array( 0, 0), array( 0, 0)), // array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // 1 array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // @@ -253,7 +253,7 @@ class Data * Rest of them can be calculated from the distance between them. * See Table 1 in Appendix E (pp.71) of JIS X0510:2004. */ - const ALIGN_PATTERN = array( + public const ALIGN_PATTERN = array( array( 0, 0), array( 0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5 array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10 @@ -270,7 +270,7 @@ class Data * See Table 1 in Appendix D (pp.68) of JIS X0510:2004. * size: [QRSPEC_VERSION_MAX - 6] */ - const VERSION_PATTERN = array( + public const VERSION_PATTERN = array( 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, // 0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, // 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, // @@ -281,7 +281,7 @@ class Data /** * Array Format information */ - const FORMAT_INFO = array( + public const FORMAT_INFO = array( array(0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976), // array(0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0), // array(0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed), // From 7f9cd979ee0b1fd88371e86a40ab17b4a2c55f07 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 17:19:31 +0000 Subject: [PATCH 043/100] fixes --- .../Square/PdfFourOneSeven/Compaction.php | 30 +++++++++++++------ src/Type/Square/PdfFourOneSeven/Sequence.php | 8 ++--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Type/Square/PdfFourOneSeven/Compaction.php b/src/Type/Square/PdfFourOneSeven/Compaction.php index 27fe8d3d..a5d0e5ae 100644 --- a/src/Type/Square/PdfFourOneSeven/Compaction.php +++ b/src/Type/Square/PdfFourOneSeven/Compaction.php @@ -45,7 +45,15 @@ abstract class Compaction extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSev * @param int $idx * @param int $codelen */ - protected function processTextCompactionSub(&$txtarr, &$submode, $sub, $code, $key, $idx, $codelen) + protected function processTextCompactionSub( + array &$txtarr, + int &$submode, + int $sub, + string $code, + int $key, + int $idx, + int $codelen + ): void { // $sub is the new submode if ( @@ -75,9 +83,9 @@ protected function processTextCompactionSub(&$txtarr, &$submode, $sub, $code, $k * Process Text Compaction * * @param string $code Data to compact - * @param string $codewords Codewords + * @param array $codewords Codewords */ - protected function processTextCompaction($code, &$codewords) + protected function processTextCompaction(string $code, array &$codewords): void { $submode = 0; // default Alpha sub-mode $txtarr = array(); // array of characters and sub-mode switching characters @@ -114,9 +122,9 @@ protected function processTextCompaction($code, &$codewords) * Process Byte Compaction * * @param string $code Data to compact - * @param string $codewords Codewords + * @param array $codewords Codewords */ - protected function processByteCompaction($code, &$codewords) + protected function processByteCompaction(string $code, array &$codewords): void { while (($codelen = strlen($code)) > 0) { if ($codelen > 6) { @@ -157,9 +165,9 @@ protected function processByteCompaction($code, &$codewords) * Process Numeric Compaction * * @param string $code Data to compact - * @param string $codewords Codewords + * @param array $codewords Codewords */ - protected function processNumericCompaction($code, &$codewords) + protected function processNumericCompaction(string $code, array &$codewords): void { while (($codelen = strlen($code)) > 0) { $rest = ''; @@ -182,11 +190,15 @@ protected function processNumericCompaction($code, &$codewords) * * @param int $mode Compaction mode number * @param string $code Data to compact - * @param boolean $addmode If true add the mode codeword in the first position + * @param bool $addmode If true add the mode codeword in the first position * * @return array of codewords */ - protected function getCompaction($mode, $code, $addmode = true) + protected function getCompaction( + int $mode, + string $code, + bool $addmode = true + ): array { $codewords = array(); // array of codewords to return switch ($mode) { diff --git a/src/Type/Square/PdfFourOneSeven/Sequence.php b/src/Type/Square/PdfFourOneSeven/Sequence.php index 36f514f5..f82183ef 100644 --- a/src/Type/Square/PdfFourOneSeven/Sequence.php +++ b/src/Type/Square/PdfFourOneSeven/Sequence.php @@ -42,7 +42,7 @@ abstract class Sequence extends \Com\Tecnick\Barcode\Type\Square * * @return int error correction level */ - protected function getErrorCorrectionLevel($ecl, $numcw) + protected function getErrorCorrectionLevel(int $ecl, int $numcw): int { $maxecl = 8; // maximum error level $maxerrsize = (928 - $numcw); // available codewords for error @@ -73,7 +73,7 @@ protected function getErrorCorrectionLevel($ecl, $numcw) * * @return array of error correction codewords */ - protected function getErrorCorrection($codewords, $ecl) + protected function getErrorCorrection(array $codewords, int $ecl): array { // get error correction coefficients $ecc = Data::RS_FACTORS[$ecl]; @@ -111,7 +111,7 @@ protected function getErrorCorrection($codewords, $ecl) * @param int $seq Current sequence * @param int $offset Current code offset */ - protected function processSequence(&$sequence_array, $code, $seq, $offset) + protected function processSequence(array &$sequence_array, string $code, int $seq, int $offset): void { // extract text sequence before the number sequence $prevseq = substr($code, $offset, ($seq - $offset)); @@ -155,7 +155,7 @@ protected function processSequence(&$sequence_array, $code, $seq, $offset) * * @return array */ - protected function getInputSequences($code) + protected function getInputSequences(string $code): array { $sequence_array = array(); // array to be returned $numseq = array(); From 42edc73b3bf6a2af421e9906b72dd805b00dd634 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 17:32:03 +0000 Subject: [PATCH 044/100] fixes --- src/Type/Square/Aztec/Bitstream.php | 49 ++++++++++++++++++----- src/Type/Square/Aztec/Codeword.php | 49 ++++++++++++++--------- src/Type/Square/Aztec/Encode.php | 33 ++++++++++----- src/Type/Square/Aztec/ErrorCorrection.php | 28 ++++++------- src/Type/Square/Aztec/Layers.php | 14 +++---- 5 files changed, 111 insertions(+), 62 deletions(-) diff --git a/src/Type/Square/Aztec/Bitstream.php b/src/Type/Square/Aztec/Bitstream.php index bbb9ebf9..b567fb01 100644 --- a/src/Type/Square/Aztec/Bitstream.php +++ b/src/Type/Square/Aztec/Bitstream.php @@ -43,7 +43,11 @@ abstract class Bitstream extends \Com\Tecnick\Barcode\Type\Square\Aztec\Layers * @param int $eci The ECI mode to use. * @param string $hint The mode to use. */ - protected function highLevelEncoding($code, $eci = 0, $hint = 'A') + protected function highLevelEncoding( + string $code, + int $eci = 0, + string $hint = 'A' + ): void { $this->addFLG($eci); $chars = array_values(unpack('C*', $code)); @@ -61,7 +65,7 @@ protected function highLevelEncoding($code, $eci = 0, $hint = 'A') * @param array $chars Integer ASCII values of the characters to encode. * @param int $chrlen Lenght of the $chars array. */ - protected function binaryEncode($chars, $chrlen) + protected function binaryEncode(array $chars, int $chrlen): void { $bits = Data::MODE_BITS[Data::MODE_BINARY]; $this->addShift(Data::MODE_BINARY); @@ -97,7 +101,7 @@ protected function binaryEncode($chars, $chrlen) * @param array $chars Integer ASCII values of the characters to encode. * @param int $chrlen Lenght of the $chars array. */ - protected function autoEncode($chars, $chrlen) + protected function autoEncode(array $chars, int $chrlen): void { $idx = 0; while ($idx < $chrlen) { @@ -118,7 +122,7 @@ protected function autoEncode($chars, $chrlen) * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. */ - protected function processModeChars(&$chars, &$idx, $chrlen) + protected function processModeChars(array &$chars, int &$idx, int $chrlen): void { $ord = $chars[$idx]; if ($this->isSameMode($this->encmode, $ord)) { @@ -148,7 +152,12 @@ protected function processModeChars(&$chars, &$idx, $chrlen) * * @return int */ - protected function countModeChars(&$chars, $idx, $chrlen, $mode) + protected function countModeChars( + array &$chars, + int $idx, + int $chrlen, + int $mode + ): int { $this->tmpCdws = array(); $nbits = Data::MODE_BITS[$mode]; @@ -177,7 +186,11 @@ protected function countModeChars(&$chars, $idx, $chrlen, $mode) * * @return bool True if binary characters have been found and processed. */ - protected function processBinaryChars(&$chars, &$idx, $chrlen) + protected function processBinaryChars( + array &$chars, + int &$idx, + int $chrlen + ): bool { $binchrs = $this->countBinaryChars($chars, $idx, $chrlen); if ($binchrs == 0) { @@ -226,7 +239,11 @@ protected function processBinaryChars(&$chars, &$idx, $chrlen) * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function countBinaryChars(&$chars, $idx, $chrlen) + protected function countBinaryChars( + array &$chars, + int $idx, + int $chrlen + ): int { $this->tmpCdws = array(); $count = 0; @@ -254,7 +271,11 @@ protected function countBinaryChars(&$chars, $idx, $chrlen) * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function processPunctPairs(&$chars, &$idx, $chrlen) + protected function processPunctPairs( + array &$chars, + int &$idx, + int $chrlen + ): bool { $ppairs = $this->countPunctPairs($chars, $idx, $chrlen); @@ -301,7 +322,11 @@ protected function processPunctPairs(&$chars, &$idx, $chrlen) * * @return int */ - protected function countPunctPairs(&$chars, $idx, $chrlen) + protected function countPunctPairs( + array &$chars, + int $idx, + int $chrlen + ): int { $this->tmpCdws = array(); $pairs = 0; @@ -328,7 +353,11 @@ protected function countPunctPairs(&$chars, $idx, $chrlen) * * @return array */ - protected function countPunctAndDigitChars(&$chars, $idx, $chrlen) + protected function countPunctAndDigitChars( + array &$chars, + int $idx, + int $chrlen + ): array { $words = array(); while ($idx < $chrlen) { diff --git a/src/Type/Square/Aztec/Codeword.php b/src/Type/Square/Aztec/Codeword.php index bf6d377b..425c7272 100644 --- a/src/Type/Square/Aztec/Codeword.php +++ b/src/Type/Square/Aztec/Codeword.php @@ -39,35 +39,35 @@ abstract class Codeword * * @var int */ - protected $encmode = Data::MODE_UPPER; + protected int $encmode = Data::MODE_UPPER; /** * Array containing the high-level encoding bitstream. * * @var array */ - protected $bitstream = array(); + protected array $bitstream = array(); /** * Temporary array of codewords. * * @var array */ - protected $tmpCdws = array(); + protected array $tmpCdws = array(); /** * Array of data words. * * @var array */ - protected $words = array(); + protected array $words = array(); /** * Count the total number of bits in the bitstream. * * @var int */ - protected $totbits = 0; + protected int $totbits = 0; /** * Encodes a character using the specified mode and ordinal value. @@ -77,7 +77,7 @@ abstract class Codeword * * @return int The encoded character. */ - protected function charEnc($mode, $ord) + protected function charEnc(int $mode, int $ord): int { return array_key_exists($ord, DATA::CHAR_ENC[$mode]) ? DATA::CHAR_ENC[$mode][$ord] : 0; } @@ -89,7 +89,7 @@ protected function charEnc($mode, $ord) * * @return int The character mode. */ - protected function charMode($ord) + protected function charMode(int $ord): int { return array_key_exists($ord, DATA::CHAR_MODES) ? DATA::CHAR_MODES[$ord] : Data::MODE_BINARY; } @@ -102,7 +102,7 @@ protected function charMode($ord) * * @return bool Returns true if the mode is the same as the ordinal value, false otherwise. */ - protected function isSameMode($mode, $ord) + protected function isSameMode(int $mode, int $ord): bool { return ( ($mode == $this->charMode($ord)) @@ -119,7 +119,7 @@ protected function isSameMode($mode, $ord) * * @return bool */ - protected function isPunctAndDigitChar($ord) + protected function isPunctAndDigitChar(int $ord): bool { return (($ord == 32) || ($ord == 44) || ($ord == 46)); } @@ -133,7 +133,7 @@ protected function isPunctAndDigitChar($ord) * * @return int */ - protected function punctPairMode($ord, $next) + protected function punctPairMode(int $ord, int $next): int { $key = (($ord << 8) + $next); switch ($key) { @@ -157,7 +157,12 @@ protected function punctPairMode($ord, $next) * @param int $wsize The number of bits in the codeword. * @param int $value The value of the codeword. */ - protected function appendWordToBitstream(array &$bitstream, &$totbits, $wsize, $value) + protected function appendWordToBitstream( + array &$bitstream, + int &$totbits, + int $wsize, + int $value + ): VOID { for ($idx = ($wsize - 1); $idx >= 0; $idx--) { $bitstream[] = (($value >> $idx) & 1); @@ -174,7 +179,11 @@ protected function appendWordToBitstream(array &$bitstream, &$totbits, $wsize, $ * * @return array */ - protected function bitstreamToWords(array $bitstream, $totbits, $wsize) + protected function bitstreamToWords( + array $bitstream, + int $totbits, + int $wsize + ): array { $words = array(); $numwords = intval(ceil($totbits / $wsize)); @@ -197,7 +206,7 @@ protected function bitstreamToWords(array $bitstream, $totbits, $wsize) * @param int $bits The number of bits in the codeword. * @param int $value The value of the codeword. */ - protected function addRawCwd($bits, $value) + protected function addRawCwd(int $bits, int $value): void { $this->appendWordToBitstream($this->bitstream, $this->totbits, $bits, $value); } @@ -208,7 +217,7 @@ protected function addRawCwd($bits, $value) * @param int $mode The encoding mode. * @param int $value The value to encode. */ - protected function addCdw($mode, $value) + protected function addCdw(int $mode, int $value): void { $this->addRawCwd(Data::MODE_BITS[$mode], $value); } @@ -218,7 +227,7 @@ protected function addCdw($mode, $value) * * @param int $mode The new encoding mode. */ - protected function addLatch($mode) + protected function addLatch(int $mode): void { $latch = Data::LATCH_MAP[$this->encmode][$mode]; foreach ($latch as $cdw) { @@ -230,7 +239,7 @@ protected function addLatch($mode) /** * Shift to another mode. */ - protected function addShift($mode) + protected function addShift(int $mode): void { $shift = Data::SHIFT_MAP[$this->encmode][$mode]; foreach ($shift as $cdw) { @@ -244,7 +253,7 @@ protected function addShift($mode) * * @param int $mode The encoding mode for the codewords. */ - protected function mergeTmpCwdWithShift($mode) + protected function mergeTmpCwdWithShift(int $mode): void { foreach ($this->tmpCdws as $item) { $this->addShift($mode); @@ -256,7 +265,7 @@ protected function mergeTmpCwdWithShift($mode) * Merges the temporary codewords array with the current codewords array. * No shift is performed. */ - protected function mergeTmpCwdRaw() + protected function mergeTmpCwdRaw(): void { foreach ($this->tmpCdws as $item) { $this->addRawCwd($item[0], $item[1]); @@ -269,7 +278,7 @@ protected function mergeTmpCwdRaw() * @param int $mode The encoding mode to use for merging codewords. * If negative, the current encoding mode will be used. */ - protected function mergeTmpCwd($mode = -1) + protected function mergeTmpCwd(int $mode = -1): void { if (($mode < 0) || ($this->encmode == $mode)) { $this->mergeTmpCwdRaw(); @@ -284,7 +293,7 @@ protected function mergeTmpCwd($mode = -1) * * @param int $eci Extended Channel Interpretation value. If negative, the function does nothing. */ - protected function addFLG($eci) + protected function addFLG(int $eci): void { if ($eci < 0) { return; diff --git a/src/Type/Square/Aztec/Encode.php b/src/Type/Square/Aztec/Encode.php index bf8de3bb..9acb922a 100644 --- a/src/Type/Square/Aztec/Encode.php +++ b/src/Type/Square/Aztec/Encode.php @@ -40,14 +40,14 @@ class Encode extends \Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream * * @var array */ - protected $grid = array(); + protected array $grid = array(); /** * Coordinate of the grid center. * * @var int */ - protected $gridcenter = 0; + protected int $gridcenter = 0; /** * Aztec main encoder. @@ -58,7 +58,13 @@ class Encode extends \Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream * @param string $hint The mode to use. * @param string $mode The mode to use (A = Automatic; F = Full Range mode). */ - public function __construct($code, $ecc = 33, $eci = 0, $hint = 'A', $mode = 'A') + public function __construct( + string $code, + int $ecc = 33, + int $eci = 0, + string $hint = 'A', + string $mode = 'A' + ) { $this->highLevelEncoding($code, $eci, $hint); if (!$this->sizeAndBitStuffing($ecc, $mode)) { @@ -77,7 +83,7 @@ public function __construct($code, $ecc = 33, $eci = 0, $hint = 'A', $mode = 'A' * * @return array */ - public function getGrid() + public function getGrid(): array { return $this->grid; } @@ -92,7 +98,12 @@ public function getGrid() * * @return int The number of data codewords. */ - protected function addCheckWords(array &$bitstream, &$totbits, $nbits, $wsize) + protected function addCheckWords( + array &$bitstream, + int &$totbits, + int $nbits, + int $wsize + ): int { $cdw = $this->bitstreamToWords($bitstream, $totbits, $wsize); $numcdw = count($cdw); @@ -110,7 +121,7 @@ protected function addCheckWords(array &$bitstream, &$totbits, $nbits, $wsize) /** * Initialize the grid with all patterns. */ - protected function setGrid() + protected function setGrid(): void { // initialize grid $size = $this->layer[0]; @@ -193,7 +204,7 @@ protected function setGrid() * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - protected function drawMode($numcdw) + protected function drawMode(int $numcdw): void { $modebs = array(); $nbits = 0; @@ -258,7 +269,7 @@ protected function drawMode($numcdw) * * @return int */ - protected function popBit(&$bit) + protected function popBit(int &$bit): int { return (empty($this->bitstream[$bit--]) ? 0 : 1); } @@ -271,7 +282,7 @@ protected function popBit(&$bit) * * @return int */ - protected function skipModeRefGrid($pos) + protected function skipModeRefGrid(int $pos): int { return intval((!$this->compact) && ($pos == 5)); } @@ -284,7 +295,7 @@ protected function skipModeRefGrid($pos) * * @return int */ - protected function skipRefGrid($pos) + protected function skipRefGrid(int $pos): int { return intval((!$this->compact) && (($pos % 16) == 0)); } @@ -292,7 +303,7 @@ protected function skipRefGrid($pos) /** * Draw the data bitstream in the grid in Full mode. */ - protected function drawData() + protected function drawData(): void { $center = $this->gridcenter; $llen = 16; // width of the first layer side diff --git a/src/Type/Square/Aztec/ErrorCorrection.php b/src/Type/Square/Aztec/ErrorCorrection.php index 73566c23..0ecd0e5e 100644 --- a/src/Type/Square/Aztec/ErrorCorrection.php +++ b/src/Type/Square/Aztec/ErrorCorrection.php @@ -36,7 +36,7 @@ class ErrorCorrection /** * Galois Field primitive by word size. */ - const GF = array( + protected const GF = array( 4 => 19, // 10011 GF(16) (x^4 + x + 1) Mode message 6 => 67, // 1000011 GF(64) (x^6 + x + 1) 01–02 layers 8 => 301, // 100101101 GF(256) (x^8 + x^5 + x^3 + x^2 + 1) 03–08 layers @@ -48,7 +48,7 @@ class ErrorCorrection * Map the log and exp (inverse log) tables by word size. * NOTE: It is equal to 2^word_size. */ - const TSIZE = array( + protected const TSIZE = array( 4 => 16, 6 => 64, 8 => 256, @@ -59,24 +59,24 @@ class ErrorCorrection /** * Log table. */ - protected $tlog = array(); + protected array $tlog = array(); /** * Exponential (inverse log) table. */ - protected $texp = array(); + protected array $texp = array(); /** * Size of the log and exp tables. */ - protected $tsize = 0; + protected int $tsize = 0; /** * Initialize the the Reed-Solomon Error Correction. * * @param int $wsize Size of a word in bits. */ - public function __construct($wsize) + public function __construct(int $wsize) { $this->genTables($wsize); } @@ -89,7 +89,7 @@ public function __construct($wsize) * * @return array */ - public function checkwords(array $data, $necc) + public function checkwords(array $data, int $necc): array { $coeff = $this->getCoefficients($data, $necc); return array_pad($coeff, -$necc, 0); @@ -100,7 +100,7 @@ public function checkwords(array $data, $necc) * * @param int $wsize Size of the word in bits. */ - protected function genTables($wsize) + protected function genTables(int $wsize): void { $this->tsize = self::TSIZE[$wsize]; $this->tlog = array_fill(0, $this->tsize, 0); @@ -129,7 +129,7 @@ protected function genTables($wsize) * * @return array Array of coefficients. */ - protected function getCoefficients(array $data, $necc) + protected function getCoefficients(array $data, int $necc): array { $gen = array(1); for ($idx = 1; $idx <= $necc; $idx++) { @@ -155,7 +155,7 @@ protected function getCoefficients(array $data, $necc) * * @return array */ - protected function multiplyCoeff(array $acf, array $bcf) + protected function multiplyCoeff(array $acf, array $bcf): array { $alen = count($acf); $blen = count($bcf); @@ -176,7 +176,7 @@ protected function multiplyCoeff(array $acf, array $bcf) * * @return int */ - protected function multiply($aval, $bval) + protected function multiply(int $aval, int $bval): int { if ($aval == 0 || $bval == 0) { return 0; @@ -191,7 +191,7 @@ protected function multiply($aval, $bval) * * @return array */ - protected function trimCoefficients($coeff) + protected function trimCoefficients(array $coeff): array { while (!empty($coeff) && $coeff[0] == 0) { array_shift($coeff); @@ -208,7 +208,7 @@ protected function trimCoefficients($coeff) * * @return array */ - protected function multiplyByMonomial(array $coeff, $mon, $deg) + protected function multiplyByMonomial(array $coeff, int $mon, int $deg): array { // if ($mon == 0) { // return array(0); @@ -229,7 +229,7 @@ protected function multiplyByMonomial(array $coeff, $mon, $deg) * * @return array */ - protected function addOrSubtract(array $smaller, array $larger) + protected function addOrSubtract(array $smaller, array $larger): array { // if ($smaller[0] == 0) { // return $larger; diff --git a/src/Type/Square/Aztec/Layers.php b/src/Type/Square/Aztec/Layers.php index 3330cb28..adc1d533 100644 --- a/src/Type/Square/Aztec/Layers.php +++ b/src/Type/Square/Aztec/Layers.php @@ -39,21 +39,21 @@ abstract class Layers extends \Com\Tecnick\Barcode\Type\Square\Aztec\Codeword * * @var bool */ - protected $compact = true; + protected bool $compact = true; /** * Number of data layers. * * @var int */ - protected $numlayers = 0; + protected int $numlayers = 0; /** * Size data for the selected layer. * * @var array */ - protected $layer = array(); + protected array $layer = array(); /** * Returns the minimum number of layers required. @@ -63,7 +63,7 @@ abstract class Layers extends \Com\Tecnick\Barcode\Type\Square\Aztec\Codeword * * @return int */ - protected function getMinLayers($data, $numbits) + protected function getMinLayers(array $data, int $numbits): int { if ($numbits <= $data[count($data)][3]) { foreach ($data as $numlayers => $size) { @@ -83,7 +83,7 @@ protected function getMinLayers($data, $numbits) * * @return bool Returns true if the size computation was successful, false otherwise. */ - protected function setLayerByBits($numbits, $mode = 'A') + protected function setLayerByBits(int $numbits, string $mode = 'A'): bool { $this->numlayers = 0; if ($mode == 'A') { @@ -109,7 +109,7 @@ protected function setLayerByBits($numbits, $mode = 'A') * * @return bool Returns true if the size computation was successful, false otherwise. */ - protected function sizeAndBitStuffing($ecc, $mode = 'A') + protected function sizeAndBitStuffing(int $ecc, string $mode = 'A'): bool { $nsbits = 0; $eccbits = (11 + intval(($this->totbits * $ecc) / 100)); @@ -131,7 +131,7 @@ protected function sizeAndBitStuffing($ecc, $mode = 'A') * * @return int The number of bits in the bitstream after bit stuffing. */ - protected function bitStuffing() + protected function bitStuffing(): int { $nsbits = 0; $wsize = $this->layer[2]; From 36ff04a00ca99e0794ea5e5c939988623dc4c0c7 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Sun, 19 Nov 2023 18:04:48 +0000 Subject: [PATCH 045/100] fixes --- src/Type/Square/Datamatrix.php | 1 + src/Type/Square/Datamatrix/Encode.php | 44 +++++++++-- src/Type/Square/Datamatrix/EncodeTxt.php | 37 +++++++-- .../Square/Datamatrix/ErrorCorrection.php | 24 +++++- src/Type/Square/Datamatrix/Modes.php | 54 ++++++------- src/Type/Square/Datamatrix/Placement.php | 78 ++++++++++++++++--- src/Type/Square/Datamatrix/Steps.php | 38 +++++---- test/Square/DatamatrixTest.php | 16 ++-- 8 files changed, 221 insertions(+), 71 deletions(-) diff --git a/src/Type/Square/Datamatrix.php b/src/Type/Square/Datamatrix.php index 35647a19..aa2ab873 100644 --- a/src/Type/Square/Datamatrix.php +++ b/src/Type/Square/Datamatrix.php @@ -234,6 +234,7 @@ protected function getHighLevelEncoding(string $data): array $cdw = array(); // array of codewords to be returned $cdw_num = 0; // number of data codewords $data_length = strlen($data); // number of chars + $field_length = 0; // number of chars in current field while ($pos < $data_length) { // Determine if current char is FNC1 (don't encode it, just pass it through) if ($this->gsonemode && ($data[$pos] == chr(232))) { diff --git a/src/Type/Square/Datamatrix/Encode.php b/src/Type/Square/Datamatrix/Encode.php index 95b073d7..e0dd9dc8 100644 --- a/src/Type/Square/Datamatrix/Encode.php +++ b/src/Type/Square/Datamatrix/Encode.php @@ -55,7 +55,14 @@ public function __construct($shape = 'S') * @param string $data * @param int $enc */ - public function encodeASCII(&$cdw, &$cdw_num, &$pos, &$data_length, &$data, &$enc) + public function encodeASCII( + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + string &$data, + int &$enc + ): void { if ( ($data_length > 1) @@ -108,9 +115,18 @@ public function encodeASCII(&$cdw, &$cdw_num, &$pos, &$data_length, &$data, &$en * @param int $enc * @param array $temp_cw * - * @return boolean true to break the loop + * @return bool true to break the loop */ - public function encodeEDFfour($epos, &$cdw, &$cdw_num, &$pos, &$data_length, &$field_length, &$enc, &$temp_cw) + public function encodeEDFfour( + int $epos, + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + int &$field_length, + int &$enc, + array &$temp_cw + ): bool { if (($epos == $data_length)) { $enc = Data::ENC_ASCII; @@ -160,7 +176,7 @@ public function encodeEDFfour($epos, &$cdw, &$cdw_num, &$pos, &$data_length, &$f /** * Encode EDF * - * @param int $cdw + * @param array $cdw * @param int $cdw_num * @param int $pos * @param int $data_length @@ -168,7 +184,15 @@ public function encodeEDFfour($epos, &$cdw, &$cdw_num, &$pos, &$data_length, &$f * @param string $data * @param int $enc */ - public function encodeEDF(&$cdw, &$cdw_num, &$pos, &$data_length, &$field_length, &$data, &$enc) + public function encodeEDF( + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + int &$field_length, + string &$data, + int &$enc + ): void { // initialize temporary array with 0 length $temp_cw = array(); @@ -205,7 +229,15 @@ public function encodeEDF(&$cdw, &$cdw_num, &$pos, &$data_length, &$field_length * @param string $data * @param int $enc */ - public function encodeBase256(&$cdw, &$cdw_num, &$pos, &$data_length, &$field_length, &$data, &$enc) + public function encodeBase256( + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + int &$field_length, + string &$data, + int &$enc + ): void { // initialize temporary array with 0 length $temp_cw = array(); diff --git a/src/Type/Square/Datamatrix/EncodeTxt.php b/src/Type/Square/Datamatrix/EncodeTxt.php index af3852eb..46438e06 100644 --- a/src/Type/Square/Datamatrix/EncodeTxt.php +++ b/src/Type/Square/Datamatrix/EncodeTxt.php @@ -43,7 +43,12 @@ class EncodeTxt extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Steps * @param array $temp_cw * @param int $ptr */ - public function encodeTXTC40shift(&$chr, &$enc, &$temp_cw, &$ptr) + public function encodeTXTC40shift( + int &$chr, + int &$enc, + array &$temp_cw, + int &$ptr + ): void { if (array_key_exists($chr, Data::CHSET['SH1'])) { $temp_cw[] = 0; // shift 1 @@ -76,7 +81,14 @@ public function encodeTXTC40shift(&$chr, &$enc, &$temp_cw, &$ptr) * * @return int Curent character code */ - public function encodeTXTC40(&$data, &$enc, &$temp_cw, &$ptr, &$epos, &$charset) + public function encodeTXTC40( + string &$data, + int &$enc, + array &$temp_cw, + int &$ptr, + int &$epos, + array &$charset + ): int { // 2. process the next character in C40 encodation. $chr = ord($data[$epos]); @@ -113,7 +125,15 @@ public function encodeTXTC40(&$data, &$enc, &$temp_cw, &$ptr, &$epos, &$charset) * @param int $ptr * @param int $epos */ - public function encodeTXTC40last($chr, &$cdw, &$cdw_num, &$enc, &$temp_cw, &$ptr, &$epos) + public function encodeTXTC40last( + int $chr, + array &$cdw, + int &$cdw_num, + int &$enc, + array &$temp_cw, + int &$ptr, + int &$epos + ): void { // get remaining number of data symbols $cdwr = ($this->getMaxDataCodewords($cdw_num + $ptr) - $cdw_num); @@ -158,14 +178,21 @@ public function encodeTXTC40last($chr, &$cdw, &$cdw_num, &$enc, &$temp_cw, &$ptr /** * Encode TXT * - * @param int $cdw + * @param array $cdw * @param int $cdw_num * @param int $pos * @param int $data_length * @param string $data * @param int $enc */ - public function encodeTXT(&$cdw, &$cdw_num, &$pos, &$data_length, &$data, &$enc) + public function encodeTXT( + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + string &$data, + int &$enc + ): void { $temp_cw = array(); $ptr = 0; diff --git a/src/Type/Square/Datamatrix/ErrorCorrection.php b/src/Type/Square/Datamatrix/ErrorCorrection.php index 9e658b65..13cec5a7 100644 --- a/src/Type/Square/Datamatrix/ErrorCorrection.php +++ b/src/Type/Square/Datamatrix/ErrorCorrection.php @@ -42,7 +42,13 @@ class ErrorCorrection * * @return int product */ - protected function getGFProduct($numa, $numb, $log, $alog, $ngf) + protected function getGFProduct( + int $numa, + int $numb, + array $log, + array $alog, + int $ngf + ): int { if (($numa == 0) || ($numb == 0)) { return 0; @@ -62,7 +68,14 @@ protected function getGFProduct($numa, $numb, $log, $alog, $ngf) * * @return array data codewords + error codewords */ - public function getErrorCorrection($wdc, $nbk, $ncw, $ncc, $ngf = 256, $vpp = 301) + public function getErrorCorrection( + array $wdc, + int $nbk, + int $ncw, + int $ncc, + int $ngf = 256, + int $vpp = 301 + ): array { // generate the log ($log) and antilog ($alog) tables $log = array(0); @@ -121,7 +134,12 @@ public function getErrorCorrection($wdc, $nbk, $ncw, $ncc, $ngf = 256, $vpp = 30 * @param int $ngf Number of fields on log/antilog table (power of 2). * @param int $vpp The value of its prime modulus polynomial (301 for ECC200). */ - protected function genLogs(&$log, &$alog, $ngf, $vpp) + protected function genLogs( + array &$log, + array &$alog, + int $ngf, + int $vpp + ): void { for ($i = 1; $i < $ngf; ++$i) { $alog[$i] = ($alog[($i - 1)] * 2); diff --git a/src/Type/Square/Datamatrix/Modes.php b/src/Type/Square/Datamatrix/Modes.php index a560aa39..9baf71e8 100644 --- a/src/Type/Square/Datamatrix/Modes.php +++ b/src/Type/Square/Datamatrix/Modes.php @@ -38,14 +38,14 @@ abstract class Modes extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Placeme * * @var int */ - public $last_enc; + public int $last_enc; /** * Datamatrix shape key (S=square, R=rectangular) * * @var string */ - public $shape; + public string $shape; /** * Return the 253-state codeword @@ -55,7 +55,7 @@ abstract class Modes extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Placeme * * @return int */ - public function get253StateCodeword($cdwpad, $cdwpos) + public function get253StateCodeword(int $cdwpad, int $cdwpos): int { $pad = ($cdwpad + (((149 * $cdwpos) % 253) + 1)); if ($pad > 254) { @@ -72,7 +72,7 @@ public function get253StateCodeword($cdwpad, $cdwpos) * * @return int pad codeword */ - protected function get255StateCodeword($cdwpad, $cdwpos) + protected function get255StateCodeword(int $cdwpad, int $cdwpos): int { $pad = ($cdwpad + (((149 * $cdwpos) % 255) + 1)); if ($pad > 255) { @@ -87,9 +87,9 @@ protected function get255StateCodeword($cdwpad, $cdwpos) * @param int $chr Character (byte) to check. * @param int $mode Current encoding mode. * - * @return boolean true if the char is of the selected mode. + * @return bool true if the char is of the selected mode. */ - protected function isCharMode($chr, $mode) + protected function isCharMode(int $chr, int $mode): bool { $map = array( //Data::ENC_ASCII => 'isASCIIMode', @@ -110,9 +110,9 @@ protected function isCharMode($chr, $mode) // * // * @param int $chr Character (byte) to check. // * - // * @return boolean + // * @return bool // */ - //protected function isASCIIMode($chr) + //protected function isASCIIMode(int $chr): bool //{ // return (($chr >= 0) && ($chr <= 127)); //} @@ -122,9 +122,9 @@ protected function isCharMode($chr, $mode) * * @param int $chr Character (byte) to check. * - * @return boolean + * @return bool */ - protected function isC40Mode($chr) + protected function isC40Mode(int $chr): bool { return (($chr == 32) || (($chr >= 48) && ($chr <= 57)) || (($chr >= 65) && ($chr <= 90))); } @@ -134,9 +134,9 @@ protected function isC40Mode($chr) * * @param int $chr Character (byte) to check. * - * @return boolean + * @return bool */ - protected function isTXTMode($chr) + protected function isTXTMode(int $chr): bool { return (($chr == 32) || (($chr >= 48) && ($chr <= 57)) || (($chr >= 97) && ($chr <= 122))); } @@ -146,9 +146,9 @@ protected function isTXTMode($chr) * * @param int $chr Character (byte) to check. * - * @return boolean + * @return bool */ - protected function isX12Mode($chr) + protected function isX12Mode(int $chr): bool { return (($chr == 13) || ($chr == 42) || ($chr == 62)); } @@ -158,9 +158,9 @@ protected function isX12Mode($chr) * * @param int $chr Character (byte) to check. * - * @return boolean + * @return bool */ - protected function isEDFMode($chr) + protected function isEDFMode(int $chr): bool { return (($chr >= 32) && ($chr <= 94)); } @@ -170,9 +170,9 @@ protected function isEDFMode($chr) * * @param int $chr Character (byte) to check. * - * @return boolean + * @return bool */ - protected function isBASE256Mode($chr) + protected function isBASE256Mode(int $chr): bool { return (($chr == 232) || ($chr == 233) || ($chr == 234) || ($chr == 241)); } @@ -182,9 +182,9 @@ protected function isBASE256Mode($chr) * * @param int $chr Character (byte) to check. * - * @return boolean + * @return bool */ - protected function isASCIIEXTMode($chr) + protected function isASCIIEXTMode(int $chr): bool { return (($chr >= 128) && ($chr <= 255)); } @@ -194,9 +194,9 @@ protected function isASCIIEXTMode($chr) * * @param int $chr Character (byte) to check. * - * @return boolean + * @return bool */ - protected function isASCIINUMMode($chr) + protected function isASCIINUMMode(int $chr): bool { return (($chr >= 48) && ($chr <= 57)); } @@ -206,9 +206,9 @@ protected function isASCIINUMMode($chr) * * @param int $numcw Number of current codewords. * - * @return number of data codewords in matrix + * @return int number of data codewords in matrix */ - protected function getMaxDataCodewords($numcw) + protected function getMaxDataCodewords(int $numcw): int { $mdc = 0; foreach (Data::SYMBATTR[$this->shape] as $matrix) { @@ -222,11 +222,11 @@ protected function getMaxDataCodewords($numcw) /** * Get the switching codeword to a new encoding mode (latch codeword) - * @param $mode (int) New encoding mode. - * @return (int) Switch codeword. + * @param int $mode New encoding mode. + * @return int Switch codeword. * @protected */ - protected function getSwitchEncodingCodeword($mode) + protected function getSwitchEncodingCodeword(int $mode): int { $map = array( Data::ENC_ASCII => 254, diff --git a/src/Type/Square/Datamatrix/Placement.php b/src/Type/Square/Datamatrix/Placement.php index dcbdd4fc..330c6d5b 100644 --- a/src/Type/Square/Datamatrix/Placement.php +++ b/src/Type/Square/Datamatrix/Placement.php @@ -47,7 +47,15 @@ abstract class Placement * * @return array */ - protected function placeModule($marr, $nrow, $ncol, $row, $col, $chr, $bit) + protected function placeModule( + array $marr, + int $nrow, + int $ncol, + int $row, + int $col, + int $chr, + int $bit + ): array { if ($row < 0) { $row += $nrow; @@ -74,7 +82,14 @@ protected function placeModule($marr, $nrow, $ncol, $row, $col, $chr, $bit) * * @return array */ - protected function placeUtah($marr, $nrow, $ncol, $row, $col, $chr) + protected function placeUtah( + array $marr, + int $nrow, + int $ncol, + int $row, + int $col, + int $chr + ): array { $marr = $this->placeModule($marr, $nrow, $ncol, $row - 2, $col - 2, $chr, 1); $marr = $this->placeModule($marr, $nrow, $ncol, $row - 2, $col - 1, $chr, 2); @@ -100,7 +115,14 @@ protected function placeUtah($marr, $nrow, $ncol, $row, $col, $chr) * * @return array */ - protected function placeCornerA($marr, $nrow, $ncol, &$chr, $row, $col) + protected function placeCornerA( + array $marr, + int $nrow, + int $ncol, + int &$chr, + int $row, + int $col + ): array { if (($row != $nrow) || ($col != 0)) { return $marr; @@ -130,7 +152,14 @@ protected function placeCornerA($marr, $nrow, $ncol, &$chr, $row, $col) * * @return array */ - protected function placeCornerB($marr, $nrow, $ncol, &$chr, $row, $col) + protected function placeCornerB( + array $marr, + int $nrow, + int $ncol, + int &$chr, + int $row, + int $col + ): array { if (($row != ($nrow - 2)) || ($col != 0) || (($ncol % 4) == 0)) { return $marr; @@ -160,7 +189,14 @@ protected function placeCornerB($marr, $nrow, $ncol, &$chr, $row, $col) * * @return array */ - protected function placeCornerC($marr, $nrow, $ncol, &$chr, $row, $col) + protected function placeCornerC( + array $marr, + int $nrow, + int $ncol, + int &$chr, + int $row, + int $col + ): array { if (($row != ($nrow - 2)) || ($col != 0) || (($ncol % 8) != 4)) { return $marr; @@ -190,7 +226,14 @@ protected function placeCornerC($marr, $nrow, $ncol, &$chr, $row, $col) * * @return array */ - protected function placeCornerD($marr, $nrow, $ncol, &$chr, $row, $col) + protected function placeCornerD( + array $marr, + int $nrow, + int $ncol, + int &$chr, + int $row, + int $col + ): array { if (($row != ($nrow + 4)) || ($col != 2) || ($ncol % 8)) { return $marr; @@ -222,7 +265,14 @@ protected function placeCornerD($marr, $nrow, $ncol, &$chr, $row, $col) * * @return array */ - protected function placeSweepUpward($marr, $nrow, $ncol, &$chr, &$row, &$col) + protected function placeSweepUpward( + array $marr, + int $nrow, + int $ncol, + int &$chr, + int &$row, + int &$col + ): array { do { if (($row < $nrow) && ($col >= 0) && (!$marr[(($row * $ncol) + $col)])) { @@ -250,7 +300,14 @@ protected function placeSweepUpward($marr, $nrow, $ncol, &$chr, &$row, &$col) * * @return array */ - protected function placeSweepDownward($marr, $nrow, $ncol, &$chr, &$row, &$col) + protected function placeSweepDownward( + array $marr, + int $nrow, + int $ncol, + int &$chr, + int &$row, + int &$col + ): array { do { if (($row >= 0) && ($col < $ncol) && (!$marr[(($row * $ncol) + $col)])) { @@ -274,7 +331,10 @@ protected function placeSweepDownward($marr, $nrow, $ncol, &$chr, &$row, &$col) * * @return array */ - public function getPlacementMap($nrow, $ncol) + public function getPlacementMap( + int $nrow, + int $ncol + ): array { // initialize array with zeros $marr = array_fill(0, ($nrow * $ncol), 0); diff --git a/src/Type/Square/Datamatrix/Steps.php b/src/Type/Square/Datamatrix/Steps.php index 53fe117a..8c666881 100644 --- a/src/Type/Square/Datamatrix/Steps.php +++ b/src/Type/Square/Datamatrix/Steps.php @@ -43,7 +43,7 @@ abstract class Steps extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Modes * * @return int encoding mode */ - public function lookAheadTest($data, $pos, $mode) + public function lookAheadTest(string $data, int $pos, int $mode): int { $data_length = strlen($data); if ($pos >= $data_length) { @@ -71,7 +71,7 @@ public function lookAheadTest($data, $pos, $mode) $this->stepQ($chr, $numch); if ($charscount >= 4) { $ret = $this->stepR($numch, $pos, $data_length, $charscount, $data); - if ($ret !== null) { + if ($ret >= 0) { return $ret; } } @@ -85,7 +85,7 @@ public function lookAheadTest($data, $pos, $mode) * * @return int */ - protected function stepK($numch) + protected function stepK(array $numch): int { if ( $numch[Data::ENC_ASCII] <= ceil(min( @@ -151,7 +151,7 @@ protected function stepK($numch) * @param int $chr * @param array $numch */ - protected function stepL($chr, &$numch) + protected function stepL(int $chr, array &$numch): void { if ($this->isCharMode($chr, Data::ENC_ASCII_NUM)) { $numch[Data::ENC_ASCII] += (1 / 2); @@ -170,7 +170,7 @@ protected function stepL($chr, &$numch) * @param int $chr * @param array $numch */ - protected function stepM($chr, &$numch) + protected function stepM(int $chr, array &$numch): void { if ($this->isCharMode($chr, Data::ENC_C40)) { $numch[Data::ENC_C40] += (2 / 3); @@ -187,7 +187,7 @@ protected function stepM($chr, &$numch) * @param int $chr * @param array $numch */ - protected function stepN($chr, &$numch) + protected function stepN(int $chr, array &$numch): void { if ($this->isCharMode($chr, Data::ENC_TXT)) { $numch[Data::ENC_TXT] += (2 / 3); @@ -204,7 +204,7 @@ protected function stepN($chr, &$numch) * @param int $chr * @param array $numch */ - protected function stepO($chr, &$numch) + protected function stepO(int $chr, array &$numch): void { if ($this->isCharMode($chr, Data::ENC_X12) || $this->isCharMode($chr, Data::ENC_C40)) { $numch[Data::ENC_X12] += (2 / 3); @@ -221,7 +221,7 @@ protected function stepO($chr, &$numch) * @param int $chr * @param array $numch */ - protected function stepP($chr, &$numch) + protected function stepP(int $chr, array &$numch): void { if ($this->isCharMode($chr, Data::ENC_EDF)) { $numch[Data::ENC_EDF] += (3 / 4); @@ -238,7 +238,7 @@ protected function stepP($chr, &$numch) * @param int $chr * @param array $numch */ - protected function stepQ($chr, &$numch) + protected function stepQ(int $chr, array &$numch): void { if ($this->isCharMode($chr, Data::ENC_BASE256)) { $numch[Data::ENC_BASE256] += 4; @@ -256,9 +256,15 @@ protected function stepQ($chr, &$numch) * @param int $charscount * @param string $data * - * @return int|null Encoding mode + * @return int Encoding mode */ - protected function stepRf($numch, $pos, $data_length, $charscount, $data) + protected function stepRf( + array $numch, + int $pos, + int $data_length, + int $charscount, + string $data + ): int { if ( ($numch[Data::ENC_C40] + 1) < min( @@ -285,7 +291,7 @@ protected function stepRf($numch, $pos, $data_length, $charscount, $data) return Data::ENC_C40; } } - return null; + return -1; } /** @@ -297,7 +303,13 @@ protected function stepRf($numch, $pos, $data_length, $charscount, $data) * @param int $charscount * @param string $data */ - protected function stepR($numch, $pos, $data_length, $charscount, $data) + protected function stepR( + array $numch, + int $pos, + int $data_length, + int $charscount, + string $data + ): int { if ( ($numch[Data::ENC_ASCII] + 1) <= min( diff --git a/test/Square/DatamatrixTest.php b/test/Square/DatamatrixTest.php index 89d62f8f..049ae15f 100644 --- a/test/Square/DatamatrixTest.php +++ b/test/Square/DatamatrixTest.php @@ -56,10 +56,10 @@ public function testEncodeTXTC40shiftException() { $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); $obj = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode(); - $chr = null; - $enc = null; - $temp_cw = null; - $ptr = null; + $chr = -1; + $enc = -1; + $temp_cw = []; + $ptr = 0; $obj->encodeTXTC40shift($chr, $enc, $temp_cw, $ptr); } @@ -67,12 +67,12 @@ public function testEncodeTXTC40Exception() { $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); $obj = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode(); - $data = array(chr(0x80)); + $data = "\x80"; $enc = \Com\Tecnick\Barcode\Type\Square\Datamatrix\Data::ENC_X12; - $temp_cw = null; - $ptr = null; + $temp_cw = []; + $ptr = 0; $epos = 0; - $charset = null; + $charset = []; $obj->encodeTXTC40($data, $enc, $temp_cw, $ptr, $epos, $charset); } From 909b8693134c2acc5ddc06f1b2e1d75cbd7bb480 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 08:41:42 +0000 Subject: [PATCH 046/100] fixes --- src/Type/Square/QrCode/ByteStream.php | 18 +++++++++--------- src/Type/Square/QrCode/Encode.php | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Type/Square/QrCode/ByteStream.php b/src/Type/Square/QrCode/ByteStream.php index 3387404c..153c5bbe 100644 --- a/src/Type/Square/QrCode/ByteStream.php +++ b/src/Type/Square/QrCode/ByteStream.php @@ -41,7 +41,7 @@ class ByteStream extends \Com\Tecnick\Barcode\Type\Square\QrCode\Encode * @param int $version Code version * @param int $level Error Correction Level */ - public function __construct($hint, $version, $level) + public function __construct(int $hint, int $version, int $level) { $this->hint = $hint; $this->version = $version; @@ -55,7 +55,7 @@ public function __construct($hint, $version, $level) * * @return array padded merged byte stream */ - public function getByteStream($items) + public function getByteStream(array $items): array { return $this->bitstreamToByte( $this->appendPaddingBit( @@ -71,7 +71,7 @@ public function getByteStream($items) * * @return array of bytes */ - protected function bitstreamToByte($bstream) + protected function bitstreamToByte(array $bstream): array { $size = count($bstream); if ($size == 0) { @@ -108,7 +108,7 @@ protected function bitstreamToByte($bstream) * * @return array bitstream */ - protected function mergeBitStream($items) + protected function mergeBitStream(array $items): array { $items = $this->convertData($items); $bstream = array(); @@ -125,7 +125,7 @@ protected function mergeBitStream($items) * * @return array items */ - protected function convertData($items) + protected function convertData(array $items): array { $ver = $this->estimateVersion($items, $this->level); if ($ver > $this->version) { @@ -151,11 +151,11 @@ protected function convertData($items) /** * Create BitStream * - * @param $items + * @param array $items * * @return array of items and total bits */ - protected function createBitStream($items) + protected function createBitStream(array $items): array { $total = 0; foreach ($items as $key => $item) { @@ -174,7 +174,7 @@ protected function createBitStream($items) * * @return array input item */ - public function encodeBitStream($inputitem, $version) + public function encodeBitStream(array $inputitem, int $version): array { $inputitem['bstream'] = array(); $specObj = new Spec(); @@ -220,7 +220,7 @@ public function encodeBitStream($inputitem, $version) * * @return array bitstream */ - protected function appendPaddingBit($bstream) + protected function appendPaddingBit(array $bstream): array { if (is_null($bstream)) { return array(); diff --git a/src/Type/Square/QrCode/Encode.php b/src/Type/Square/QrCode/Encode.php index 3efa96fb..2fe1fa7c 100644 --- a/src/Type/Square/QrCode/Encode.php +++ b/src/Type/Square/QrCode/Encode.php @@ -40,7 +40,7 @@ abstract class Encode extends \Com\Tecnick\Barcode\Type\Square\QrCode\EncodingMo * * @return array input item */ - protected function encodeModeNum($inputitem, $version) + protected function encodeModeNum(array $inputitem, int $version): array { $words = (int)($inputitem['size'] / 3); $inputitem['bstream'] = array(); @@ -76,7 +76,7 @@ protected function encodeModeNum($inputitem, $version) * * @return array input item */ - protected function encodeModeAn($inputitem, $version) + protected function encodeModeAn(array $inputitem, int $version): array { $words = (int)($inputitem['size'] / 2); $inputitem['bstream'] = array(); @@ -106,7 +106,7 @@ protected function encodeModeAn($inputitem, $version) * * @return array input item */ - protected function encodeMode8($inputitem, $version) + protected function encodeMode8(array $inputitem, int $version): array { $inputitem['bstream'] = array(); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4); @@ -129,7 +129,7 @@ protected function encodeMode8($inputitem, $version) * * @return array input item */ - protected function encodeModeKanji($inputitem, $version) + protected function encodeModeKanji(array $inputitem, int $version): array { $inputitem['bstream'] = array(); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8); @@ -158,7 +158,7 @@ protected function encodeModeKanji($inputitem, $version) * * @return array input item */ - protected function encodeModeStructure($inputitem) + protected function encodeModeStructure(array $inputitem): array { $inputitem['bstream'] = array(); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x03); From e1c68c5f52e7ca3c5df32f74f78c1423e3fb74d4 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 08:43:17 +0000 Subject: [PATCH 047/100] fixes --- src/Type/Square/QrCode/Encoder.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Type/Square/QrCode/Encoder.php b/src/Type/Square/QrCode/Encoder.php index b2b5902f..e0188aae 100644 --- a/src/Type/Square/QrCode/Encoder.php +++ b/src/Type/Square/QrCode/Encoder.php @@ -41,7 +41,7 @@ class Encoder extends \Com\Tecnick\Barcode\Type\Square\QrCode\Init * * @return array Encoded Mask */ - public function encodeMask($maskNo, $datacode) + public function encodeMask(int $maskNo, array $datacode): array { // initialize values $this->datacode = $datacode; @@ -100,7 +100,7 @@ public function encodeMask($maskNo, $datacode) * * @return int rsblocks */ - protected function getCode() + protected function getCode(): int { if ($this->count < $this->dataLength) { $row = ($this->count % $this->blocks); @@ -126,7 +126,7 @@ protected function getCode() * @param array $pos X,Y position * @param int $val Value of the character to set */ - protected function setFrameAt($pos, $val) + protected function setFrameAt(array $pos, int $val): void { $this->frame[$pos['y']][$pos['x']] = chr($val); } @@ -136,7 +136,7 @@ protected function setFrameAt($pos, $val) * * @return array of x,y coordinates */ - protected function getNextPosition() + protected function getNextPosition(): array { do { if ($this->bit == -1) { @@ -164,7 +164,7 @@ protected function getNextPosition() * @param int $ypos * @param int $wdt */ - protected function getNextPositionB(&$xpos, &$ypos, $wdt) + protected function getNextPositionB(int &$xpos, int &$ypos, int $wdt): void { if ($this->bit == 0) { --$xpos; From f2843ac55e5dada7972d9e78f614bb59342dad54 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 08:45:46 +0000 Subject: [PATCH 048/100] fixes --- src/Type/Square/QrCode/EncodingMode.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Type/Square/QrCode/EncodingMode.php b/src/Type/Square/QrCode/EncodingMode.php index bcca051d..2b124d4d 100644 --- a/src/Type/Square/QrCode/EncodingMode.php +++ b/src/Type/Square/QrCode/EncodingMode.php @@ -40,7 +40,7 @@ abstract class EncodingMode extends \Com\Tecnick\Barcode\Type\Square\QrCode\Inpu * * @return int mode */ - public function getEncodingMode($data, $pos) + public function getEncodingMode(string $data, int $pos): int { if (!isset($data[$pos])) { return Data::ENC_MODES['NL']; @@ -62,7 +62,7 @@ public function getEncodingMode($data, $pos) * * @return int mode */ - protected function getEncodingModeKj($data, $pos) + protected function getEncodingModeKj(string $data, int $pos): int { if (($this->hint == Data::ENC_MODES['KJ']) && isset($data[($pos + 1)])) { $word = ((ord($data[$pos]) << 8) | ord($data[($pos + 1)])); @@ -79,9 +79,9 @@ protected function getEncodingModeKj($data, $pos) * @param string $str Data * @param int $pos Character position * - * @return boolean + * @return bool */ - public function isDigitAt($str, $pos) + public function isDigitAt(string $str, int $pos): bool { if (!isset($str[$pos])) { return false; @@ -95,9 +95,9 @@ public function isDigitAt($str, $pos) * @param string $str Data * @param int $pos Character position * - * @return boolean + * @return bool */ - public function isAlphanumericAt($str, $pos) + public function isAlphanumericAt(string $str, int $pos): bool { if (!isset($str[$pos])) { return false; @@ -113,7 +113,7 @@ public function isAlphanumericAt($str, $pos) * * @return array bitstream */ - protected function appendBitstream($bitstream, $append) + protected function appendBitstream(array $bitstream, array $append): array { if ((!is_array($append)) || (count($append) == 0)) { return $bitstream; @@ -133,7 +133,7 @@ protected function appendBitstream($bitstream, $append) * * @return array bitstream */ - protected function appendNum($bitstream, $bits, $num) + protected function appendNum(array $bitstream, int $bits, int $num): array { if ($bits == 0) { return array(); @@ -150,7 +150,7 @@ protected function appendNum($bitstream, $bits, $num) * * @return array bitstream */ - protected function appendBytes($bitstream, $size, $data) + protected function appendBytes(array $bitstream, int $size, array $data): array { if ($size == 0) { return array(); @@ -166,7 +166,7 @@ protected function appendBytes($bitstream, $size, $data) * * @return array bitstream */ - protected function newFromNum($bits, $num) + protected function newFromNum(int $bits, int $num): array { $bstream = $this->allocate($bits); $mask = 1 << ($bits - 1); @@ -189,7 +189,7 @@ protected function newFromNum($bits, $num) * * @return array bitstream */ - protected function newFromBytes($size, $data) + protected function newFromBytes(int $size, array $data): array { $bstream = $this->allocate($size * 8); $pval = 0; @@ -215,7 +215,7 @@ protected function newFromBytes($size, $data) * * @return array */ - protected function allocate($setLength) + protected function allocate(int $setLength): array { return array_fill(0, $setLength, 0); } From d3ddb3e3057ebbb5dec047e031ea95566badf1f8 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 08:47:28 +0000 Subject: [PATCH 049/100] fixes --- src/Type/Square/QrCode/Estimate.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Type/Square/QrCode/Estimate.php b/src/Type/Square/QrCode/Estimate.php index 98174625..db6b127d 100644 --- a/src/Type/Square/QrCode/Estimate.php +++ b/src/Type/Square/QrCode/Estimate.php @@ -37,7 +37,7 @@ abstract class Estimate * * @var int */ - protected $hint = 2; + protected int $hint = 2; /** * QR code version. @@ -47,14 +47,14 @@ abstract class Estimate * * @var int */ - public $version = 0; + public int $version = 0; /** * Error correction level * * @var int */ - protected $level = 0; + protected int $level = 0; /** @@ -65,7 +65,7 @@ abstract class Estimate * * @return int the size of the appropriate length indicator (bits). */ - public function getLengthIndicator($mode, $version) + public function getLengthIndicator(int $mode, int $version): int { if ($mode == Data::ENC_MODES['ST']) { return 0; @@ -87,7 +87,7 @@ public function getLengthIndicator($mode, $version) * * @return int number of bits */ - public function estimateBitsModeNum($size) + public function estimateBitsModeNum(int $size): int { $wdt = (int)($size / 3); $bits = ($wdt * 10); @@ -109,7 +109,7 @@ public function estimateBitsModeNum($size) * * @return int number of bits */ - public function estimateBitsModeAn($size) + public function estimateBitsModeAn(int $size): int { $bits = (int)($size * 5.5); // (size / 2 ) * 11 if ($size & 1) { @@ -125,7 +125,7 @@ public function estimateBitsModeAn($size) * * @return int number of bits */ - public function estimateBitsMode8($size) + public function estimateBitsMode8(int $size): int { return (int)($size * 8); } @@ -137,7 +137,7 @@ public function estimateBitsMode8($size) * * @return int number of bits */ - public function estimateBitsModeKanji($size) + public function estimateBitsModeKanji(int $size): int { return (int)($size * 6.5); // (size / 2 ) * 13 } @@ -150,7 +150,7 @@ public function estimateBitsModeKanji($size) * * @return int version */ - public function estimateVersion($items, $level) + public function estimateVersion(array $items, int $level): int { $version = 0; $prev = 0; @@ -175,7 +175,7 @@ public function estimateVersion($items, $level) * * @throws BarcodeException */ - protected function getMinimumVersion($size, $level) + protected function getMinimumVersion(int $size, int $level): int { for ($idx = 1; $idx <= Data::QRSPEC_VERSION_MAX; ++$idx) { $words = (Data::CAPACITY[$idx][Data::QRCAP_WORDS] - Data::CAPACITY[$idx][Data::QRCAP_EC][$level]); @@ -196,7 +196,7 @@ protected function getMinimumVersion($size, $level) * * @return int bits */ - protected function estimateBitStreamSize($items, $version) + protected function estimateBitStreamSize(array $items, int $version): int { $bits = 0; if ($version == 0) { From b9ea0bdc9c751bfd1d20624db3f3b71b9406d207 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 08:55:54 +0000 Subject: [PATCH 050/100] fixes --- src/Type/Square/QrCode/Init.php | 76 ++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/src/Type/Square/QrCode/Init.php b/src/Type/Square/QrCode/Init.php index 43dc9719..516fc11c 100644 --- a/src/Type/Square/QrCode/Init.php +++ b/src/Type/Square/QrCode/Init.php @@ -38,112 +38,112 @@ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask * * @var array */ - protected $datacode = array(); + protected array $datacode = array(); /** * Error correction code * * @var array */ - protected $ecccode = array(); + protected array $ecccode = array(); /** * Blocks * * @var int */ - protected $blocks; + protected int $blocks; /** * Reed-Solomon blocks * * @var array */ - protected $rsblocks = array(); //of RSblock + protected array $rsblocks = array(); //of RSblock /** * Counter * * @var int */ - protected $count; + protected int $count; /** * Data length * * @var int */ - protected $dataLength; + protected int $dataLength; /** * Error correction length * * @var int */ - protected $eccLength; + protected int $eccLength; /** * Value bv1 * * @var int */ - protected $bv1; + protected int $bv1; /** * Width. * * @var int */ - protected $width; + protected int $width; /** * Frame * * @var array */ - protected $frame; + protected array $frame; /** * Horizontal bit position * * @var int */ - protected $xpos; + protected int $xpos; /** * Vertical bit position * * @var int */ - protected $ypos; + protected int $ypos; /** * Direction * * @var int */ - protected $dir; + protected int $dir; /** * Single bit value * * @var int */ - protected $bit; + protected int $bit; /** * Reed-Solomon items * * @va array */ - protected $rsitems = array(); + protected array $rsitems = array(); /** * Initialize code * * @param array $spec Array of ECC specification */ - protected function init($spec) + protected function init(array $spec): void { $dlv = $this->spc->rsDataCodes1($spec); $elv = $this->spc->rsEccCodes1($spec); @@ -151,6 +151,7 @@ protected function init($spec) $blockNo = 0; $dataPos = 0; $eccPos = 0; + $ecc = []; $endfor = $this->spc->rsBlockNum1($spec); $this->initLoop($endfor, $dlv, $elv, $rsv, $eccPos, $blockNo, $dataPos, $ecc); if ($this->spc->rsBlockNum2($spec) == 0) { @@ -176,9 +177,18 @@ protected function init($spec) * @param int $eccPos * @param int $blockNo * @param int $dataPos - * @param int $ecc + * @param array $ecc */ - protected function initLoop($endfor, $dlv, $elv, $rsv, &$eccPos, &$blockNo, &$dataPos, &$ecc) + protected function initLoop( + int $endfor, + int $dlv, + int $elv, + array $rsv, + int &$eccPos, + int &$blockNo, + int &$dataPos, + array &$ecc + ): void { for ($idx = 0; $idx < $endfor; ++$idx) { $ecc = array_slice($this->ecccode, $eccPos); @@ -219,7 +229,14 @@ protected function initLoop($endfor, $dlv, $elv, $rsv, &$eccPos, &$blockNo, &$da * pad = Padding bytes in shortened block; * gfpoly. */ - protected function initRs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) + protected function initRs( + int $symsize, + int $gfpoly, + int $fcr, + int $prim, + int $nroots, + int $pad + ): array { foreach ($this->rsitems as $rsv) { if ( @@ -247,7 +264,7 @@ protected function initRs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) * * @return int X position */ - protected function modnn($rsv, $xpos) + protected function modnn(array $rsv, int $xpos): int { while ($xpos >= $rsv['nn']) { $xpos -= $rsv['nn']; @@ -265,7 +282,7 @@ protected function modnn($rsv, $xpos) * * @throws BarcodeException in case of error */ - protected function checkRsCharParamsA($symsize, $fcr, $prim) + protected function checkRsCharParamsA(int $symsize, int $fcr, int $prim): void { $shfsymsize = (1 << $symsize); if ( @@ -289,7 +306,7 @@ protected function checkRsCharParamsA($symsize, $fcr, $prim) * * @throws BarcodeException in case of error */ - protected function checkRsCharParamsB($symsize, $nroots, $pad) + protected function checkRsCharParamsB(int $symsize, int $nroots, int $pad): void { $shfsymsize = (1 << $symsize); if ( @@ -326,7 +343,14 @@ protected function checkRsCharParamsB($symsize, $nroots, $pad) * pad = Padding bytes in shortened block; * gfpoly. */ - protected function initRsChar($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) + protected function initRsChar( + int $symsize, + int $gfpoly, + int $fcr, + int $prim, + int $nroots, + int $pad + ): array { $this->checkRsCharParamsA($symsize, $fcr, $prim); $this->checkRsCharParamsB($symsize, $nroots, $pad); @@ -397,7 +421,11 @@ protected function initRsChar($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) * * @return array Parity array */ - protected function encodeRsChar($rsv, $data, $parity) + protected function encodeRsChar( + array $rsv, + array $data, + array $parity + ): array { // the total number of symbols in a RS block $nnv =& $rsv['nn']; From 50d5657b0290372f1c0a2b9d55e76839a76cccc8 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 09:06:34 +0000 Subject: [PATCH 051/100] fixes --- src/Type/Square/QrCode/InputItem.php | 36 +++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/Type/Square/QrCode/InputItem.php b/src/Type/Square/QrCode/InputItem.php index 599df87f..1c1df225 100644 --- a/src/Type/Square/QrCode/InputItem.php +++ b/src/Type/Square/QrCode/InputItem.php @@ -39,7 +39,7 @@ abstract class InputItem extends \Com\Tecnick\Barcode\Type\Square\QrCode\Estimat * * @return int */ - public function lookAnTable($chr) + public function lookAnTable(int $chr): int { return (($chr > 127) ? -1 : Data::AN_TABLE[$chr]); } @@ -55,7 +55,12 @@ public function lookAnTable($chr) * * @return array items */ - public function appendNewInputItem($items, $mode, $size, $data) + public function appendNewInputItem( + array $items, + int $mode, + int $size, + array $data + ): array { $newitem = $this->newInputItem($mode, $size, $data); if (!empty($newitem)) { @@ -74,7 +79,12 @@ public function appendNewInputItem($items, $mode, $size, $data) * * @return array input item */ - protected function newInputItem($mode, $size, $data, $bstream = null) + protected function newInputItem( + int $mode, + int $size, + array $data, + array $bstream = [] + ): array { $setData = array_slice($data, 0, $size); if (count($setData) < $size) { @@ -98,9 +108,13 @@ protected function newInputItem($mode, $size, $data, $bstream = null) * @param int $size Size of data (byte). * @param array $data Data to validate * - * @return boolean true in case of valid data, false otherwise + * @return bool true in case of valid data, false otherwise */ - protected function check($mode, $size, $data) + protected function check( + int $mode, + int $size, + array $data + ): bool { if ($size <= 0) { return false; @@ -126,9 +140,9 @@ protected function check($mode, $size, $data) * @param int $size * @param array $data * - * @return boolean true or false + * @return bool true or false */ - protected function checkModeNum($size, $data) + protected function checkModeNum(int $size, array $data): bool { for ($idx = 0; $idx < $size; ++$idx) { if ((ord($data[$idx]) < ord('0')) || (ord($data[$idx]) > ord('9'))) { @@ -144,9 +158,9 @@ protected function checkModeNum($size, $data) * @param int $size * @param array $data * - * @return boolean true or false + * @return bool true or false */ - protected function checkModeAn($size, $data) + protected function checkModeAn(int $size, array $data): bool { for ($idx = 0; $idx < $size; ++$idx) { if ($this->lookAnTable(ord($data[$idx])) == -1) { @@ -162,9 +176,9 @@ protected function checkModeAn($size, $data) * @param int $size * @param array $data * - * @return boolean true or false + * @return bool true or false */ - protected function checkModeKanji($size, $data) + protected function checkModeKanji(int $size, array $data): bool { if ($size & 1) { return false; From 07083ff94d6394ce15332be49f171f7ca5798fbf Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 09:22:57 +0000 Subject: [PATCH 052/100] fixes --- src/Type/Square/QrCode/Mask.php | 61 +++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/src/Type/Square/QrCode/Mask.php b/src/Type/Square/QrCode/Mask.php index fcba0259..0f37dfbb 100644 --- a/src/Type/Square/QrCode/Mask.php +++ b/src/Type/Square/QrCode/Mask.php @@ -39,7 +39,7 @@ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum * * @var bool */ - protected $qr_find_from_random = false; + protected bool $qr_find_from_random = false; /** * If true, estimates best mask (spec. default, but extremally slow; @@ -47,21 +47,21 @@ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum * * @var bool */ - protected $qr_find_best_mask = true; + protected bool $qr_find_best_mask = true; /** * Default mask used when $this->qr_find_best_mask === false * * @var int */ - protected $qr_default_mask = 2; + protected int $qr_default_mask = 2; /** * Run length * * @var array */ - protected $runLength = array(); + protected array $runLength = array(); /** * QR code version. @@ -71,21 +71,21 @@ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum * * @var int */ - public $version = 0; + public int $version = 0; /** * Error correction level * * @var int */ - protected $level = 0; + protected int $level = 0; /** * Spec class object * - * @var \Com\Tecnick\Barcode\Type\Square\QrCode\Spec + * @var Spec */ - protected $spc; + protected Spec $spc; /** * Initialize @@ -97,7 +97,13 @@ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum * @param bool $best_mask If true, estimates best mask (slow) * @param int $default_mask Default mask used when $fbm is false */ - public function __construct($version, $level, $random_mask = false, $best_mask = true, $default_mask = 2) + public function __construct( + int $version, + int $level, + bool $random_mask = false, + bool $best_mask = true, + int $default_mask = 2 + ) { $this->version = $version; $this->level = $level; @@ -116,7 +122,11 @@ public function __construct($version, $level, $random_mask = false, $best_mask = * * @return array best mask */ - protected function mask($width, $frame, $level) + protected function mask( + int $width, + array $frame, + int $level + ): array { $minDemerit = PHP_INT_MAX; $bestMask = array(); @@ -157,7 +167,12 @@ protected function mask($width, $frame, $level) * * @return array mask */ - protected function makeMask($width, $frame, $maskNo, $level) + protected function makeMask( + int $width, + array $frame, + int $maskNo, + int $level + ): array { $this->makeMaskNo($maskNo, $width, $frame, $mask); $this->writeFormatInformation($width, $mask, $maskNo, $level); @@ -174,7 +189,12 @@ protected function makeMask($width, $frame, $maskNo, $level) * * @return int blacks */ - protected function writeFormatInformation($width, &$frame, $maskNo, $level) + protected function writeFormatInformation( + int $width, + array &$frame, + int $maskNo, + int $level + ): int { $blacks = 0; $spec = new Spec(); @@ -220,7 +240,7 @@ protected function writeFormatInformation($width, &$frame, $maskNo, $level) * * @return int */ - protected function evaluateSymbol($width, $frame) + protected function evaluateSymbol(int $width, array $frame): int { $frameY = $frameYM = $frame[0]; for ($ypos = 0; $ypos < $width; ++$ypos) { @@ -259,12 +279,17 @@ protected function evaluateSymbol($width, $frame) * * @param int $ypos Y position * @param int $width Width - * @param array $frameY - * @param array $frameYM + * @param string $frameY + * @param string $frameYM * * @return int demerit */ - protected function evaluateSymbolB($ypos, $width, $frameY, $frameYM) + protected function evaluateSymbolB( + int $ypos, + int $width, + string $frameY, + string $frameYM + ): int { $head = 0; $demerit = 0; @@ -306,7 +331,7 @@ protected function evaluateSymbolB($ypos, $width, $frameY, $frameYM) * * @return int demerit */ - protected function calcN1N3($length) + protected function calcN1N3(int $length): int { $demerit = 0; for ($idx = 0; $idx < $length; ++$idx) { @@ -328,7 +353,7 @@ protected function calcN1N3($length) * * @return int demerit delta */ - protected function calcN1N3delta($length, $idx) + protected function calcN1N3delta(int $length, int $idx): int { $fact = (int)($this->runLength[$idx] / 3); if ( From 77fc91c675ea8a57a8cd29150e6919a24991a8c9 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 09:25:48 +0000 Subject: [PATCH 053/100] fixes --- src/Type/Square/QrCode/MaskNum.php | 31 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Type/Square/QrCode/MaskNum.php b/src/Type/Square/QrCode/MaskNum.php index 8beca207..9ab4f47d 100644 --- a/src/Type/Square/QrCode/MaskNum.php +++ b/src/Type/Square/QrCode/MaskNum.php @@ -38,11 +38,16 @@ abstract class MaskNum * @param int $maskNo Mask number * @param int $width Width * @param array $frame Frame - * @param int $mask Mask + * @param array $mask Mask * * @return int mask number */ - protected function makeMaskNo($maskNo, $width, $frame, &$mask) + protected function makeMaskNo( + int $maskNo, + int $width, + array $frame, + array &$mask + ): int { $bnum = 0; $bitMask = $this->generateMaskNo($maskNo, $width, $frame); @@ -67,7 +72,11 @@ protected function makeMaskNo($maskNo, $width, $frame, &$mask) * * @return array bit mask */ - protected function generateMaskNo($maskNo, $width, $frame) + protected function generateMaskNo( + int $maskNo, + int $width, + array $frame + ): array { $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); for ($ypos = 0; $ypos < $width; ++$ypos) { @@ -91,7 +100,7 @@ protected function generateMaskNo($maskNo, $width, $frame) * * @return int mask */ - protected function mask0($xpos, $ypos) + protected function mask0(int $xpos, int $ypos): int { return (($xpos + $ypos) & 1); } @@ -104,7 +113,7 @@ protected function mask0($xpos, $ypos) * * @return int mask */ - protected function mask1($xpos, $ypos) + protected function mask1(int $xpos, int $ypos): int { $xpos = null; return ($ypos & 1); @@ -118,7 +127,7 @@ protected function mask1($xpos, $ypos) * * @return int mask */ - protected function mask2($xpos, $ypos) + protected function mask2(int $xpos, int $ypos): int { $ypos = null; return ($xpos % 3); @@ -132,7 +141,7 @@ protected function mask2($xpos, $ypos) * * @return int mask */ - protected function mask3($xpos, $ypos) + protected function mask3(int $xpos, int $ypos): int { return (($xpos + $ypos) % 3); } @@ -145,7 +154,7 @@ protected function mask3($xpos, $ypos) * * @return int mask */ - protected function mask4($xpos, $ypos) + protected function mask4(int $xpos, int $ypos): int { return ((((int)($ypos / 2)) + ((int)($xpos / 3))) & 1); } @@ -158,7 +167,7 @@ protected function mask4($xpos, $ypos) * * @return int mask */ - protected function mask5($xpos, $ypos) + protected function mask5(int $xpos, int $ypos): int { return ((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3); } @@ -171,7 +180,7 @@ protected function mask5($xpos, $ypos) * * @return int mask */ - protected function mask6($xpos, $ypos) + protected function mask6(int $xpos, int $ypos): int { return (((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3) & 1); } @@ -184,7 +193,7 @@ protected function mask6($xpos, $ypos) * * @return int mask */ - protected function mask7($xpos, $ypos) + protected function mask7(int $xpos, int $ypos): int { return (((($xpos * $ypos) % 3) + (($xpos + $ypos) & 1)) & 1); } From f422f3dfcb3fd190ee0adbff192981bf3202121e Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 09:27:17 +0000 Subject: [PATCH 054/100] fixes --- src/Type/Square/QrCode/Spec.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Type/Square/QrCode/Spec.php b/src/Type/Square/QrCode/Spec.php index a35480b1..4ce026df 100644 --- a/src/Type/Square/QrCode/Spec.php +++ b/src/Type/Square/QrCode/Spec.php @@ -40,7 +40,7 @@ class Spec extends \Com\Tecnick\Barcode\Type\Square\QrCode\SpecRs * * @return int maximum size (bytes) */ - public function getDataLength($version, $level) + public function getDataLength(int $version, int $level): int { return (Data::CAPACITY[$version][Data::QRCAP_WORDS] - Data::CAPACITY[$version][Data::QRCAP_EC][$level]); } @@ -53,7 +53,7 @@ public function getDataLength($version, $level) * * @return int ECC size (bytes) */ - public function getECCLength($version, $level) + public function getECCLength(int $version, int $level): int { return Data::CAPACITY[$version][Data::QRCAP_EC][$level]; } @@ -65,7 +65,7 @@ public function getECCLength($version, $level) * * @return int width */ - public function getWidth($version) + public function getWidth(int $version): int { return Data::CAPACITY[$version][Data::QRCAP_WIDTH]; } @@ -77,7 +77,7 @@ public function getWidth($version) * * @return int number of remainder bits */ - public function getRemainder($version) + public function getRemainder(int $version): int { return Data::CAPACITY[$version][Data::QRCAP_REMINDER]; } @@ -90,7 +90,7 @@ public function getRemainder($version) * * @return int the maximum length (bytes) */ - public function maximumWords($mode, $version) + public function maximumWords(int $mode, int $version): int { if ($mode == Data::ENC_MODES['ST']) { return 3; @@ -120,7 +120,7 @@ public function maximumWords($mode, $version) * * @return array spec */ - public function getEccSpec($version, $level, $spec) + public function getEccSpec(int $version, int $level, array $spec): array { if (count($spec) < 5) { $spec = array(0, 0, 0, 0, 0); @@ -153,7 +153,7 @@ public function getEccSpec($version, $level, $spec) * * @return int */ - public function getFormatInfo($maskNo, $level) + public function getFormatInfo(int $maskNo, int $level): int { if ( ($maskNo < 0) From a9625c5e8d14d421499087e5410c01683cc48450 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 09:57:24 +0000 Subject: [PATCH 055/100] fixes --- src/Type/Square/QrCode/SpecRs.php | 50 +++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/Type/Square/QrCode/SpecRs.php b/src/Type/Square/QrCode/SpecRs.php index ea4dd1db..237a849b 100644 --- a/src/Type/Square/QrCode/SpecRs.php +++ b/src/Type/Square/QrCode/SpecRs.php @@ -41,7 +41,7 @@ abstract class SpecRs * * @return int value */ - public function rsBlockNum($spec) + public function rsBlockNum(array $spec): int { return ($spec[0] + $spec[3]); } @@ -53,7 +53,7 @@ public function rsBlockNum($spec) * * @return int value */ - public function rsBlockNum1($spec) + public function rsBlockNum1(array $spec): int { return $spec[0]; } @@ -65,7 +65,7 @@ public function rsBlockNum1($spec) * * @return int value */ - public function rsDataCodes1($spec) + public function rsDataCodes1(array $spec): int { return $spec[1]; } @@ -77,7 +77,7 @@ public function rsDataCodes1($spec) * * @return int value */ - public function rsEccCodes1($spec) + public function rsEccCodes1(array $spec): int { return $spec[2]; } @@ -89,7 +89,7 @@ public function rsEccCodes1($spec) * * @return int value */ - public function rsBlockNum2($spec) + public function rsBlockNum2(array $spec): int { return $spec[3]; } @@ -101,7 +101,7 @@ public function rsBlockNum2($spec) * * @return int value */ - public function rsDataCodes2($spec) + public function rsDataCodes2(array $spec): int { return $spec[4]; } @@ -113,7 +113,7 @@ public function rsDataCodes2($spec) * * @return int value */ - public function rsEccCodes2($spec) + public function rsEccCodes2(array $spec): int { return $spec[2]; } @@ -125,7 +125,7 @@ public function rsEccCodes2($spec) * * @return int value */ - public function rsDataLength($spec) + public function rsDataLength(array $spec): int { return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]); } @@ -137,7 +137,7 @@ public function rsDataLength($spec) * * @return int value */ - public function rsEccLength($spec) + public function rsEccLength(array $spec): int { return ($spec[0] + $spec[3]) * $spec[2]; } @@ -147,9 +147,9 @@ public function rsEccLength($spec) * * @param int $version Version * - * @return Array of unsigned char. + * @return array of unsigned char. */ - public function createFrame($version) + public function createFrame(int $version): array { $width = Data::CAPACITY[$version][Data::QRCAP_WIDTH]; $frameLine = str_repeat("\0", $width); @@ -221,7 +221,13 @@ public function createFrame($version) * * @return array srctab */ - public function qrstrset($srctab, $xpos, $ypos, $repl, $replLen = null) + public function qrstrset( + array $srctab, + int $xpos, + int $ypos, + string $repl, + int $replLen = null + ): array { $srctab[$ypos] = substr_replace( $srctab[$ypos], @@ -241,7 +247,11 @@ public function qrstrset($srctab, $xpos, $ypos, $repl, $replLen = null) * * @return array frame */ - public function putAlignmentMarker($frame, $pox, $poy) + public function putAlignmentMarker( + array $frame, + int $pox, + int $poy + ): array { $finder = array( "\xa1\xa1\xa1\xa1\xa1", @@ -267,7 +277,11 @@ public function putAlignmentMarker($frame, $pox, $poy) * * @return array frame */ - public function putFinderPattern($frame, $pox, $poy) + public function putFinderPattern( + array $frame, + int $pox, + int $poy + ): array { $finder = array( "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", @@ -292,7 +306,7 @@ public function putFinderPattern($frame, $pox, $poy) * * @return int */ - public function getVersionPattern($version) + public function getVersionPattern(int $version): int { if (($version < 7) || ($version > Data::QRSPEC_VERSION_MAX)) { return 0; @@ -309,7 +323,11 @@ public function getVersionPattern($version) * * @return array frame */ - public function putAlignmentPattern($version, $frame, $width) + public function putAlignmentPattern( + int $version, + array $frame, + int $width + ): array { if ($version < 2) { return $frame; From 9beba2f7eeaa2c8998622dd51c93dc9427fbb152 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 09:59:29 +0000 Subject: [PATCH 056/100] fixes --- src/Type/Square/QrCode/Split.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Type/Square/QrCode/Split.php b/src/Type/Square/QrCode/Split.php index 68dde4c5..cce1c040 100644 --- a/src/Type/Square/QrCode/Split.php +++ b/src/Type/Square/QrCode/Split.php @@ -19,6 +19,7 @@ use Com\Tecnick\Barcode\Exception as BarcodeException; use Com\Tecnick\Barcode\Type\Square\QrCode\Data; use Com\Tecnick\Barcode\Type\Square\QrCode\ByteStream; +use Com\Tecnick\Barcode\Type\Square\QrCode\EncodingMode; /** * Com\Tecnick\Barcode\Type\Square\QrCode\Split @@ -36,16 +37,16 @@ class Split /** * EncodingMode class object * - * @var \Com\Tecnick\Barcode\Type\Square\QrCode\EncodingMode + * @var EncodingMode */ - protected $bsObj; + protected EncodingMode $bsObj; /** * Input items * * @var array */ - protected $items = array(); + protected array $items = array(); /** * QR code version. @@ -55,14 +56,14 @@ class Split * * @var int */ - protected $version = 0; + protected int $version = 0; /** * Encoding mode * * @var int */ - protected $hint = 2; + protected int $hint = 2; /** * Initialize @@ -71,7 +72,11 @@ class Split * @param int $hint Encoding mode * @param int $version Code version */ - public function __construct($bsObj, $hint, $version) + public function __construct( + ByteStream $bsObj, + int $hint, + int $version + ) { $this->bsObj = $bsObj; $this->items = array(); @@ -86,7 +91,7 @@ public function __construct($bsObj, $hint, $version) * * @return array items */ - public function getSplittedString($data) + public function getSplittedString(string $data): array { while (strlen($data) > 0) { $mode = $this->bsObj->getEncodingMode($data, 0); @@ -126,7 +131,7 @@ public function getSplittedString($data) * * @return int run */ - protected function eatNum($data) + protected function eatNum(string $data): int { $lng = $this->bsObj->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); $pos = 0; @@ -163,9 +168,10 @@ protected function eatNum($data) * eatAn * * @param string $data Data + * * @return int run */ - protected function eatAn($data) + protected function eatAn(string $data): int { $lag = $this->bsObj->getLengthIndicator(Data::ENC_MODES['AN'], $this->version); $lng = $this->bsObj->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); @@ -209,9 +215,10 @@ protected function eatAn($data) * eatKanji * * @param string $data Data + * * @return int run */ - protected function eatKanji($data) + protected function eatKanji(string $data): int { $pos = 0; while ($this->bsObj->getEncodingMode($data, $pos) == Data::ENC_MODES['KJ']) { @@ -230,9 +237,10 @@ protected function eatKanji($data) * eat8 * * @param string $data Data + * * @return int run */ - protected function eat8($data) + protected function eat8(string $data): int { $lag = $this->bsObj->getLengthIndicator(Data::ENC_MODES['AN'], $this->version); $lng = $this->bsObj->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); From 47a440be53e179039d48bc211dd68866bc3de88c Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 10:02:37 +0000 Subject: [PATCH 057/100] rector --- example/index.php | 56 +- src/Barcode.php | 41 +- src/Type.php | 195 +- src/Type/Convert.php | 79 +- src/Type/Linear/Codabar.php | 32 +- src/Type/Linear/CodeNineThree.php | 195 +- src/Type/Linear/CodeOneOne.php | 42 +- src/Type/Linear/CodeOneTwoEight.php | 13 +- .../CodeOneTwoEight/CodeOneTwoEightA.php | 2 +- .../CodeOneTwoEight/CodeOneTwoEightB.php | 2 +- .../CodeOneTwoEight/CodeOneTwoEightC.php | 3 +- src/Type/Linear/CodeOneTwoEight/Process.php | Bin 12019 -> 12544 bytes src/Type/Linear/CodeThreeNineExtCheck.php | 105 +- src/Type/Linear/EanEight.php | 6 +- src/Type/Linear/EanFive.php | 19 +- src/Type/Linear/EanOneThree.php | 107 +- src/Type/Linear/EanTwo.php | 63 +- src/Type/Linear/Imb.php | 107 +- src/Type/Linear/ImbPre.php | 13 +- src/Type/Linear/InterleavedTwoOfFiveCheck.php | 30 +- src/Type/Linear/KlantIndex.php | 2 +- src/Type/Linear/MsiCheck.php | 26 +- src/Type/Linear/Pharma.php | 6 +- src/Type/Linear/PharmaTwoTracks.php | 12 +- src/Type/Linear/Planet.php | 13 +- src/Type/Linear/Postnet.php | 31 +- src/Type/Linear/RoyalMailFourCc.php | 99 +- src/Type/Linear/StandardTwoOfFiveCheck.php | 27 +- src/Type/Linear/UpcA.php | 2 - src/Type/Linear/UpcE.php | 41 +- src/Type/Raw.php | 23 +- src/Type/Square/Aztec.php | 25 +- src/Type/Square/Aztec/Bitstream.php | 117 +- src/Type/Square/Aztec/Codeword.php | 72 +- src/Type/Square/Aztec/Data.php | 1044 ++-- src/Type/Square/Aztec/Encode.php | 100 +- src/Type/Square/Aztec/ErrorCorrection.php | 70 +- src/Type/Square/Aztec/Layers.php | 35 +- src/Type/Square/Datamatrix.php | 57 +- src/Type/Square/Datamatrix/Data.php | 693 +-- src/Type/Square/Datamatrix/Encode.php | 81 +- src/Type/Square/Datamatrix/EncodeTxt.php | 52 +- .../Square/Datamatrix/ErrorCorrection.php | 14 +- src/Type/Square/Datamatrix/Modes.php | 52 +- src/Type/Square/Datamatrix/Placement.php | 41 +- src/Type/Square/Datamatrix/Steps.php | 62 +- src/Type/Square/PdfFourOneSeven.php | 76 +- .../Square/PdfFourOneSeven/Compaction.php | 46 +- src/Type/Square/PdfFourOneSeven/Data.php | 4707 +++++++++++++++-- src/Type/Square/PdfFourOneSeven/Sequence.php | 40 +- src/Type/Square/QrCode.php | 43 +- src/Type/Square/QrCode/ByteStream.php | 56 +- src/Type/Square/QrCode/Data.php | 533 +- src/Type/Square/QrCode/Encode.php | 32 +- src/Type/Square/QrCode/Encoder.php | 43 +- src/Type/Square/QrCode/EncodingMode.php | 42 +- src/Type/Square/QrCode/Estimate.php | 39 +- src/Type/Square/QrCode/Init.php | 107 +- src/Type/Square/QrCode/InputItem.php | 48 +- src/Type/Square/QrCode/Mask.php | 149 +- src/Type/Square/QrCode/MaskNum.php | 11 +- src/Type/Square/QrCode/Spec.php | 10 +- src/Type/Square/QrCode/SpecRs.php | 55 +- src/Type/Square/QrCode/Split.php | 156 +- test/BarcodeTest.php | 121 +- test/Linear/CodabarTest.php | 18 +- test/Linear/CodeNineThreeTest.php | 18 +- test/Linear/CodeOneOneTest.php | 20 +- .../CodeOneTwoEight/CodeOneTwoEightATest.php | 20 +- .../CodeOneTwoEight/CodeOneTwoEightBTest.php | 18 +- .../CodeOneTwoEight/CodeOneTwoEightCTest.php | 30 +- test/Linear/CodeOneTwoEightTest.php | 50 +- test/Linear/CodeThreeNineCheckTest.php | 10 +- test/Linear/CodeThreeNineExtCheckTest.php | 18 +- test/Linear/CodeThreeNineExtTest.php | 10 +- test/Linear/CodeThreeNineTest.php | 18 +- test/Linear/EanEightTest.php | 10 +- test/Linear/EanFiveTest.php | 10 +- test/Linear/EanOneThreeTest.php | 28 +- test/Linear/EanTwoTest.php | 10 +- test/Linear/ImbPreTest.php | 18 +- test/Linear/ImbTest.php | 28 +- test/Linear/InterleavedTwoOfFiveCheckTest.php | 18 +- test/Linear/InterleavedTwoOfFiveTest.php | 10 +- test/Linear/KlantIndexTest.php | 10 +- test/Linear/MsiCheckTest.php | 18 +- test/Linear/MsiTest.php | 10 +- test/Linear/PharmaTest.php | 10 +- test/Linear/PharmaTwoTracksTest.php | 10 +- test/Linear/PlanetTest.php | 10 +- test/Linear/PostnetTest.php | 18 +- test/Linear/RawTest.php | 9 +- test/Linear/RoyalMailFourCcTest.php | 18 +- test/Linear/StandardTwoOfFiveCheckTest.php | 18 +- test/Linear/StandardTwoOfFiveTest.php | 10 +- test/Linear/UpcATest.php | 10 +- test/Linear/UpcETest.php | 36 +- test/Square/AztecTest.php | 137 +- test/Square/DatamatrixTest.php | 738 ++- test/Square/PdfFourOneSevenTest.php | 2666 +++++----- test/Square/QrCodeTest.php | 3217 ++++++----- test/Square/RawTest.php | 10 +- test/TestStrings.php | 48 +- 103 files changed, 10304 insertions(+), 7282 deletions(-) diff --git a/example/index.php b/example/index.php index 8d0f0cfd..8f9bf0d3 100644 --- a/example/index.php +++ b/example/index.php @@ -14,75 +14,31 @@ */ // autoloader when using Composer -require ('../vendor/autoload.php'); +require (__DIR__ . '/../vendor/autoload.php'); // autoloader when using RPM or DEB package installation //require ('/usr/share/php/Com/Tecnick/Barcode/autoload.php'); // data to generate for each barcode type -$linear = array( - 'C128A' => array('0123456789', 'CODE 128 A'), - 'C128B' => array('0123456789', 'CODE 128 B'), - 'C128C' => array('0123456789', 'CODE 128 C'), - 'C128' => array('0123456789', 'CODE 128'), - 'C39E+' => array('0123456789', 'CODE 39 EXTENDED + CHECKSUM'), - 'C39E' => array('0123456789', 'CODE 39 EXTENDED'), - 'C39+' => array('0123456789', 'CODE 39 + CHECKSUM'), - 'C39' => array('0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'), - 'C93' => array('0123456789', 'CODE 93 - USS-93'), - 'CODABAR' => array('0123456789', 'CODABAR'), - 'CODE11' => array('0123456789', 'CODE 11'), - 'EAN13' => array('0123456789', 'EAN 13'), - 'EAN2' => array('12', 'EAN 2-Digits UPC-Based Extension'), - 'EAN5' => array('12345', 'EAN 5-Digits UPC-Based Extension'), - 'EAN8' => array('1234567', 'EAN 8'), - 'I25+' => array('0123456789', 'Interleaved 2 of 5 + CHECKSUM'), - 'I25' => array('0123456789', 'Interleaved 2 of 5'), - 'IMB' => array('01234567094987654321-01234567891', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'), - 'IMBPRE' => array('AADTFFDFTDADTAADAATFDTDDAAADDTDTTDAFADADDDTFFFDDTTTADFAAADFTDAADA', 'IMB pre-processed'), - 'KIX' => array('0123456789', 'KIX (Klant index - Customer index)'), - 'MSI+' => array('0123456789', 'MSI + CHECKSUM (modulo 11)'), - 'MSI' => array('0123456789', 'MSI (Variation of Plessey code)'), - 'PHARMA2T' => array('0123456789', 'PHARMACODE TWO-TRACKS'), - 'PHARMA' => array('0123456789', 'PHARMACODE'), - 'PLANET' => array('0123456789', 'PLANET'), - 'POSTNET' => array('0123456789', 'POSTNET'), - 'RMS4CC' => array('0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'), - 'S25+' => array('0123456789', 'Standard 2 of 5 + CHECKSUM'), - 'S25' => array('0123456789', 'Standard 2 of 5'), - 'UPCA' => array('72527273070', 'UPC-A'), - 'UPCE' => array('725277', 'UPC-E'), -); +$linear = ['C128A' => ['0123456789', 'CODE 128 A'], 'C128B' => ['0123456789', 'CODE 128 B'], 'C128C' => ['0123456789', 'CODE 128 C'], 'C128' => ['0123456789', 'CODE 128'], 'C39E+' => ['0123456789', 'CODE 39 EXTENDED + CHECKSUM'], 'C39E' => ['0123456789', 'CODE 39 EXTENDED'], 'C39+' => ['0123456789', 'CODE 39 + CHECKSUM'], 'C39' => ['0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'], 'C93' => ['0123456789', 'CODE 93 - USS-93'], 'CODABAR' => ['0123456789', 'CODABAR'], 'CODE11' => ['0123456789', 'CODE 11'], 'EAN13' => ['0123456789', 'EAN 13'], 'EAN2' => ['12', 'EAN 2-Digits UPC-Based Extension'], 'EAN5' => ['12345', 'EAN 5-Digits UPC-Based Extension'], 'EAN8' => ['1234567', 'EAN 8'], 'I25+' => ['0123456789', 'Interleaved 2 of 5 + CHECKSUM'], 'I25' => ['0123456789', 'Interleaved 2 of 5'], 'IMB' => ['01234567094987654321-01234567891', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'], 'IMBPRE' => ['AADTFFDFTDADTAADAATFDTDDAAADDTDTTDAFADADDDTFFFDDTTTADFAAADFTDAADA', 'IMB pre-processed'], 'KIX' => ['0123456789', 'KIX (Klant index - Customer index)'], 'MSI+' => ['0123456789', 'MSI + CHECKSUM (modulo 11)'], 'MSI' => ['0123456789', 'MSI (Variation of Plessey code)'], 'PHARMA2T' => ['0123456789', 'PHARMACODE TWO-TRACKS'], 'PHARMA' => ['0123456789', 'PHARMACODE'], 'PLANET' => ['0123456789', 'PLANET'], 'POSTNET' => ['0123456789', 'POSTNET'], 'RMS4CC' => ['0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'], 'S25+' => ['0123456789', 'Standard 2 of 5 + CHECKSUM'], 'S25' => ['0123456789', 'Standard 2 of 5'], 'UPCA' => ['72527273070', 'UPC-A'], 'UPCE' => ['725277', 'UPC-E']]; -$square = array( - 'LRAW' => array('0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'), - 'SRAW' => array('0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)'), - 'AZTEC' => array('ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'), - 'AZTEC,50,A,A' => array('ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'), - 'PDF417' => array('0123456789', 'PDF417 (ISO/IEC 15438:2006)'), - 'QRCODE' => array('0123456789', 'QR-CODE'), - 'QRCODE,H,ST,0,0' => array('abcdefghijklmnopqrstuvwxy0123456789', 'QR-CODE WITH PARAMETERS'), - 'DATAMATRIX' => array('0123456789', 'DATAMATRIX (ISO/IEC 16022) SQUARE'), - 'DATAMATRIX,R' => array('0123456789012345678901234567890123456789', 'DATAMATRIX Rectangular (ISO/IEC 16022) RECTANGULAR'), - 'DATAMATRIX,S,GS1' => array(chr(232).'01095011010209171719050810ABCD1234'.chr(232).'2110', 'GS1 DATAMATRIX (ISO/IEC 16022) SQUARE GS1'), - 'DATAMATRIX,R,GS1' => array(chr(232).'01095011010209171719050810ABCD1234'.chr(232).'2110', 'GS1 DATAMATRIX (ISO/IEC 16022) RECTANGULAR GS1'), -); +$square = ['LRAW' => ['0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'], 'SRAW' => ['0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)'], 'AZTEC' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'], 'AZTEC,50,A,A' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'], 'PDF417' => ['0123456789', 'PDF417 (ISO/IEC 15438:2006)'], 'QRCODE' => ['0123456789', 'QR-CODE'], 'QRCODE,H,ST,0,0' => ['abcdefghijklmnopqrstuvwxy0123456789', 'QR-CODE WITH PARAMETERS'], 'DATAMATRIX' => ['0123456789', 'DATAMATRIX (ISO/IEC 16022) SQUARE'], 'DATAMATRIX,R' => ['0123456789012345678901234567890123456789', 'DATAMATRIX Rectangular (ISO/IEC 16022) RECTANGULAR'], 'DATAMATRIX,S,GS1' => [chr(232).'01095011010209171719050810ABCD1234'.chr(232).'2110', 'GS1 DATAMATRIX (ISO/IEC 16022) SQUARE GS1'], 'DATAMATRIX,R,GS1' => [chr(232).'01095011010209171719050810ABCD1234'.chr(232).'2110', 'GS1 DATAMATRIX (ISO/IEC 16022) RECTANGULAR GS1']]; $barcode = new \Com\Tecnick\Barcode\Barcode(); $examples = '

    Linear

    '."\n"; foreach ($linear as $type => $code) { - $bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30, 'black', array(0, 0, 0, 0)); + $bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30, 'black', [0, 0, 0, 0]); $examples .= '

    ['.$type.'] '.$code[1].'

    '.$bobj->getHtmlDiv().'

    '."\n"; } $examples .= '

    Square

    '."\n"; foreach ($square as $type => $code) { - $bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4, 'black', array(0, 0, 0, 0)); + $bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4, 'black', [0, 0, 0, 0]); $examples .= '

    ['.$type.'] '.$code[1].'

    '.$bobj->getHtmlDiv().'

    '."\n"; } -$bobj = $barcode->getBarcodeObj('QRCODE,H', 'https://tecnick.com', -4, -4, 'black', array(-2, -2, -2, -2))->setBackgroundColor('#f0f0f0'); +$bobj = $barcode->getBarcodeObj('QRCODE,H', 'https://tecnick.com', -4, -4, 'black', [-2, -2, -2, -2])->setBackgroundColor('#f0f0f0'); echo " diff --git a/src/Barcode.php b/src/Barcode.php index 6679c30b..4077044a 100644 --- a/src/Barcode.php +++ b/src/Barcode.php @@ -38,45 +38,7 @@ class Barcode * * @var array */ - public const BARCODETYPES = array( - 'C128' => 'CODE 128', - 'C128A' => 'CODE 128 A', - 'C128B' => 'CODE 128 B', - 'C128C' => 'CODE 128 C', - 'C39' => 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.', - 'C39+' => 'CODE 39 + CHECKSUM', - 'C39E' => 'CODE 39 EXTENDED', - 'C39E+' => 'CODE 39 EXTENDED + CHECKSUM', - 'C93' => 'CODE 93 - USS-93', - 'CODABAR' => 'CODABAR', - 'CODE11' => 'CODE 11', - 'EAN13' => 'EAN 13', - 'EAN2' => 'EAN 2-Digits UPC-Based Extension', - 'EAN5' => 'EAN 5-Digits UPC-Based Extension', - 'EAN8' => 'EAN 8', - 'I25' => 'Interleaved 2 of 5', - 'I25+' => 'Interleaved 2 of 5 + CHECKSUM', - 'IMB' => 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200', - 'IMBPRE' => 'IMB - Intelligent Mail Barcode pre-processed', - 'KIX' => 'KIX (Klant index - Customer index)', - 'LRAW' => '1D RAW MODE (comma-separated rows of 01 strings)', - 'MSI' => 'MSI (Variation of Plessey code)', - 'MSI+' => 'MSI + CHECKSUM (modulo 11)', - 'PHARMA' => 'PHARMACODE', - 'PHARMA2T' => 'PHARMACODE TWO-TRACKS', - 'PLANET' => 'PLANET', - 'POSTNET' => 'POSTNET', - 'RMS4CC' => 'RMS4CC (Royal Mail 4-state Customer Bar Code)', - 'S25' => 'Standard 2 of 5', - 'S25+' => 'Standard 2 of 5 + CHECKSUM', - 'UPCA' => 'UPC-A', - 'UPCE' => 'UPC-E', - 'AZTEC' => 'AZTEC Code (ISO/IEC 24778:2008)', - 'DATAMATRIX' => 'DATAMATRIX (ISO/IEC 16022)', - 'PDF417' => 'PDF417 (ISO/IEC 15438:2006)', - 'QRCODE' => 'QR-CODE', - 'SRAW' => '2D RAW MODE (comma-separated rows of 01 strings)', - ); + public const BARCODETYPES = ['C128' => 'CODE 128', 'C128A' => 'CODE 128 A', 'C128B' => 'CODE 128 B', 'C128C' => 'CODE 128 C', 'C39' => 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.', 'C39+' => 'CODE 39 + CHECKSUM', 'C39E' => 'CODE 39 EXTENDED', 'C39E+' => 'CODE 39 EXTENDED + CHECKSUM', 'C93' => 'CODE 93 - USS-93', 'CODABAR' => 'CODABAR', 'CODE11' => 'CODE 11', 'EAN13' => 'EAN 13', 'EAN2' => 'EAN 2-Digits UPC-Based Extension', 'EAN5' => 'EAN 5-Digits UPC-Based Extension', 'EAN8' => 'EAN 8', 'I25' => 'Interleaved 2 of 5', 'I25+' => 'Interleaved 2 of 5 + CHECKSUM', 'IMB' => 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200', 'IMBPRE' => 'IMB - Intelligent Mail Barcode pre-processed', 'KIX' => 'KIX (Klant index - Customer index)', 'LRAW' => '1D RAW MODE (comma-separated rows of 01 strings)', 'MSI' => 'MSI (Variation of Plessey code)', 'MSI+' => 'MSI + CHECKSUM (modulo 11)', 'PHARMA' => 'PHARMACODE', 'PHARMA2T' => 'PHARMACODE TWO-TRACKS', 'PLANET' => 'PLANET', 'POSTNET' => 'POSTNET', 'RMS4CC' => 'RMS4CC (Royal Mail 4-state Customer Bar Code)', 'S25' => 'Standard 2 of 5', 'S25+' => 'Standard 2 of 5 + CHECKSUM', 'UPCA' => 'UPC-A', 'UPCE' => 'UPC-E', 'AZTEC' => 'AZTEC Code (ISO/IEC 24778:2008)', 'DATAMATRIX' => 'DATAMATRIX (ISO/IEC 16022)', 'PDF417' => 'PDF417 (ISO/IEC 15438:2006)', 'QRCODE' => 'QR-CODE', 'SRAW' => '2D RAW MODE (comma-separated rows of 01 strings)']; /** * Get the barcode object @@ -91,7 +53,6 @@ class Barcode * @param array{int, int, int, int} $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. * A negative value indicates the multiplication factor for each row or column. * - * @return Type * * @throws BarcodeException in case of error */ diff --git a/src/Type.php b/src/Type.php index 6c3e0954..2da4e1fa 100644 --- a/src/Type.php +++ b/src/Type.php @@ -99,12 +99,12 @@ public function setSize( array $padding = [0, 0, 0, 0] ): static { - $this->width = intval($width); + $this->width = $width; if ($this->width <= 0) { $this->width = (abs(min(-1, $this->width)) * $this->ncols); } - $this->height = intval($height); + $this->height = $height; if ($this->height <= 0) { $this->height = (abs(min(-1, $this->height)) * $this->nrows); } @@ -130,17 +130,14 @@ protected function setPadding(array $padding): static if (!is_array($padding) || (count($padding) != 4)) { throw new BarcodeException('Invalid padding, expecting an array of 4 numbers (top, right, bottom, left)'); } - $map = array( - array('T', $this->height_ratio), - array('R', $this->width_ratio), - array('B', $this->height_ratio), - array('L', $this->width_ratio) - ); + + $map = [['T', $this->height_ratio], ['R', $this->width_ratio], ['B', $this->height_ratio], ['L', $this->width_ratio]]; foreach ($padding as $key => $val) { - $val = intval($val); + $val = (int) $val; if ($val < 0) { $val = (abs(min(-1, $val)) * $map[$key][1]); } + $this->padding[$map[$key][0]] = $val; } @@ -159,9 +156,10 @@ protected function setPadding(array $padding): static public function setColor(string $color): static { $this->color_obj = $this->getRgbColorObject($color); - if ($this->color_obj === null) { + if (!$this->color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { throw new BarcodeException('The foreground color cannot be empty or transparent'); } + return $this; } @@ -183,52 +181,30 @@ public function setBackgroundColor(string $color): static * * @param string $color Color in Web notation (color name, or hexadecimal code, or CSS syntax) * - * @return Rgb|null * * @throws ColorException in case of color error */ protected function getRgbColorObject(string $color): ?Rgb { - $conv = new Pdf(); - $cobj = $conv->getColorObject($color); - if ($cobj !== null) { + $pdf = new Pdf(); + $cobj = $pdf->getColorObject($color); + if ($cobj instanceof \Com\Tecnick\Color\Model) { return new Rgb($cobj->toRgbArray()); } + return null; } /** * Get the barcode raw array - * - * @return array */ public function getArray(): array { - return array( - 'type' => $this::TYPE, - 'format' => $this::FORMAT, - 'params' => $this->params, - 'code' => $this->code, - 'extcode' => $this->extcode, - 'ncols' => $this->ncols, - 'nrows' => $this->nrows, - 'width' => $this->width, - 'height' => $this->height, - 'width_ratio' => $this->width_ratio, - 'height_ratio' => $this->height_ratio, - 'padding' => $this->padding, - 'full_width' => ($this->width + $this->padding['L'] + $this->padding['R']), - 'full_height' => ($this->height + $this->padding['T'] + $this->padding['B']), - 'color_obj' => $this->color_obj, - 'bg_color_obj' => $this->bg_color_obj, - 'bars' => $this->bars - ); + return ['type' => $this::TYPE, 'format' => $this::FORMAT, 'params' => $this->params, 'code' => $this->code, 'extcode' => $this->extcode, 'ncols' => $this->ncols, 'nrows' => $this->nrows, 'width' => $this->width, 'height' => $this->height, 'width_ratio' => $this->width_ratio, 'height_ratio' => $this->height_ratio, 'padding' => $this->padding, 'full_width' => ($this->width + $this->padding['L'] + $this->padding['R']), 'full_height' => ($this->height + $this->padding['T'] + $this->padding['B']), 'color_obj' => $this->color_obj, 'bg_color_obj' => $this->bg_color_obj, 'bars' => $this->bars]; } /** * Get the extended code (code + checksum) - * - * @return string|array */ public function getExtendedCode(): string|array { @@ -240,18 +216,19 @@ public function getExtendedCode(): string|array */ public function getSvg(): void { - $data = $this->getSvgCode(); + $svgCode = $this->getSvgCode(); header('Content-Type: application/svg+xml'); header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1'); header('Pragma: public'); header('Expires: Thu, 04 jan 1973 00:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - header('Content-Disposition: inline; filename="' . md5($data) . '.svg";'); + header('Content-Disposition: inline; filename="' . md5($svgCode) . '.svg";'); if (empty($_SERVER['HTTP_ACCEPT_ENCODING'])) { // the content length may vary if the server is using compression - header('Content-Length: ' . strlen($data)); + header('Content-Length: ' . strlen($svgCode)); } - echo $data; + + echo $svgCode; } /** @@ -266,6 +243,7 @@ public function getSvgCode(): string if (defined('ENT_XML1') && defined('ENT_DISALLOWED')) { $hflag = ENT_XML1 | ENT_DISALLOWED; } + $width = sprintf('%F', ($this->width + $this->padding['L'] + $this->padding['R'])); $height = sprintf('%F', ($this->height + $this->padding['T'] + $this->padding['B'])); $svg = '' . "\n" @@ -279,11 +257,8 @@ public function getSvgCode(): string . ' xmlns="http://www.w3.org/2000/svg"' . '>' . "\n" . "\t" . '' . htmlspecialchars($this->code, $hflag, 'UTF-8') . '' . "\n"; - if ($this->bg_color_obj !== null) { - $svg .= "\t" . 'bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { + $svg .= ' ' . "\n"; } - $svg .= "\t" . 'color_obj->getRgbHexColor() . '"' . ' stroke="none"' . ' stroke-width="0"' . ' stroke-linecap="square"' . '>' . "\n"; $bars = $this->getBarsArray('XYWH'); - foreach ($bars as $rect) { - $svg .= "\t\t" . '' . "\n"; } - $svg .= "\t" . '' . "\n" - . '' . "\n"; - return $svg; + + return $svg . (' ' . "\n" + . '' . "\n"); } /** @@ -319,33 +292,33 @@ public function getSvgCode(): string */ public function getHtmlDiv(): string { - $html = '
    width + $this->padding['L'] + $this->padding['R'])) . 'px;' . 'height:' . sprintf('%F', ($this->height + $this->padding['T'] + $this->padding['B'])) . 'px;' . 'position:relative;' . 'font-size:0;' . 'border:none;' . 'padding:0;' . 'margin:0;'; - if ($this->bg_color_obj !== null) { + if ($this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { $html .= 'background-color:' . $this->bg_color_obj->getCssColor() . ';'; } + $html .= '">' . "\n"; $bars = $this->getBarsArray('XYWH'); - foreach ($bars as $rect) { - $html .= "\t" . '
    color_obj->getCssColor() . ';' + . 'left:' . sprintf('%F', $bar[0]) . 'px;' + . 'top:' . sprintf('%F', $bar[1]) . 'px;' + . 'width:' . sprintf('%F', $bar[2]) . 'px;' + . 'height:' . sprintf('%F', $bar[3]) . 'px;' . 'position:absolute;' . 'border:none;' . 'padding:0;' . 'margin:0;' . '"> 
    ' . "\n"; } - $html .= '
    ' . "\n"; - return $html; + + return $html . ('
    ' . "\n"); } /** @@ -353,18 +326,19 @@ public function getHtmlDiv(): string */ public function getPng(): void { - $data = $this->getPngData(); + $pngData = $this->getPngData(); header('Content-Type: image/png'); header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1'); header('Pragma: public'); header('Expires: Thu, 04 jan 1973 00:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - header('Content-Disposition: inline; filename="' . md5($data) . '.png";'); + header('Content-Disposition: inline; filename="' . md5($pngData) . '.png";'); if (empty($_SERVER['HTTP_ACCEPT_ENCODING'])) { // the content length may vary if the server is using compression - header('Content-Length: ' . strlen($data)); + header('Content-Length: ' . strlen($pngData)); } - echo $data; + + echo $pngData; } /** @@ -379,47 +353,48 @@ public function getPngData(bool $imagick = true): string if ($imagick && extension_loaded('imagick')) { return $this->getPngDataImagick(); } - $img = $this->getGd(); + + $gdImage = $this->getGd(); ob_start(); - imagepng($img); + imagepng($gdImage); return ob_get_clean(); } /** * Get the barcode as PNG image (requires Imagick library) * - * @return string * * @throws BarcodeException if the Imagick library is not installed */ public function getPngDataImagick(): string { - $img = new \Imagick(); + $imagick = new \Imagick(); $width = (int)ceil($this->width + $this->padding['L'] + $this->padding['R']); $height = (int)ceil($this->height + $this->padding['T'] + $this->padding['B']); - $img->newImage($width, $height, 'none', 'png'); - $barcode = new \imagickdraw(); - if ($this->bg_color_obj !== null) { + $imagick->newImage($width, $height, 'none', 'png'); + $imagickdraw = new \imagickdraw(); + if ($this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { $rgbcolor = $this->bg_color_obj->getNormalizedArray(255); $bg_color = new \imagickpixel('rgb(' . $rgbcolor['R'] . ',' . $rgbcolor['G'] . ',' . $rgbcolor['B'] . ')'); - $barcode->setfillcolor($bg_color); - $barcode->rectangle(0, 0, $width, $height); + $imagickdraw->setfillcolor($bg_color); + $imagickdraw->rectangle(0, 0, $width, $height); } + $rgbcolor = $this->color_obj->getNormalizedArray(255); $bar_color = new \imagickpixel('rgb(' . $rgbcolor['R'] . ',' . $rgbcolor['G'] . ',' . $rgbcolor['B'] . ')'); - $barcode->setfillcolor($bar_color); + $imagickdraw->setfillcolor($bar_color); $bars = $this->getBarsArray('XYXY'); - foreach ($bars as $rect) { - $barcode->rectangle($rect[0], $rect[1], $rect[2], $rect[3]); + foreach ($bars as $bar) { + $imagickdraw->rectangle($bar[0], $bar[1], $bar[2], $bar[3]); } - $img->drawimage($barcode); - return $img->getImageBlob(); + + $imagick->drawimage($imagickdraw); + return $imagick->getImageBlob(); } /** * Get the barcode as GD image object (requires GD library) * - * @return \GdImage * * @throws BarcodeException if the GD library is not installed */ @@ -428,7 +403,7 @@ public function getGd(): \GdImage $width = (int)ceil($this->width + $this->padding['L'] + $this->padding['R']); $height = (int)ceil($this->height + $this->padding['T'] + $this->padding['B']); $img = imagecreate($width, $height); - if ($this->bg_color_obj === null) { + if (!$this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { $bgobj = clone $this->color_obj; $rgbcolor = $bgobj->invertColor()->getNormalizedArray(255); $background_color = imagecolorallocate($img, $rgbcolor['R'], $rgbcolor['G'], $rgbcolor['B']); @@ -438,19 +413,21 @@ public function getGd(): \GdImage $bg_color = imagecolorallocate($img, $rgbcolor['R'], $rgbcolor['G'], $rgbcolor['B']); imagefilledrectangle($img, 0, 0, $width, $height, $bg_color); } + $rgbcolor = $this->color_obj->getNormalizedArray(255); $bar_color = imagecolorallocate($img, $rgbcolor['R'], $rgbcolor['G'], $rgbcolor['B']); $bars = $this->getBarsArray('XYXY'); - foreach ($bars as $rect) { + foreach ($bars as $bar) { imagefilledrectangle( $img, - (int)floor($rect[0]), - (int)floor($rect[1]), - (int)floor($rect[2]), - (int)floor($rect[3]), + (int)floor($bar[0]), + (int)floor($bar[1]), + (int)floor($bar[2]), + (int)floor($bar[3]), $bar_color ); } + return $img; } @@ -459,8 +436,6 @@ public function getGd(): \GdImage * * @param string $space_char Character or string to use for filling empty spaces * @param string $bar_char Character or string to use for filling bars - * - * @return string */ public function getGrid( string $space_char = '0', @@ -470,8 +445,9 @@ public function getGrid( $raw = $this->getGridArray($space_char, $bar_char); $grid = ''; foreach ($raw as $row) { - $grid .= implode($row) . "\n"; + $grid .= implode('', $row) . "\n"; } + return $grid; } @@ -479,8 +455,6 @@ public function getGrid( * Get the array containing all the formatted bars coordinates * * @param string $type Type of coordinates to return: 'XYXY' or 'XYWH' - * - * @return array */ public function getBarsArray( string $type = 'XYXY' @@ -491,22 +465,35 @@ public function getBarsArray( 'XYWH' => 'getBarRectXYWH', }; - $rect = array(); + $rect = []; foreach ($this->bars as $bar) { - if (($bar[2] > 0) && ($bar[3] > 0)) { - $rect[] = $this->$mtd($bar); + if ($bar[2] <= 0) { + continue; } + + if ($bar[3] <= 0) { + continue; + } + + $rect[] = $this->$mtd($bar); } if ($this->nrows > 1) { // reprint rotated to cancel row gaps $rot = $this->getRotatedBarArray(); foreach ($rot as $bar) { - if (($bar[2] > 0) && ($bar[3] > 0)) { - $rect[] = $this->$mtd($bar); + if ($bar[2] <= 0) { + continue; + } + + if ($bar[3] <= 0) { + continue; } + + $rect[] = $this->$mtd($bar); } } + return $rect; } } diff --git a/src/Type/Convert.php b/src/Type/Convert.php index c670bc52..9b5be11b 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -50,58 +50,42 @@ abstract class Convert /** * Array containing extra parameters for the specified barcode type - * - * @var array */ protected array $params = []; /** * Code to convert (barcode content) - * - * @var string|array */ protected string|array $code = ''; /** * Resulting code after applying checksum etc. - * - * @var string|array */ protected string|array $extcode = ''; /** * Total number of columns - * - * @var int */ protected int $ncols = 0; /** * Total number of rows - * - * @var int */ protected int $nrows = 1; /** * Array containing the position and dimensions of each barcode bar * (x, y, width, height) - * - * @var array */ - protected array $bars = array(); + protected array $bars = []; /** * Barcode width - * - * @var int */ protected int $width = 0; /** * Barcode height - * - * @var int */ protected int $height = 0; @@ -115,29 +99,21 @@ abstract class Convert /** * Ratio between the barcode width and the number of rows - * - * @var float */ protected float $width_ratio = 0; /** * Ratio between the barcode height and the number of columns - * - * @var float */ protected float $height_ratio = 0; /** * Foreground Color object - * - * @var ?Color */ protected ?Color $color_obj = null; /** * Backgorund Color object - * - * @var ?Color */ protected ?Color $bg_color_obj = null; @@ -167,13 +143,15 @@ protected function convertDecToHex(string $number): string if ($number == 0) { return '00'; } - $hex = array(); + + $hex = []; while ($number > 0) { - array_push($hex, strtoupper((string)dechex((int)bcmod($number, '16')))); + $hex[] = strtoupper(dechex((int)bcmod($number, '16'))); $number = bcdiv($number, '16', 0); } + $hex = array_reverse($hex); - return implode($hex); + return implode('', $hex); } /** @@ -192,6 +170,7 @@ protected function convertHexToDec(string $hex): string $dec = bcadd($dec, bcmul((string)hexdec($hex[$pos]), $bitval)); $bitval = bcmul($bitval, '16'); } + return $dec; } @@ -200,8 +179,6 @@ protected function convertHexToDec(string $hex): string * * @param string $space_char Character or string to use for filling empty spaces * @param string $bar_char Character or string to use for filling bars - * - * @return array */ public function getGridArray( string $space_char = '0', @@ -210,27 +187,32 @@ public function getGridArray( { $raw = array_fill(0, $this->nrows, array_fill(0, $this->ncols, $space_char)); foreach ($this->bars as $bar) { - if (($bar[2] > 0) && ($bar[3] > 0)) { - for ($vert = 0; $vert < $bar[3]; ++$vert) { - for ($horiz = 0; $horiz < $bar[2]; ++$horiz) { - $raw[($bar[1] + $vert)][($bar[0] + $horiz)] = $bar_char; - } + if ($bar[2] <= 0) { + continue; + } + + if ($bar[3] <= 0) { + continue; + } + + for ($vert = 0; $vert < $bar[3]; ++$vert) { + for ($horiz = 0; $horiz < $bar[2]; ++$horiz) { + $raw[($bar[1] + $vert)][($bar[0] + $horiz)] = $bar_char; } } } + return $raw; } /** * Returns the bars array ordered by columns - * - * @return array */ protected function getRotatedBarArray(): array { $grid = $this->getGridArray(); - $cols = call_user_func_array('array_map', array(-1 => null) + $grid); - $bars = array(); + $cols = array_map(...[-1 => null] + $grid); + $bars = []; foreach ($cols as $posx => $col) { $prevrow = ''; $bar_height = 0; @@ -238,14 +220,17 @@ protected function getRotatedBarArray(): array for ($posy = 0; $posy <= $this->nrows; ++$posy) { if ($col[$posy] != $prevrow) { if ($prevrow == '1') { - $bars[] = array($posx, ($posy - $bar_height), 1, $bar_height); + $bars[] = [$posx, ($posy - $bar_height), 1, $bar_height]; } + $bar_height = 0; } + ++$bar_height; $prevrow = $col[$posy]; } } + return $bars; } @@ -258,12 +243,7 @@ protected function getRotatedBarArray(): array */ protected function getBarRectXYXY(array $bar): array { - return array( - ($this->padding['L'] + ($bar[0] * $this->width_ratio)), - ($this->padding['T'] + ($bar[1] * $this->height_ratio)), - ($this->padding['L'] + (($bar[0] + $bar[2]) * $this->width_ratio) - 1), - ($this->padding['T'] + (($bar[1] + $bar[3]) * $this->height_ratio) - 1) - ); + return [($this->padding['L'] + ($bar[0] * $this->width_ratio)), ($this->padding['T'] + ($bar[1] * $this->height_ratio)), ($this->padding['L'] + (($bar[0] + $bar[2]) * $this->width_ratio) - 1), ($this->padding['T'] + (($bar[1] + $bar[3]) * $this->height_ratio) - 1)]; } /** @@ -275,11 +255,6 @@ protected function getBarRectXYXY(array $bar): array */ protected function getBarRectXYWH(array $bar): array { - return array( - ($this->padding['L'] + ($bar[0] * $this->width_ratio)), - ($this->padding['T'] + ($bar[1] * $this->height_ratio)), - ($bar[2] * $this->width_ratio), - ($bar[3] * $this->height_ratio) - ); + return [($this->padding['L'] + ($bar[0] * $this->width_ratio)), ($this->padding['T'] + ($bar[1] * $this->height_ratio)), ($bar[2] * $this->width_ratio), ($bar[3] * $this->height_ratio)]; } } diff --git a/src/Type/Linear/Codabar.php b/src/Type/Linear/Codabar.php index eb1e2d55..2e5daac2 100644 --- a/src/Type/Linear/Codabar.php +++ b/src/Type/Linear/Codabar.php @@ -45,28 +45,7 @@ class Codabar extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = array( - '0' => '11111221', - '1' => '11112211', - '2' => '11121121', - '3' => '22111111', - '4' => '11211211', - '5' => '21111211', - '6' => '12111121', - '7' => '12112111', - '8' => '12211111', - '9' => '21121111', - '-' => '11122111', - '$' => '11221111', - ':' => '21112121', - '/' => '21211121', - '.' => '21212111', - '+' => '11222221', - 'A' => '11221211', - 'B' => '12121121', - 'C' => '11121221', - 'D' => '11122211' - ); + protected const CHBAR = ['0' => '11111221', '1' => '11112211', '2' => '11121121', '3' => '22111111', '4' => '11211211', '5' => '21111211', '6' => '12111121', '7' => '12112111', '8' => '12211111', '9' => '21121111', '-' => '11122111', '$' => '11221111', ':' => '21112121', '/' => '21211121', '.' => '21212111', '+' => '11222221', 'A' => '11221211', 'B' => '12121121', 'C' => '11121221', 'D' => '11122211']; /** * Format code @@ -85,7 +64,7 @@ protected function setBars(): void { $this->ncols = 0; $this->nrows = 1; - $this->bars = array(); + $this->bars = []; $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { @@ -93,14 +72,17 @@ protected function setBars(): void if (!isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } + for ($pos = 0; $pos < 8; ++$pos) { - $bar_width = intval($this::CHBAR[$char][$pos]); + $bar_width = (int) $this::CHBAR[$char][$pos]; if (($pos % 2) == 0) { - $this->bars[] = array($this->ncols, 0, $bar_width, 1); + $this->bars[] = [$this->ncols, 0, $bar_width, 1]; } + $this->ncols += $bar_width; } } + --$this->ncols; } } diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index a82c29bd..739d9397 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -102,191 +102,14 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * * @var array */ - protected const EXTCODES = array( - "\x83U", - "\x80A", - "\x80B", - "\x80C", - "\x80D", - "\x80E", - "\x80F", - "\x80G", - "\x80H", - "\x80I", - "\x80J", - "\x80K", - "\x80L", - "\x80M", - "\x80N", - "\x80O", - "\x80P", - "\x80Q", - "\x80R", - "\x80S", - "\x80T", - "\x80U", - "\x80V", - "\x80W", - "\x80X", - "\x80Y", - "\x80Z", - "\x83A", - "\x83B", - "\x83C", - "\x83D", - "\x83E", - " ", - "\x81A", - "\x81B", - "\x81C", - "\x81D", - "\x81E", - "\x81F", - "\x81G", - "\x81H", - "\x81I", - "\x81J", - "\x81K", - "\x81L", - "-", - ".", - "\x81O", - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "\x81Z", - "\x83F", - "\x83G", - "\x83H", - "\x83I", - "\x83J", - "\x83V", - "A", - "B", - "C", - "D", - "E", - "F", - "G", - "H", - "I", - "J", - "K", - "L", - "M", - "N", - "O", - "P", - "Q", - "R", - "S", - "T", - "U", - "V", - "W", - "X", - "Y", - "Z", - "\x83K", - "\x83L", - "\x83M", - "\x83N", - "\x83O", - "\x83W", - "\x82A", - "\x82B", - "\x82C", - "\x82D", - "\x82E", - "\x82F", - "\x82G", - "\x82H", - "\x82I", - "\x82J", - "\x82K", - "\x82L", - "\x82M", - "\x82N", - "\x82O", - "\x82P", - "\x82Q", - "\x82R", - "\x82S", - "\x82T", - "\x82U", - "\x82V", - "\x82W", - "\x82X", - "\x82Y", - "\x82Z", - "\x83P", - "\x83Q", - "\x83R", - "\x83S", - "\x83T" - ); + protected const EXTCODES = ["\x83U", "\x80A", "\x80B", "\x80C", "\x80D", "\x80E", "\x80F", "\x80G", "\x80H", "\x80I", "\x80J", "\x80K", "\x80L", "\x80M", "\x80N", "\x80O", "\x80P", "\x80Q", "\x80R", "\x80S", "\x80T", "\x80U", "\x80V", "\x80W", "\x80X", "\x80Y", "\x80Z", "\x83A", "\x83B", "\x83C", "\x83D", "\x83E", " ", "\x81A", "\x81B", "\x81C", "\x81D", "\x81E", "\x81F", "\x81G", "\x81H", "\x81I", "\x81J", "\x81K", "\x81L", "-", ".", "\x81O", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\x81Z", "\x83F", "\x83G", "\x83H", "\x83I", "\x83J", "\x83V", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "\x83K", "\x83L", "\x83M", "\x83N", "\x83O", "\x83W", "\x82A", "\x82B", "\x82C", "\x82D", "\x82E", "\x82F", "\x82G", "\x82H", "\x82I", "\x82J", "\x82K", "\x82L", "\x82M", "\x82N", "\x82O", "\x82P", "\x82Q", "\x82R", "\x82S", "\x82T", "\x82U", "\x82V", "\x82W", "\x82X", "\x82Y", "\x82Z", "\x83P", "\x83Q", "\x83R", "\x83S", "\x83T"]; /** * Characters used for checksum * * @var array */ - protected const CHKSUM = array( - '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'G', - 'H', - 'I', - 'J', - 'K', - 'L', - 'M', - 'N', - 'O', - 'P', - 'Q', - 'R', - 'S', - 'T', - 'U', - 'V', - 'W', - 'X', - 'Y', - 'Z', - '-', - '.', - ' ', - '$', - '/', - '+', - '%', - '<', - '=', - '>', - '?' - ); + protected const CHKSUM = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%', '<', '=', '>', '?']; /** * Calculate CODE 93 checksum (modulo 47). @@ -311,6 +134,7 @@ protected function getChecksum(string $code): string $pck = 1; } } + $check %= 47; $chk = $this::CHKSUM[$check]; $code .= $chk; @@ -325,6 +149,7 @@ protected function getChecksum(string $code): string $pck = 1; } } + $check %= 47; $key = $this::CHKSUM[$check]; $checksum = $chk . $key; @@ -348,20 +173,22 @@ protected function setBars(): void { $this->ncols = 0; $this->nrows = 1; - $this->bars = array(); + $this->bars = []; $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = ord($this->extcode[$chr]); for ($pos = 0; $pos < 6; ++$pos) { - $bar_width = intval($this::CHBAR[$char][$pos]); + $bar_width = (int) $this::CHBAR[$char][$pos]; if (($pos % 2) == 0) { - $this->bars[] = array($this->ncols, 0, $bar_width, 1); + $this->bars[] = [$this->ncols, 0, $bar_width, 1]; } + $this->ncols += $bar_width; } } - $this->bars[] = array($this->ncols, 0, 1, 1); - $this->ncols += 1; + + $this->bars[] = [$this->ncols, 0, 1, 1]; + ++$this->ncols; } } diff --git a/src/Type/Linear/CodeOneOne.php b/src/Type/Linear/CodeOneOne.php index 604c8a2f..5dc10413 100644 --- a/src/Type/Linear/CodeOneOne.php +++ b/src/Type/Linear/CodeOneOne.php @@ -46,20 +46,7 @@ class CodeOneOne extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = array( - '0' => '111121', - '1' => '211121', - '2' => '121121', - '3' => '221111', - '4' => '112121', - '5' => '212111', - '6' => '122111', - '7' => '111221', - '8' => '211211', - '9' => '211111', - '-' => '112111', - 'S' => '112211' - ); + protected const CHBAR = ['0' => '111121', '1' => '211121', '2' => '121121', '3' => '221111', '4' => '112121', '5' => '212111', '6' => '122111', '7' => '111221', '8' => '211211', '9' => '211111', '-' => '112111', 'S' => '112211']; /** * Calculate the checksum. @@ -76,41 +63,39 @@ protected function getChecksum(string $code): string $ccheck = 0; for ($pos = ($len - 1); $pos >= 0; --$pos) { $digit = $code[$pos]; - if ($digit == '-') { - $dval = 10; - } else { - $dval = intval($digit); - } + $dval = $digit == '-' ? 10 : (int) $digit; + $ccheck += ($dval * $ptr); ++$ptr; if ($ptr > 10) { $ptr = 1; } } + $ccheck %= 11; if ($ccheck == 10) { $ccheck = '-'; } + if ($len <= 10) { return $ccheck; } + // calculate check digit K $code .= $ccheck; $ptr = 1; $kcheck = 0; for ($pos = $len; $pos >= 0; --$pos) { $digit = $code[$pos]; - if ($digit == '-') { - $dval = 10; - } else { - $dval = intval($digit); - } + $dval = $digit == '-' ? 10 : (int) $digit; + $kcheck += ($dval * $ptr); ++$ptr; if ($ptr > 9) { $ptr = 1; } } + $kcheck %= 11; return $ccheck . $kcheck; } @@ -132,7 +117,7 @@ protected function setBars(): void { $this->ncols = 0; $this->nrows = 1; - $this->bars = array(); + $this->bars = []; $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { @@ -140,14 +125,17 @@ protected function setBars(): void if (!isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } + for ($pos = 0; $pos < 6; ++$pos) { - $bar_width = intval($this::CHBAR[$char][$pos]); + $bar_width = (int) $this::CHBAR[$char][$pos]; if ((($pos % 2) == 0) && ($bar_width > 0)) { - $this->bars[] = array($this->ncols, 0, $bar_width, 1); + $this->bars[] = [$this->ncols, 0, $bar_width, 1]; } + $this->ncols += $bar_width; } } + --$this->ncols; } } diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index 497f227d..7af06aff 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -43,7 +43,7 @@ protected function getCodeData(): array { $code = $this->code; // array of symbols - $code_data = array(); + $code_data = []; // split code into sequences $sequence = $this->getNumericSequence($code); // process the sequence @@ -52,6 +52,7 @@ protected function getCodeData(): array $processMethod = 'processSequence' . $seq[0]; $this->$processMethod($sequence, $code_data, $startid, $key, $seq); } + return $this->finalizeCodeData($code_data, $startid); } @@ -91,6 +92,7 @@ protected function processSequenceA( $code_data[] = 101; } } + $this->getCodeDataA($code_data, $seq[1], (int)$seq[2]); } @@ -118,6 +120,7 @@ protected function processSequenceB( } elseif ($sequence[($key - 1)][0] != 'B') { $this->processSequenceBB($sequence, $code_data, $key, $seq); } + $this->getCodeDataB($code_data, $seq[1], (int)$seq[2]); } @@ -221,6 +224,7 @@ protected function processSequenceC( } elseif ($sequence[($key - 1)][0] != 'C') { $code_data[] = 99; } + $this->getCodeDataC($code_data, $seq[1]); } @@ -234,14 +238,15 @@ protected function setBars(): void $code_data = $this->getCodeData(); $this->ncols = 0; $this->nrows = 1; - $this->bars = array(); + $this->bars = []; foreach ($code_data as $val) { $seq = $this::CHBAR[$val]; for ($pos = 0; $pos < 6; ++$pos) { - $bar_width = intval($seq[$pos]); + $bar_width = (int) $seq[$pos]; if ((($pos % 2) == 0) && ($bar_width > 0)) { - $this->bars[] = array($this->ncols, 0, $bar_width, 1); + $this->bars[] = [$this->ncols, 0, $bar_width, 1]; } + $this->ncols += $bar_width; } } diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php index 361ed6de..86eb37a4 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php @@ -50,7 +50,7 @@ protected function getCodeData(): array { $code = $this->code; $len = strlen($code); - $code_data = array(); + $code_data = []; $this->getCodeDataA($code_data, $code, $len); return $this->finalizeCodeData($code_data, 103); } diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php index 8f8cdd03..5be600c6 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php @@ -50,7 +50,7 @@ protected function getCodeData(): array { $code = $this->code; $len = strlen($code); - $code_data = array(); + $code_data = []; $this->getCodeDataB($code_data, $code, $len); return $this->finalizeCodeData($code_data, 104); } diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php index 61970a1e..2ecdcbc0 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php @@ -49,11 +49,12 @@ class CodeOneTwoEightC extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight protected function getCodeData(): array { $code = $this->code; - $code_data = array(); + $code_data = []; if (ord($code[0]) == 241) { $code_data[] = 102; $code = substr($code, 1); } + $this->getCodeDataC($code_data, $code); return $this->finalizeCodeData($code_data, 105); } diff --git a/src/Type/Linear/CodeOneTwoEight/Process.php b/src/Type/Linear/CodeOneTwoEight/Process.php index 6390aceb9702864c84ba04be9aba6c80db20be49..612faddb271fe44a3481eec0cd121896b83e135d 100644 GIT binary patch delta 2851 zcmZ9OKTH#G6vw?Hwv@Ifg+lLI=@n~^^2c($mOp7oqwaQ4gGoJ`fEw`+HU5b)4rO#> zc!Nx`IJuy9A{ucvMs^c}gNY;t8C-M`-wy=ddtJy~KYZ`|dG~s`U*7!mOMh#k8npg@ z?7Wl5k3F<^22!o@{=EY$m$OEk{UckUd56Fi3A+cdlXqN}+>mgQ!Wit5{<4h^vp;be|jEwiL9F4pbQ*da7c4MAwf&?aUzKKnvbp~VIqjD!IytQz!OwZjhQ}VRwYaYai7^Vwj@jh zRW7^TsR$RGpn~{VWN<~oL{ODr51B^9$nL)f;G2v?UuD#8F#1)*2<*}DA(B2g_(2as zI{9W;H~hPAP9D^v-OU?%ryk9I^myJFoval=d`kM*W( zMZ*o1;U>www(-ThaCcRd~8#oItP zS~1r&vg$giGM*2^inqV%nOz!uQ1J?uCvuPbF71 z%-Bfv!iC-hypG2)>qXBA_}qJ;rD~soq+zr4@g2H|=Z=~qaMl`#R_)XFkd>LKU%85Z zu&)R22V<~e8qK%Xn}DxA0}r!(ef61}*-~)t&g{Il&R(p;Ak zxl_OAStqT`^eqfo9B^8Sn`;qR0=~( zm0iG42Vj0qG^*$r;rtV&V|vlYrB15knXsPv0j1{v(8Q>Uu84uaTw$mXVoiK!#j z6*17#IFTa8F_Z-qG3sT0y<+sv4`YhgELOzi&Zjh1#8j4d94lh-7Jp5Q-mDud6XJFuZ%F%^ci*!@ru6PF}X#57SR8!BQ-&y5ZhF{Ky1Bn}8m8cHj~<&KAnmq_YZFYJtvQLQFF)CNWXO zv>DM&s(+7>jT0$iO3wrnO^k)bUlXG${)(7nDa^pH=GTvoOVKIlcP=_Z903ExOlPHx zP|!H){DRnp)wbP1yNvc=wXx#U``m?B&gZyccC;FL>2!AGYLE*%erI}bFhB#e2rWi4 zXhXCST7ou4o1mRVJBRi%+Ih4KXcwpV0OJAU0pkJV0pkJV0pkJV0pkJV0pkJVPXZcF<1`D1xHyBX}+*Xn0Z6d|GgtUi_R|J9oddxP!CENeY`*<0>)?;hMd^q=>m z(EhU3u>SV3?BmA2p8dMHX#aZd>E*qd|Dx||f4LrFm5m^f9cyJjZG7W#mya4XDsU_~7xb#N``NdhpBL@XR_D}hltrgE z^joj{y&n1VV19h+_Fng`J9lTeo9?v(`+XmZDcZmLr%&EGeCNIWgI@Rg8}q|=-wd;t VwjX--*H$h2VW;6`zwNGh{{zL */ - protected const CHBAR = array( - '0' => '111331311', - '1' => '311311113', - '2' => '113311113', - '3' => '313311111', - '4' => '111331113', - '5' => '311331111', - '6' => '113331111', - '7' => '111311313', - '8' => '311311311', - '9' => '113311311', - 'A' => '311113113', - 'B' => '113113113', - 'C' => '313113111', - 'D' => '111133113', - 'E' => '311133111', - 'F' => '113133111', - 'G' => '111113313', - 'H' => '311113311', - 'I' => '113113311', - 'J' => '111133311', - 'K' => '311111133', - 'L' => '113111133', - 'M' => '313111131', - 'N' => '111131133', - 'O' => '311131131', - 'P' => '113131131', - 'Q' => '111111333', - 'R' => '311111331', - 'S' => '113111331', - 'T' => '111131331', - 'U' => '331111113', - 'V' => '133111113', - 'W' => '333111111', - 'X' => '131131113', - 'Y' => '331131111', - 'Z' => '133131111', - '-' => '131111313', - '.' => '331111311', - ' ' => '133111311', - '$' => '131313111', - '/' => '131311131', - '+' => '131113131', - '%' => '111313131', - '*' => '131131311' - ); + protected const CHBAR = ['0' => '111331311', '1' => '311311113', '2' => '113311113', '3' => '313311111', '4' => '111331113', '5' => '311331111', '6' => '113331111', '7' => '111311313', '8' => '311311311', '9' => '113311311', 'A' => '311113113', 'B' => '113113113', 'C' => '313113111', 'D' => '111133113', 'E' => '311133111', 'F' => '113133111', 'G' => '111113313', 'H' => '311113311', 'I' => '113113311', 'J' => '111133311', 'K' => '311111133', 'L' => '113111133', 'M' => '313111131', 'N' => '111131133', 'O' => '311131131', 'P' => '113131131', 'Q' => '111111333', 'R' => '311111331', 'S' => '113111331', 'T' => '111131331', 'U' => '331111113', 'V' => '133111113', 'W' => '333111111', 'X' => '131131113', 'Y' => '331131111', 'Z' => '133131111', '-' => '131111313', '.' => '331111311', ' ' => '133111311', '$' => '131313111', '/' => '131311131', '+' => '131113131', '%' => '111313131', '*' => '131131311']; /** * Map for extended characters * * @var array */ - protected const EXTCODES = array( - '%U', '$A', '$B', '$C', - '$D', '$E', '$F', '$G', - '$H', '$I', '$J', '$K', - '$L', '$M', '$N', '$O', - '$P', '$Q', '$R', '$S', - '$T', '$U', '$V', '$W', - '$X', '$Y', '$Z', '%A', - '%B', '%C', '%D', '%E', - ' ', '/A', '/B', '/C', - '/D', '/E', '/F', '/G', - '/H', '/I', '/J', '/K', - '/L', '-', '.', '/O', - '0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', '/Z', '%F', - '%G', '%H', '%I', '%J', - '%V', 'A', 'B', 'C', - 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', - 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', - 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', '%K', - '%L', '%M', '%N', '%O', - '%W', '+A', '+B', '+C', - '+D', '+E', '+F', '+G', - '+H', '+I', '+J', '+K', - '+L', '+M', '+N', '+O', - '+P', '+Q', '+R', '+S', - '+T', '+U', '+V', '+W', - '+X', '+Y', '+Z', '%P', - '%Q', '%R', '%S', '%T' - ); + protected const EXTCODES = ['%U', '$A', '$B', '$C', '$D', '$E', '$F', '$G', '$H', '$I', '$J', '$K', '$L', '$M', '$N', '$O', '$P', '$Q', '$R', '$S', '$T', '$U', '$V', '$W', '$X', '$Y', '$Z', '%A', '%B', '%C', '%D', '%E', ' ', '/A', '/B', '/C', '/D', '/E', '/F', '/G', '/H', '/I', '/J', '/K', '/L', '-', '.', '/O', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '/Z', '%F', '%G', '%H', '%I', '%J', '%V', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%K', '%L', '%M', '%N', '%O', '%W', '+A', '+B', '+C', '+D', '+E', '+F', '+G', '+H', '+I', '+J', '+K', '+L', '+M', '+N', '+O', '+P', '+Q', '+R', '+S', '+T', '+U', '+V', '+W', '+X', '+Y', '+Z', '%P', '%Q', '%R', '%S', '%T']; /** * Characters used for checksum * * @var array */ - protected const CHKSUM = array( - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', - 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%' - ); + protected const CHKSUM = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%']; /** * Encode a string to be used for CODE 39 Extended mode. * * @param string $code Code to extend * - * @return string * * @throws BarcodeException in case of error */ @@ -163,8 +79,10 @@ protected function getExtendCode(string $code): string if ($item > 127) { throw new BarcodeException('Invalid character: chr(' . $item . ')'); } + $ext .= $this::EXTCODES[$item]; } + return $ext; } @@ -183,6 +101,7 @@ protected function getChecksum(string $code): string $key = array_keys($this::CHKSUM, $code[$chr]); $sum += $key[0]; } + $idx = ($sum % 43); return $this::CHKSUM[$idx]; } @@ -205,7 +124,7 @@ protected function setBars(): void { $this->ncols = 0; $this->nrows = 1; - $this->bars = array(); + $this->bars = []; $this::FORMATCode(); $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { @@ -213,16 +132,20 @@ protected function setBars(): void if (!isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } + for ($pos = 0; $pos < 9; ++$pos) { - $bar_width = intval($this::CHBAR[$char][$pos]); + $bar_width = (int) $this::CHBAR[$char][$pos]; if ((($pos % 2) == 0) && ($bar_width > 0)) { - $this->bars[] = array($this->ncols, 0, $bar_width, 1); + $this->bars[] = [$this->ncols, 0, $bar_width, 1]; } + $this->ncols += $bar_width; } + // intercharacter gap - $this->ncols += 1; + ++$this->ncols; } + --$this->ncols; } } diff --git a/src/Type/Linear/EanEight.php b/src/Type/Linear/EanEight.php index 19455665..303340dc 100644 --- a/src/Type/Linear/EanEight.php +++ b/src/Type/Linear/EanEight.php @@ -43,8 +43,6 @@ class EanEight extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree /** * Fixed code length - * - * @var int */ protected int $code_length = 8; @@ -57,14 +55,16 @@ protected function setBars(): void { $this::FORMATCode(); $seq = '101'; // left guard bar - $half_len = intval(ceil($this->code_length / 2)); + $half_len = (int) ceil($this->code_length / 2); for ($pos = 0; $pos < $half_len; ++$pos) { $seq .= $this::CHBAR['A'][$this->extcode[$pos]]; } + $seq .= '01010'; // center guard bar for ($pos = $half_len; $pos < $this->code_length; ++$pos) { $seq .= $this::CHBAR['C'][$this->extcode[$pos]]; } + $seq .= '101'; // right guard bar $this->processBinarySequence($seq); } diff --git a/src/Type/Linear/EanFive.php b/src/Type/Linear/EanFive.php index 2fc18faa..6aaec5de 100644 --- a/src/Type/Linear/EanFive.php +++ b/src/Type/Linear/EanFive.php @@ -43,8 +43,6 @@ class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo /** * Fixed code length - * - * @var int */ protected int $code_length = 5; @@ -53,18 +51,7 @@ class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo * * @var array> */ - protected const PARITIES = array( - '0' => array('B','B','A','A','A'), - '1' => array('B','A','B','A','A'), - '2' => array('B','A','A','B','A'), - '3' => array('B','A','A','A','B'), - '4' => array('A','B','B','A','A'), - '5' => array('A','A','B','B','A'), - '6' => array('A','A','A','B','B'), - '7' => array('A','B','A','B','A'), - '8' => array('A','B','A','A','B'), - '9' => array('A','A','B','A','B') - ); + protected const PARITIES = ['0' => ['B', 'B', 'A', 'A', 'A'], '1' => ['B', 'A', 'B', 'A', 'A'], '2' => ['B', 'A', 'A', 'B', 'A'], '3' => ['B', 'A', 'A', 'A', 'B'], '4' => ['A', 'B', 'B', 'A', 'A'], '5' => ['A', 'A', 'B', 'B', 'A'], '6' => ['A', 'A', 'A', 'B', 'B'], '7' => ['A', 'B', 'A', 'B', 'A'], '8' => ['A', 'B', 'A', 'A', 'B'], '9' => ['A', 'A', 'B', 'A', 'B']]; /** * Calculate checksum @@ -75,7 +62,7 @@ class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo */ protected function getChecksum(string $code): int { - return (((3 * (intval($code[0]) + intval($code[2]) + intval($code[4]))) - + (9 * (intval($code[1]) + intval($code[3])))) % 10); + return (((3 * ((int) $code[0] + (int) $code[2] + (int) $code[4])) + + (9 * ((int) $code[1] + (int) $code[3]))) % 10); } } diff --git a/src/Type/Linear/EanOneThree.php b/src/Type/Linear/EanOneThree.php index 9b62325e..a16f0708 100644 --- a/src/Type/Linear/EanOneThree.php +++ b/src/Type/Linear/EanOneThree.php @@ -43,15 +43,11 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear /** * Fixed code length - * - * @var int */ protected int $code_length = 13; /** * Check digit - * - * @var int */ protected int $check = 0; @@ -60,62 +56,50 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear * * @var array> */ - protected const CHBAR = array( - 'A' => array( // left odd parity - '0' => '0001101', - '1' => '0011001', - '2' => '0010011', - '3' => '0111101', - '4' => '0100011', - '5' => '0110001', - '6' => '0101111', - '7' => '0111011', - '8' => '0110111', - '9' => '0001011' - ), - 'B' => array( // left even parity - '0' => '0100111', - '1' => '0110011', - '2' => '0011011', - '3' => '0100001', - '4' => '0011101', - '5' => '0111001', - '6' => '0000101', - '7' => '0010001', - '8' => '0001001', - '9' => '0010111' - ), - 'C' => array( // right - '0' => '1110010', - '1' => '1100110', - '2' => '1101100', - '3' => '1000010', - '4' => '1011100', - '5' => '1001110', - '6' => '1010000', - '7' => '1000100', - '8' => '1001000', - '9' => '1110100' - ) - ); + protected const CHBAR = ['A' => [ + // left odd parity + '0' => '0001101', + '1' => '0011001', + '2' => '0010011', + '3' => '0111101', + '4' => '0100011', + '5' => '0110001', + '6' => '0101111', + '7' => '0111011', + '8' => '0110111', + '9' => '0001011', + ], 'B' => [ + // left even parity + '0' => '0100111', + '1' => '0110011', + '2' => '0011011', + '3' => '0100001', + '4' => '0011101', + '5' => '0111001', + '6' => '0000101', + '7' => '0010001', + '8' => '0001001', + '9' => '0010111', + ], 'C' => [ + // right + '0' => '1110010', + '1' => '1100110', + '2' => '1101100', + '3' => '1000010', + '4' => '1011100', + '5' => '1001110', + '6' => '1010000', + '7' => '1000100', + '8' => '1001000', + '9' => '1110100', + ]]; /** * Map parities * * @var array */ - protected const PARITIES = array( - '0' => 'AAAAAA', - '1' => 'AABABB', - '2' => 'AABBAB', - '3' => 'AABBBA', - '4' => 'ABAABB', - '5' => 'ABBAAB', - '6' => 'ABBBAA', - '7' => 'ABABAB', - '8' => 'ABABBA', - '9' => 'ABBABA' - ); + protected const PARITIES = ['0' => 'AAAAAA', '1' => 'AABABB', '2' => 'AABBAB', '3' => 'AABBBA', '4' => 'ABAABB', '5' => 'ABBAAB', '6' => 'ABBBAA', '7' => 'ABABAB', '8' => 'ABABBA', '9' => 'ABBABA']; /** * Calculate checksum @@ -134,27 +118,35 @@ protected function getChecksum(string $code): int for ($pos = 1; $pos < $data_len; $pos += 2) { $sum_a += $code[$pos]; } + if ($this->code_length > 12) { $sum_a *= 3; } + $sum_b = 0; for ($pos = 0; $pos < $data_len; $pos += 2) { $sum_b += ($code[$pos]); } + if ($this->code_length < 13) { $sum_b *= 3; } + $this->check = ($sum_a + $sum_b) % 10; if ($this->check > 0) { $this->check = (10 - $this->check); } + if ($code_len == $data_len) { // add check digit return $this->check; - } elseif ($this->check !== intval($code[$data_len])) { + } + + if ($this->check !== (int) $code[$data_len]) { // wrong check digit throw new BarcodeException('Invalid check digit: ' . $this->check); } + return 0; } @@ -177,17 +169,20 @@ protected function setBars(): void if (!is_numeric($this->code)) { throw new BarcodeException('Input code must be a number'); } + $this::FORMATCode(); $seq = '101'; // left guard bar - $half_len = intval(ceil($this->code_length / 2)); + $half_len = (int) ceil($this->code_length / 2); $parity = $this::PARITIES[$this->extcode[0]]; for ($pos = 1; $pos < $half_len; ++$pos) { $seq .= $this::CHBAR[$parity[($pos - 1)]][$this->extcode[$pos]]; } + $seq .= '01010'; // center guard bar for ($pos = $half_len; $pos < $this->code_length; ++$pos) { $seq .= $this::CHBAR['C'][$this->extcode[$pos]]; } + $seq .= '101'; // right guard bar $this->processBinarySequence($seq); } diff --git a/src/Type/Linear/EanTwo.php b/src/Type/Linear/EanTwo.php index b6a9d410..a95ba4b8 100644 --- a/src/Type/Linear/EanTwo.php +++ b/src/Type/Linear/EanTwo.php @@ -43,8 +43,6 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear /** * Fixed code length - * - * @var int */ protected int $code_length = 2; @@ -53,44 +51,38 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear * * @var array> */ - protected const CHBAR = array( - 'A' => array( // left odd parity - '0' => '0001101', - '1' => '0011001', - '2' => '0010011', - '3' => '0111101', - '4' => '0100011', - '5' => '0110001', - '6' => '0101111', - '7' => '0111011', - '8' => '0110111', - '9' => '0001011' - ), - 'B' => array( // left even parity - '0' => '0100111', - '1' => '0110011', - '2' => '0011011', - '3' => '0100001', - '4' => '0011101', - '5' => '0111001', - '6' => '0000101', - '7' => '0010001', - '8' => '0001001', - '9' => '0010111' - ) - ); + protected const CHBAR = ['A' => [ + // left odd parity + '0' => '0001101', + '1' => '0011001', + '2' => '0010011', + '3' => '0111101', + '4' => '0100011', + '5' => '0110001', + '6' => '0101111', + '7' => '0111011', + '8' => '0110111', + '9' => '0001011', + ], 'B' => [ + // left even parity + '0' => '0100111', + '1' => '0110011', + '2' => '0011011', + '3' => '0100001', + '4' => '0011101', + '5' => '0111001', + '6' => '0000101', + '7' => '0010001', + '8' => '0001001', + '9' => '0010111', + ]]; /** * Map parities * * @var array> */ - protected const PARITIES = array( - '0' => array('A','A'), - '1' => array('A','B'), - '2' => array('B','A'), - '3' => array('B','B') - ); + protected const PARITIES = ['0' => ['A', 'A'], '1' => ['A', 'B'], '2' => ['B', 'A'], '3' => ['B', 'B']]; /** * Calculate checksum @@ -101,7 +93,7 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear */ protected function getChecksum(string $code): int { - return (intval($code) % 4); + return ((int) $code % 4); } /** @@ -129,6 +121,7 @@ protected function setBars(): void $seq .= '01'; // separator $seq .= $this::CHBAR[$parity[$pos]][$this->extcode[$pos]]; } + $this->processBinarySequence($seq); } } diff --git a/src/Type/Linear/Imb.php b/src/Type/Linear/Imb.php index 84d66e74..ad71b615 100644 --- a/src/Type/Linear/Imb.php +++ b/src/Type/Linear/Imb.php @@ -67,47 +67,28 @@ class Imb extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const ASC_CHR = array( - 4,0,2,6,3,5,1,9,8,7, - 1,2,0,6,4,8,2,9,5,3, - 0,1,3,7,4,6,8,9,2,0, - 5,1,9,4,3,8,6,7,1,2, - 4,3,9,5,7,8,3,0,2,1, - 4,0,9,1,7,0,2,4,6,3, - 7,1,9,5,8 - ); + protected const ASC_CHR = [4, 0, 2, 6, 3, 5, 1, 9, 8, 7, 1, 2, 0, 6, 4, 8, 2, 9, 5, 3, 0, 1, 3, 7, 4, 6, 8, 9, 2, 0, 5, 1, 9, 4, 3, 8, 6, 7, 1, 2, 4, 3, 9, 5, 7, 8, 3, 0, 2, 1, 4, 0, 9, 1, 7, 0, 2, 4, 6, 3, 7, 1, 9, 5, 8]; /** * DSC characters * * @var array */ - protected const DSC_CHR = array( - 7,1,9,5,8,0,2,4,6,3, - 5,8,9,7,3,0,6,1,7,4, - 6,8,9,2,5,1,7,5,4,3, - 8,7,6,0,2,5,4,9,3,0, - 1,6,8,2,0,4,5,9,6,7, - 5,2,6,3,8,5,1,9,8,7, - 4,0,2,6,3); + protected const DSC_CHR = [7, 1, 9, 5, 8, 0, 2, 4, 6, 3, 5, 8, 9, 7, 3, 0, 6, 1, 7, 4, 6, 8, 9, 2, 5, 1, 7, 5, 4, 3, 8, 7, 6, 0, 2, 5, 4, 9, 3, 0, 1, 6, 8, 2, 0, 4, 5, 9, 6, 7, 5, 2, 6, 3, 8, 5, 1, 9, 8, 7, 4, 0, 2, 6, 3]; /** * ASC positions * * @var array */ - protected const ASC_POS = array( - 3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9, - 6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2); + protected const ASC_POS = [3, 0, 8, 11, 1, 12, 8, 11, 10, 6, 4, 12, 2, 7, 9, 6, 7, 9, 2, 8, 4, 0, 12, 7, 10, 9, 0, 7, 10, 5, 7, 9, 6, 8, 2, 12, 1, 4, 2, 0, 1, 5, 4, 6, 12, 1, 0, 9, 4, 7, 5, 10, 2, 6, 9, 11, 2, 12, 6, 7, 5, 11, 0, 3, 2]; /** * DSC positions * * @var array */ - protected const DSC_POS = array( - 2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11, - 0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10); + protected const DSC_POS = [2, 10, 12, 5, 9, 1, 5, 4, 3, 9, 11, 5, 10, 1, 6, 3, 4, 1, 10, 0, 2, 11, 8, 6, 1, 12, 3, 8, 6, 4, 4, 11, 0, 6, 1, 9, 11, 5, 3, 7, 3, 10, 7, 11, 8, 2, 10, 3, 5, 8, 0, 3, 12, 11, 8, 4, 5, 1, 3, 0, 7, 12, 9, 8, 10]; /** * Reverse unsigned short value @@ -124,6 +105,7 @@ protected function getReversedUnsignedShort(int $num): int $rev |= ($num & 1); $num >>= 1; } + return $rev; } @@ -141,27 +123,23 @@ protected function getFrameCheckSequence(array $code_arr): int // do most significant byte skipping the 2 most significant bits $data = hexdec($code_arr[0]) << 5; for ($bit = 2; $bit < 8; ++$bit) { - if (($fcs ^ $data) & 0x400) { - $fcs = ($fcs << 1) ^ $genpoly; - } else { - $fcs = ($fcs << 1); - } + $fcs = (($fcs ^ $data) & 0x400) !== 0 ? ($fcs << 1) ^ $genpoly : $fcs << 1; + $fcs &= 0x7FF; $data <<= 1; } + // do rest of bytes for ($byte = 1; $byte < 13; ++$byte) { $data = hexdec($code_arr[$byte]) << 3; for ($bit = 0; $bit < 8; ++$bit) { - if (($fcs ^ $data) & 0x400) { - $fcs = ($fcs << 1) ^ $genpoly; - } else { - $fcs = ($fcs << 1); - } + $fcs = (($fcs ^ $data) & 0x400) !== 0 ? ($fcs << 1) ^ $genpoly : $fcs << 1; + $fcs &= 0x7FF; $data <<= 1; } } + return $fcs; } @@ -175,16 +153,17 @@ protected function getFrameCheckSequence(array $code_arr): int */ protected function getTables(int $type, int $size): array { - $table = array(); + $table = []; $lli = 0; // LUT lower index $lui = $size - 1; // LUT upper index for ($count = 0; $count < 8192; ++$count) { $bit_count = 0; for ($bit_index = 0; $bit_index < 13; ++$bit_index) { - $bit_count += intval(($count & (1 << $bit_index)) != 0); + $bit_count += (int) (($count & (1 << $bit_index)) != 0); } + // if we don't have the right number of bits on, go on to the next value - if ($bit_count == $type) { + if ($bit_count === $type) { $reverse = ($this->getReversedUnsignedShort($count) >> 3); // if the reverse is less than count, we have already visited this pair before if ($reverse >= $count) { @@ -203,6 +182,7 @@ protected function getTables(int $type, int $size): array } } } + return $table; } @@ -211,30 +191,24 @@ protected function getTables(int $type, int $size): array * * @param string $routing_code the routing code * - * @return string * * @throws BarcodeException in case of error */ protected function getRoutingCode(string $routing_code): string { // Conversion of Routing Code - switch (strlen($routing_code)) { - case 0: - return '0'; - case 5: - return bcadd($routing_code, '1'); - case 9: - return bcadd($routing_code, '100001'); - case 11: - return bcadd($routing_code, '1000100001'); - } - throw new BarcodeException('Invalid routing code'); + return match (strlen($routing_code)) { + 0 => '0', + 5 => bcadd($routing_code, '1'), + 9 => bcadd($routing_code, '100001'), + 11 => bcadd($routing_code, '1000100001'), + default => throw new BarcodeException('Invalid routing code'), + }; } /** * Get the processed array of characters * - * @return array * * @throws BarcodeException in case of error */ @@ -242,13 +216,14 @@ protected function getCharsArray(): array { $this->ncols = 0; $this->nrows = 3; - $this->bars = array(); + $this->bars = []; $code_arr = explode('-', $this->code); $tracking_number = $code_arr[0]; $binary_code = 0; if (isset($code_arr[1])) { $binary_code = $this->getRoutingCode($code_arr[1]); } + $binary_code = bcmul($binary_code, '10'); $binary_code = bcadd($binary_code, $tracking_number[0]); $binary_code = bcmul($binary_code, '5'); @@ -268,7 +243,7 @@ protected function getCharsArray(): array $first_byte = sprintf('%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2)); $binary_code_102bit = $first_byte . substr($binary_code, 2); // convert binary data to codewords - $codewords = array(); + $codewords = []; $data = $this->convertHexToDec($binary_code_102bit); $codewords[0] = bcmod($data, '636') * 2; $data = bcdiv($data, '636'); @@ -276,26 +251,26 @@ protected function getCharsArray(): array $codewords[$pos] = bcmod($data, '1365'); $data = bcdiv($data, '1365'); } + $codewords[9] = $data; if (($fcs >> 10) == 1) { $codewords[9] += 659; } + // generate lookup tables $table2of13 = $this->getTables(2, 78); $table5of13 = $this->getTables(5, 1287); // convert codewords to characters - $characters = array(); + $characters = []; $bitmask = 512; - foreach ($codewords as $val) { - if ($val <= 1286) { - $chrcode = $table5of13[$val]; - } else { - $chrcode = $table2of13[($val - 1287)]; - } + foreach ($codewords as $codeword) { + $chrcode = $codeword <= 1286 ? $table5of13[$codeword] : $table2of13[($codeword - 1287)]; + if (($fcs & $bitmask) > 0) { // bitwise invert $chrcode = ((~(int)$chrcode) & 8191); } + $characters[] = $chrcode; $bitmask /= 2; } @@ -312,23 +287,25 @@ protected function setBars(): void { $chars = $this->getCharsArray(); for ($pos = 0; $pos < 65; ++$pos) { - $asc = (($chars[self::ASC_CHR[$pos]] & pow(2, self::ASC_POS[$pos])) > 0); - $dsc = (($chars[self::DSC_CHR[$pos]] & pow(2, self::DSC_POS[$pos])) > 0); - if ($asc and $dsc) { + $asc = (($chars[self::ASC_CHR[$pos]] & 2 ** self::ASC_POS[$pos]) > 0); + $dsc = (($chars[self::DSC_CHR[$pos]] & 2 ** self::DSC_POS[$pos]) > 0); + if ($asc && $dsc) { // full bar (F) - $this->bars[] = array($this->ncols, 0, 1, 3); + $this->bars[] = [$this->ncols, 0, 1, 3]; } elseif ($asc) { // ascender (A) - $this->bars[] = array($this->ncols, 0, 1, 2); + $this->bars[] = [$this->ncols, 0, 1, 2]; } elseif ($dsc) { // descender (D) - $this->bars[] = array($this->ncols, 1, 1, 2); + $this->bars[] = [$this->ncols, 1, 1, 2]; } else { // tracker (T) - $this->bars[] = array($this->ncols, 1, 1, 1); + $this->bars[] = [$this->ncols, 1, 1, 1]; } + $this->ncols += 2; } + --$this->ncols; } } diff --git a/src/Type/Linear/ImbPre.php b/src/Type/Linear/ImbPre.php index a935639f..df38f46f 100644 --- a/src/Type/Linear/ImbPre.php +++ b/src/Type/Linear/ImbPre.php @@ -52,30 +52,33 @@ protected function setBars(): void if (preg_match('/^[fadt]{65}$/', $code) != 1) { throw new BarcodeException('Invalid character sequence'); } + $this->ncols = 0; $this->nrows = 3; - $this->bars = array(); + $this->bars = []; for ($pos = 0; $pos < 65; ++$pos) { switch ($code[$pos]) { case 'f': // full bar - $this->bars[] = array($this->ncols, 0, 1, 3); + $this->bars[] = [$this->ncols, 0, 1, 3]; break; case 'a': // ascender - $this->bars[] = array($this->ncols, 0, 1, 2); + $this->bars[] = [$this->ncols, 0, 1, 2]; break; case 'd': // descender - $this->bars[] = array($this->ncols, 1, 1, 2); + $this->bars[] = [$this->ncols, 1, 1, 2]; break; case 't': // tracker (short) - $this->bars[] = array($this->ncols, 1, 1, 1); + $this->bars[] = [$this->ncols, 1, 1, 1]; break; } + $this->ncols += 2; } + --$this->ncols; } } diff --git a/src/Type/Linear/InterleavedTwoOfFiveCheck.php b/src/Type/Linear/InterleavedTwoOfFiveCheck.php index dc2edd4d..de2a2c36 100644 --- a/src/Type/Linear/InterleavedTwoOfFiveCheck.php +++ b/src/Type/Linear/InterleavedTwoOfFiveCheck.php @@ -46,20 +46,7 @@ class InterleavedTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear\Standar * * @var array */ - protected const CHBAR= array( - '0' => '11221', - '1' => '21112', - '2' => '12112', - '3' => '22111', - '4' => '11212', - '5' => '21211', - '6' => '12211', - '7' => '11122', - '8' => '21121', - '9' => '12121', - 'A' => '11', - 'Z' => '21' - ); + protected const CHBAR= ['0' => '11221', '1' => '21112', '2' => '12112', '3' => '22111', '4' => '11212', '5' => '21211', '6' => '12211', '7' => '11122', '8' => '21121', '9' => '12121', 'A' => '11', 'Z' => '21']; /** * Format code @@ -77,37 +64,42 @@ protected function formatCode(): void protected function setBars(): void { $this::FORMATCode(); - if ((strlen($this->extcode) % 2) != 0) { + if (strlen($this->extcode) % 2 != 0) { // add leading zero if code-length is odd $this->extcode = '0' . $this->extcode; } + // add start and stop codes $this->extcode = 'AA' . strtolower($this->extcode) . 'ZA'; $this->ncols = 0; $this->nrows = 1; - $this->bars = array(); + $this->bars = []; $clen = strlen($this->extcode); - for ($idx = 0; $idx < $clen; $idx = ($idx + 2)) { + for ($idx = 0; $idx < $clen; $idx += 2) { $char_bar = $this->extcode[$idx]; $char_space = $this->extcode[($idx + 1)]; if ((!isset($this::CHBAR[$char_bar])) || (!isset($this::CHBAR[$char_space]))) { throw new BarcodeException('Invalid character sequence: ' . $char_bar . $char_space); } + // create a bar-space sequence $seq = ''; $chrlen = strlen($this::CHBAR[$char_bar]); for ($pos = 0; $pos < $chrlen; ++$pos) { $seq .= $this::CHBAR[$char_bar][$pos] . $this::CHBAR[$char_space][$pos]; } + $seqlen = strlen($seq); for ($pos = 0; $pos < $seqlen; ++$pos) { - $bar_width = intval($seq[$pos]); + $bar_width = (int) $seq[$pos]; if ((($pos % 2) == 0) && ($bar_width > 0)) { - $this->bars[] = array($this->ncols, 0, $bar_width, 1); + $this->bars[] = [$this->ncols, 0, $bar_width, 1]; } + $this->ncols += $bar_width; } } + --$this->ncols; } } diff --git a/src/Type/Linear/KlantIndex.php b/src/Type/Linear/KlantIndex.php index 4afb6430..96207096 100644 --- a/src/Type/Linear/KlantIndex.php +++ b/src/Type/Linear/KlantIndex.php @@ -58,7 +58,7 @@ protected function setBars(): void { $this->ncols = 0; $this->nrows = 3; - $this->bars = array(); + $this->bars = []; $this->getCoreBars(); } } diff --git a/src/Type/Linear/MsiCheck.php b/src/Type/Linear/MsiCheck.php index 44c07ee5..2068da5c 100644 --- a/src/Type/Linear/MsiCheck.php +++ b/src/Type/Linear/MsiCheck.php @@ -46,24 +46,7 @@ class MsiCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = array( - '0' => '100100100100', - '1' => '100100100110', - '2' => '100100110100', - '3' => '100100110110', - '4' => '100110100100', - '5' => '100110100110', - '6' => '100110110100', - '7' => '100110110110', - '8' => '110100100100', - '9' => '110100100110', - 'A' => '110100110100', - 'B' => '110100110110', - 'C' => '110110100100', - 'D' => '110110100110', - 'E' => '110110110100', - 'F' => '110110110110' - ); + protected const CHBAR = ['0' => '100100100100', '1' => '100100100110', '2' => '100100110100', '3' => '100100110110', '4' => '100110100100', '5' => '100110100110', '6' => '100110110100', '7' => '100110110110', '8' => '110100100100', '9' => '110100100110', 'A' => '110100110100', 'B' => '110100110110', 'C' => '110110100100', 'D' => '110110100110', 'E' => '110110110100', 'F' => '110110110110']; /** * Calculate the checksum @@ -82,16 +65,19 @@ protected function getChecksum(string $code): int if (!ctype_xdigit($hex)) { continue; } + $check += (hexdec($hex) * $pix); ++$pix; if ($pix > 7) { $pix = 2; } } + $check %= 11; if ($check > 0) { - $check = (11 - $check); + return 11 - $check; } + return $check; } @@ -118,8 +104,10 @@ protected function setBars(): void if (!isset($this::CHBAR[$digit])) { throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')'); } + $seq .= $this::CHBAR[$digit]; } + $seq .= '1001'; // right guard $this->processBinarySequence($seq); } diff --git a/src/Type/Linear/Pharma.php b/src/Type/Linear/Pharma.php index 725d837a..13601976 100644 --- a/src/Type/Linear/Pharma.php +++ b/src/Type/Linear/Pharma.php @@ -49,17 +49,19 @@ class Pharma extends \Com\Tecnick\Barcode\Type\Linear protected function setBars(): void { $seq = ''; - $code = intval($this->code); + $code = (int) $this->code; while ($code > 0) { if (($code % 2) == 0) { $seq .= '11100'; $code -= 2; } else { $seq .= '100'; - $code -= 1; + --$code; } + $code /= 2; } + $seq = substr($seq, 0, -2); $seq = strrev($seq); $this->processBinarySequence($seq); diff --git a/src/Type/Linear/PharmaTwoTracks.php b/src/Type/Linear/PharmaTwoTracks.php index 088e1893..60c5d74a 100644 --- a/src/Type/Linear/PharmaTwoTracks.php +++ b/src/Type/Linear/PharmaTwoTracks.php @@ -49,7 +49,7 @@ class PharmaTwoTracks extends \Com\Tecnick\Barcode\Type\Linear protected function setBars(): void { $seq = ''; - $code = intval($this->code); + $code = (int) $this->code; do { switch ($code % 3) { @@ -70,22 +70,24 @@ protected function setBars(): void $seq = strrev($seq); $this->ncols = 0; $this->nrows = 2; - $this->bars = array(); + $this->bars = []; $len = strlen($seq); for ($pos = 0; $pos < $len; ++$pos) { switch ($seq[$pos]) { case '1': - $this->bars[] = array($this->ncols, 1, 1, 1); + $this->bars[] = [$this->ncols, 1, 1, 1]; break; case '2': - $this->bars[] = array($this->ncols, 0, 1, 1); + $this->bars[] = [$this->ncols, 0, 1, 1]; break; case '3': - $this->bars[] = array($this->ncols, 0, 1, 2); + $this->bars[] = [$this->ncols, 0, 1, 2]; break; } + $this->ncols += 2; } + --$this->ncols; } } diff --git a/src/Type/Linear/Planet.php b/src/Type/Linear/Planet.php index 684e8a50..3f46d420 100644 --- a/src/Type/Linear/Planet.php +++ b/src/Type/Linear/Planet.php @@ -46,16 +46,5 @@ class Planet extends \Com\Tecnick\Barcode\Type\Linear\Postnet * * @var array */ - protected const CHBAR = array( - '0' => '11222', - '1' => '22211', - '2' => '22121', - '3' => '22112', - '4' => '21221', - '5' => '21212', - '6' => '21122', - '7' => '12221', - '8' => '12212', - '9' => '12122' - ); + protected const CHBAR = ['0' => '11222', '1' => '22211', '2' => '22121', '3' => '22112', '4' => '21221', '5' => '21212', '6' => '21122', '7' => '12221', '8' => '12212', '9' => '12122']; } diff --git a/src/Type/Linear/Postnet.php b/src/Type/Linear/Postnet.php index 97ef5d23..0e5592da 100644 --- a/src/Type/Linear/Postnet.php +++ b/src/Type/Linear/Postnet.php @@ -46,18 +46,7 @@ class Postnet extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = array( - '0' => '22111', - '1' => '11122', - '2' => '11212', - '3' => '11221', - '4' => '12112', - '5' => '12121', - '6' => '12211', - '7' => '21112', - '8' => '21121', - '9' => '21211' - ); + protected const CHBAR = ['0' => '22111', '1' => '11122', '2' => '11212', '3' => '11221', '4' => '12112', '5' => '12121', '6' => '12211', '7' => '21112', '8' => '21121', '9' => '21211']; /** * Calculate the checksum. @@ -71,12 +60,14 @@ protected function getChecksum(string $code): int $sum = 0; $len = strlen($code); for ($pos = 0; $pos < $len; ++$pos) { - $sum += intval($code[$pos]); + $sum += (int) $code[$pos]; } + $check = ($sum % 10); if ($check > 0) { - $check = (10 - $check); + return 10 - $check; } + return $check; } @@ -98,25 +89,27 @@ protected function setBars(): void { $this->ncols = 0; $this->nrows = 2; - $this->bars = array(); + $this->bars = []; $this::FORMATCode(); $clen = strlen($this->extcode); // start bar - $this->bars[] = array($this->ncols, 0, 1, 2); + $this->bars[] = [$this->ncols, 0, 1, 2]; $this->ncols += 2; for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; if (!isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } + for ($pos = 0; $pos < 5; ++$pos) { - $bar_height = intval($this::CHBAR[$char][$pos]); - $this->bars[] = array($this->ncols, floor(1 / $bar_height), 1, $bar_height); + $bar_height = (int) $this::CHBAR[$char][$pos]; + $this->bars[] = [$this->ncols, floor(1 / $bar_height), 1, $bar_height]; $this->ncols += 2; } } + // end bar - $this->bars[] = array($this->ncols, 0, 1, 2); + $this->bars[] = [$this->ncols, 0, 1, 2]; ++$this->ncols; } } diff --git a/src/Type/Linear/RoyalMailFourCc.php b/src/Type/Linear/RoyalMailFourCc.php index 1b4aab27..0bb0d7ce 100644 --- a/src/Type/Linear/RoyalMailFourCc.php +++ b/src/Type/Linear/RoyalMailFourCc.php @@ -46,88 +46,14 @@ class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = array( - '0' => '3322', - '1' => '3412', - '2' => '3421', - '3' => '4312', - '4' => '4321', - '5' => '4411', - '6' => '3142', - '7' => '3232', - '8' => '3241', - '9' => '4132', - 'A' => '4141', - 'B' => '4231', - 'C' => '3124', - 'D' => '3214', - 'E' => '3223', - 'F' => '4114', - 'G' => '4123', - 'H' => '4213', - 'I' => '1342', - 'J' => '1432', - 'K' => '1441', - 'L' => '2332', - 'M' => '2341', - 'N' => '2431', - 'O' => '1324', - 'P' => '1414', - 'Q' => '1423', - 'R' => '2314', - 'S' => '2323', - 'T' => '2413', - 'U' => '1144', - 'V' => '1234', - 'W' => '1243', - 'X' => '2134', - 'Y' => '2143', - 'Z' => '2233' - ); + protected const CHBAR = ['0' => '3322', '1' => '3412', '2' => '3421', '3' => '4312', '4' => '4321', '5' => '4411', '6' => '3142', '7' => '3232', '8' => '3241', '9' => '4132', 'A' => '4141', 'B' => '4231', 'C' => '3124', 'D' => '3214', 'E' => '3223', 'F' => '4114', 'G' => '4123', 'H' => '4213', 'I' => '1342', 'J' => '1432', 'K' => '1441', 'L' => '2332', 'M' => '2341', 'N' => '2431', 'O' => '1324', 'P' => '1414', 'Q' => '1423', 'R' => '2314', 'S' => '2323', 'T' => '2413', 'U' => '1144', 'V' => '1234', 'W' => '1243', 'X' => '2134', 'Y' => '2143', 'Z' => '2233']; /** * Characters used for checksum * * @var array */ - protected const CHKSUM= array( - '0' => '11', - '1' => '12', - '2' => '13', - '3' => '14', - '4' => '15', - '5' => '10', - '6' => '21', - '7' => '22', - '8' => '23', - '9' => '24', - 'A' => '25', - 'B' => '20', - 'C' => '31', - 'D' => '32', - 'E' => '33', - 'F' => '34', - 'G' => '35', - 'H' => '30', - 'I' => '41', - 'J' => '42', - 'K' => '43', - 'L' => '44', - 'M' => '45', - 'N' => '40', - 'O' => '51', - 'P' => '52', - 'Q' => '53', - 'R' => '54', - 'S' => '55', - 'T' => '50', - 'U' => '01', - 'V' => '02', - 'W' => '03', - 'X' => '04', - 'Y' => '05', - 'Z' => '00' - ); + protected const CHKSUM= ['0' => '11', '1' => '12', '2' => '13', '3' => '14', '4' => '15', '5' => '10', '6' => '21', '7' => '22', '8' => '23', '9' => '24', 'A' => '25', 'B' => '20', 'C' => '31', 'D' => '32', 'E' => '33', 'F' => '34', 'G' => '35', 'H' => '30', 'I' => '41', 'J' => '42', 'K' => '43', 'L' => '44', 'M' => '45', 'N' => '40', 'O' => '51', 'P' => '52', 'Q' => '53', 'R' => '54', 'S' => '55', 'T' => '50', 'U' => '01', 'V' => '02', 'W' => '03', 'X' => '04', 'Y' => '05', 'Z' => '00']; /** * Calculate the checksum. @@ -148,9 +74,11 @@ protected function getChecksum(string $code): int if (!isset($this::CHKSUM[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } - $row += intval($this::CHKSUM[$char][0]); - $col += intval($this::CHKSUM[$char][1]); + + $row += (int) $this::CHKSUM[$char][0]; + $col += (int) $this::CHKSUM[$char][1]; } + $row %= 6; $col %= 6; $check = array_keys($this::CHKSUM, $row . $col); @@ -180,18 +108,19 @@ protected function getCoreBars(): void for ($pos = 0; $pos < 4; ++$pos) { switch ($this::CHBAR[$char][$pos]) { case '1': - $this->bars[] = array($this->ncols, 0, 1, 2); + $this->bars[] = [$this->ncols, 0, 1, 2]; break; case '2': - $this->bars[] = array($this->ncols, 0, 1, 3); + $this->bars[] = [$this->ncols, 0, 1, 3]; break; case '3': - $this->bars[] = array($this->ncols, 1, 1, 1); + $this->bars[] = [$this->ncols, 1, 1, 1]; break; case '4': - $this->bars[] = array($this->ncols, 1, 1, 2); + $this->bars[] = [$this->ncols, 1, 1, 2]; break; } + $this->ncols += 2; } } @@ -206,16 +135,16 @@ protected function setBars(): void { $this->ncols = 0; $this->nrows = 3; - $this->bars = array(); + $this->bars = []; // start bar - $this->bars[] = array($this->ncols, 0, 1, 2); + $this->bars[] = [$this->ncols, 0, 1, 2]; $this->ncols += 2; $this->getCoreBars(); // stop bar - $this->bars[] = array($this->ncols, 0, 1, 3); + $this->bars[] = [$this->ncols, 0, 1, 3]; ++$this->ncols; } } diff --git a/src/Type/Linear/StandardTwoOfFiveCheck.php b/src/Type/Linear/StandardTwoOfFiveCheck.php index dbdc99c6..91628baf 100644 --- a/src/Type/Linear/StandardTwoOfFiveCheck.php +++ b/src/Type/Linear/StandardTwoOfFiveCheck.php @@ -46,18 +46,7 @@ class StandardTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = array( - '0' => '10101110111010', - '1' => '11101010101110', - '2' => '10111010101110', - '3' => '11101110101010', - '4' => '10101110101110', - '5' => '11101011101010', - '6' => '10111011101010', - '7' => '10101011101110', - '8' => '11101010111010', - '9' => '10111010111010' - ); + protected const CHBAR = ['0' => '10101110111010', '1' => '11101010101110', '2' => '10111010101110', '3' => '11101110101010', '4' => '10101110101110', '5' => '11101011101010', '6' => '10111011101010', '7' => '10101011101110', '8' => '11101010111010', '9' => '10111010111010']; /** * Calculate the checksum @@ -71,16 +60,19 @@ protected function getChecksum(string $code): int $clen = strlen($code); $sum = 0; for ($idx = 0; $idx < $clen; $idx += 2) { - $sum += intval($code[$idx]); + $sum += (int) $code[$idx]; } + $sum *= 3; for ($idx = 1; $idx < $clen; $idx += 2) { - $sum += intval($code[$idx]); + $sum += (int) $code[$idx]; } + $check = $sum % 10; if ($check > 0) { - $check = (10 - $check); + return 10 - $check; } + return $check; } @@ -100,10 +92,11 @@ protected function formatCode(): void protected function setBars(): void { $this::FORMATCode(); - if ((strlen($this->extcode) % 2) != 0) { + if (strlen($this->extcode) % 2 != 0) { // add leading zero if code-length is odd $this->extcode = '0' . $this->extcode; } + $seq = '1110111010'; $clen = strlen($this->extcode); for ($idx = 0; $idx < $clen; ++$idx) { @@ -111,8 +104,10 @@ protected function setBars(): void if (!isset($this::CHBAR[$digit])) { throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')'); } + $seq .= $this::CHBAR[$digit]; } + $seq .= '111010111'; $this->processBinarySequence($seq); } diff --git a/src/Type/Linear/UpcA.php b/src/Type/Linear/UpcA.php index aef079c5..2f886469 100644 --- a/src/Type/Linear/UpcA.php +++ b/src/Type/Linear/UpcA.php @@ -43,8 +43,6 @@ class UpcA extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree /** * Fixed code length - * - * @var int */ protected int $code_length = 12; diff --git a/src/Type/Linear/UpcE.php b/src/Type/Linear/UpcE.php index 3ec89de2..12d8e42e 100644 --- a/src/Type/Linear/UpcE.php +++ b/src/Type/Linear/UpcE.php @@ -47,8 +47,6 @@ class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA /** * Fixed code length - * - * @var int */ protected int $code_length = 12; @@ -57,51 +55,27 @@ class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA * * @var array>> */ - protected const PARITIES = array( - 0 => array( - '0' => array('B','B','B','A','A','A'), - '1' => array('B','B','A','B','A','A'), - '2' => array('B','B','A','A','B','A'), - '3' => array('B','B','A','A','A','B'), - '4' => array('B','A','B','B','A','A'), - '5' => array('B','A','A','B','B','A'), - '6' => array('B','A','A','A','B','B'), - '7' => array('B','A','B','A','B','A'), - '8' => array('B','A','B','A','A','B'), - '9' => array('B','A','A','B','A','B') - ), - 1 => array( - '0' => array('A','A','A','B','B','B'), - '1' => array('A','A','B','A','B','B'), - '2' => array('A','A','B','B','A','B'), - '3' => array('A','A','B','B','B','A'), - '4' => array('A','B','A','A','B','B'), - '5' => array('A','B','B','A','A','B'), - '6' => array('A','B','B','B','A','A'), - '7' => array('A','B','A','B','A','B'), - '8' => array('A','B','A','B','B','A'), - '9' => array('A','B','B','A','B','A') - ) - ); + protected const PARITIES = [0 => ['0' => ['B', 'B', 'B', 'A', 'A', 'A'], '1' => ['B', 'B', 'A', 'B', 'A', 'A'], '2' => ['B', 'B', 'A', 'A', 'B', 'A'], '3' => ['B', 'B', 'A', 'A', 'A', 'B'], '4' => ['B', 'A', 'B', 'B', 'A', 'A'], '5' => ['B', 'A', 'A', 'B', 'B', 'A'], '6' => ['B', 'A', 'A', 'A', 'B', 'B'], '7' => ['B', 'A', 'B', 'A', 'B', 'A'], '8' => ['B', 'A', 'B', 'A', 'A', 'B'], '9' => ['B', 'A', 'A', 'B', 'A', 'B']], 1 => ['0' => ['A', 'A', 'A', 'B', 'B', 'B'], '1' => ['A', 'A', 'B', 'A', 'B', 'B'], '2' => ['A', 'A', 'B', 'B', 'A', 'B'], '3' => ['A', 'A', 'B', 'B', 'B', 'A'], '4' => ['A', 'B', 'A', 'A', 'B', 'B'], '5' => ['A', 'B', 'B', 'A', 'A', 'B'], '6' => ['A', 'B', 'B', 'B', 'A', 'A'], '7' => ['A', 'B', 'A', 'B', 'A', 'B'], '8' => ['A', 'B', 'A', 'B', 'B', 'A'], '9' => ['A', 'B', 'B', 'A', 'B', 'A']]]; /** * Convert UPC-E code to UPC-A * * @param string $code Code to convert. - * - * @return string */ protected function convertUpceToUpca(string $code): string { if ($code[5] < 3) { return '0' . $code[0] . $code[1] . $code[5] . '0000' . $code[2] . $code[3] . $code[4]; } + if ($code[5] == 3) { return '0' . $code[0] . $code[1] . $code[2] . '00000' . $code[3] . $code[4]; } + if ($code[5] == 4) { return '0' . $code[0] . $code[1] . $code[2] . $code[3] . '00000' . $code[4]; } + return '0' . $code[0] . $code[1] . $code[2] . $code[3] . $code[4] . '0000' . $code[5]; } @@ -109,8 +83,6 @@ protected function convertUpceToUpca(string $code): string * Convert UPC-A code to UPC-E * * @param string $code Code to convert. - * - * @return string */ protected function convertUpcaToUpce(string $code): string { @@ -119,16 +91,19 @@ protected function convertUpcaToUpce(string $code): string // manufacturer code ends in 000, 100, or 200 return substr($code, 2, 2) . substr($code, 9, 3) . substr($code, 4, 1); } + $tmp = substr($code, 5, 2); if ($tmp == '00') { // manufacturer code ends in 00 return substr($code, 2, 3) . substr($code, 10, 2) . '3'; } + $tmp = substr($code, 6, 1); if ($tmp == '0') { // manufacturer code ends in 0 return substr($code, 2, 4) . substr($code, 11, 1) . '4'; } + // manufacturer code does not end in zero return substr($code, 2, 5) . substr($code, 11, 1); } @@ -142,6 +117,7 @@ protected function formatCode(): void if (strlen($code) == 6) { $code = $this->convertUpceToUpca($code); } + $code = str_pad($code, ($this->code_length - 1), '0', STR_PAD_LEFT); $code .= $this->getChecksum($code); ++$this->code_length; @@ -162,6 +138,7 @@ protected function setBars(): void for ($pos = 0; $pos < 6; ++$pos) { $seq .= $this::CHBAR[$parity[$pos]][$upce_code[$pos]]; } + $seq .= '010101'; // right guard bar $this->processBinarySequence($seq); } diff --git a/src/Type/Raw.php b/src/Type/Raw.php index c0c14af7..9f4b7227 100644 --- a/src/Type/Raw.php +++ b/src/Type/Raw.php @@ -36,14 +36,13 @@ class Raw extends \Com\Tecnick\Barcode\Type { /** * Get the pre-formatted code - * - * @return array */ protected function getCodeRows(): array { if (is_array($this->code)) { return $this->code; } + // remove spaces and newlines $code = preg_replace('/[\s]*/s', '', $this->code); // remove trailing brackets or commas @@ -62,33 +61,35 @@ protected function getCodeRows(): array protected function setBars(): void { $rows = $this->getCodeRows(); - if (empty($rows)) { + if ($rows === []) { throw new BarcodeException('Empty input string'); } + $this->nrows = count($rows); - if (is_array($rows[0])) { - $this->ncols = count($rows[0]); - } else { - $this->ncols = strlen($rows[0]); - } - if (empty($this->ncols)) { + $this->ncols = is_array($rows[0]) ? count($rows[0]) : strlen($rows[0]); + + if ($this->ncols === 0) { throw new BarcodeException('Empty columns'); } - $this->bars = array(); + + $this->bars = []; foreach ($rows as $posy => $row) { if (!is_array($row)) { $row = str_split($row, 1); } + $prevcol = ''; $bar_width = 0; $row[] = '0'; for ($posx = 0; $posx <= $this->ncols; ++$posx) { if ($row[$posx] != $prevcol) { if ($prevcol == '1') { - $this->bars[] = array(($posx - $bar_width), $posy, $bar_width, 1); + $this->bars[] = [($posx - $bar_width), $posy, $bar_width, 1]; } + $bar_width = 0; } + ++$bar_width; $prevcol = $row[$posx]; } diff --git a/src/Type/Square/Aztec.php b/src/Type/Square/Aztec.php index 0d3660f7..5da98d56 100644 --- a/src/Type/Square/Aztec.php +++ b/src/Type/Square/Aztec.php @@ -45,15 +45,11 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square /** * Error correction code percentage of error check words. * A minimum of 23% + 3 words is recommended by ISO/IEC 24778:2008a. - * - * @var int */ protected int $ecc = 33; /** * Encoding mode - * - * @var string */ protected string $hint = 'A'; @@ -61,8 +57,6 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square * Mode: * - A = Automatic selection between Compact (priority) and Full Range. * - F = Force Full Range mode. - * - * @var string */ protected string $mode = 'A'; @@ -71,8 +65,6 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square * See Data:ECI for the list of supported codes. * NOTE: Even if special FNC1 or ECI flag characters could be inserted * at any points in the stream, this will only be added at the beginning of the stream. - * - * @var int */ protected int $eci = -1; @@ -92,25 +84,29 @@ protected function setParameters(): void if (!isset($this->params[0]) || !in_array($this->params[0], range(1, 100))) { $this->params[0] = 33; } - $this->ecc = intval($this->params[0]); + + $this->ecc = (int) $this->params[0]; // hint if (!isset($this->params[1]) || !in_array($this->params[1], ['A', 'B'])) { $this->params[1] = 'A'; } + $this->hint = $this->params[1]; // mode if (!isset($this->params[2]) || !in_array($this->params[2], ['A', 'F'])) { $this->params[2] = 'A'; } + $this->mode = $this->params[2]; // eci code. Used to set the charset encoding. See $this->eci. if (!isset($this->params[3]) || !array_key_exists($this->params[3], Data::ECI)) { $this->params[3] = -1; } - $this->eci = intval($this->params[3]); + + $this->eci = (int) $this->params[3]; } /** @@ -123,12 +119,13 @@ protected function setBars(): void if (strlen((string)$this->code) == 0) { throw new BarcodeException('Empty input'); } + try { - $enc = new Encode($this->code, $this->ecc, $this->eci, $this->hint, $this->mode); - $grid = $enc->getGrid(); + $encode = new Encode($this->code, $this->ecc, $this->eci, $this->hint, $this->mode); + $grid = $encode->getGrid(); $this->processBinarySequence($grid); - } catch (BarcodeException $e) { - throw new BarcodeException('AZTEC: ' . $e->getMessage()); + } catch (BarcodeException $barcodeException) { + throw new BarcodeException('AZTEC: ' . $barcodeException->getMessage()); } } } diff --git a/src/Type/Square/Aztec/Bitstream.php b/src/Type/Square/Aztec/Bitstream.php index b567fb01..adeb4207 100644 --- a/src/Type/Square/Aztec/Bitstream.php +++ b/src/Type/Square/Aztec/Bitstream.php @@ -56,6 +56,7 @@ protected function highLevelEncoding( $this->binaryEncode($chars, $chrlen); return; } + $this->autoEncode($chars, $chrlen); } @@ -72,25 +73,30 @@ protected function binaryEncode(array $chars, int $chrlen): void if ($chrlen > 62) { $this->addRawCwd(5, 0); $this->addRawCwd(11, ($chrlen - 31)); - for ($idx = 0; $idx < $chrlen; $idx++) { + for ($idx = 0; $idx < $chrlen; ++$idx) { $this->addRawCwd($bits, $chars[$idx]); } + return; } + if ($chrlen > 31) { $this->addRawCwd(5, 31); - for ($idx = 0; $idx < 31; $idx++) { + for ($idx = 0; $idx < 31; ++$idx) { $this->addRawCwd($bits, $chars[$idx]); } + $this->addShift(Data::MODE_BINARY); $this->addRawCwd(5, ($chrlen - 31)); - for ($idx = 31; $idx < $chrlen; $idx++) { + for ($idx = 31; $idx < $chrlen; ++$idx) { $this->addRawCwd($bits, $chars[$idx]); } + return; } + $this->addRawCwd(5, $chrlen); - for ($idx = 0; $idx < $chrlen; $idx++) { + for ($idx = 0; $idx < $chrlen; ++$idx) { $this->addRawCwd($bits, $chars[$idx]); } } @@ -108,9 +114,11 @@ protected function autoEncode(array $chars, int $chrlen): void if ($this->processBinaryChars($chars, $idx, $chrlen)) { continue; } + if ($this->processPunctPairs($chars, $idx, $chrlen)) { continue; } + $this->processModeChars($chars, $idx, $chrlen); } } @@ -125,33 +133,29 @@ protected function autoEncode(array $chars, int $chrlen): void protected function processModeChars(array &$chars, int &$idx, int $chrlen): void { $ord = $chars[$idx]; - if ($this->isSameMode($this->encmode, $ord)) { - $mode = $this->encmode; - } else { - $mode = $this->charMode($ord); - } + $mode = $this->isSameMode($this->encmode, $ord) ? $this->encmode : $this->charMode($ord); + $nchr = $this->countModeChars($chars, $idx, $chrlen, $mode); - if ($this->encmode != $mode) { - if (($nchr == 1) && (!empty(Data::SHIFT_MAP[$this->encmode][$mode]))) { + if ($this->encmode !== $mode) { + if (($nchr == 1) && (isset(Data::SHIFT_MAP[$this->encmode][$mode]) && Data::SHIFT_MAP[$this->encmode][$mode] !== [])) { $this->addShift($mode); } else { $this->addLatch($mode); } } + $this->mergeTmpCwd(); $idx += $nchr; } /** - * Count consecutive characters in the same mode. - * - * @param array $chars The array of characters. - * @param int $idx The current character index. - * @param int $chrlen The total number of characters to process. - * @param int $mode The current mode. - * - * @return int - */ + * Count consecutive characters in the same mode. + * + * @param array $chars The array of characters. + * @param int $idx The current character index. + * @param int $chrlen The total number of characters to process. + * @param int $mode The current mode. + */ protected function countModeChars( array &$chars, int $idx, @@ -159,7 +163,7 @@ protected function countModeChars( int $mode ): int { - $this->tmpCdws = array(); + $this->tmpCdws = []; $nbits = Data::MODE_BITS[$mode]; $count = 0; do { @@ -170,10 +174,12 @@ protected function countModeChars( ) { return $count; } - $this->tmpCdws[] = array($nbits, $this->charEnc($mode, $ord)); - $count++; - $idx++; + + $this->tmpCdws[] = [$nbits, $this->charEnc($mode, $ord)]; + ++$count; + ++$idx; } while ($idx < $chrlen); + return $count; } @@ -196,6 +202,7 @@ protected function processBinaryChars( if ($binchrs == 0) { return false; } + $encmode = $this->encmode; $this->addShift(Data::MODE_BINARY); if ($binchrs > 62) { @@ -206,21 +213,25 @@ protected function processBinaryChars( $this->encmode = $encmode; return true; } + if ($binchrs > 31) { $nbits = Data::MODE_BITS[Data::MODE_BINARY]; $this->addRawCwd(5, 31); - for ($bcw = 0; $bcw < 31; $bcw++) { + for ($bcw = 0; $bcw < 31; ++$bcw) { $this->addRawCwd($nbits, $this->tmpCdws[$bcw][1]); } + $this->addShift(Data::MODE_BINARY); $this->addRawCwd(5, ($binchrs - 31)); - for ($bcw = 31; $bcw < $binchrs; $bcw++) { + for ($bcw = 31; $bcw < $binchrs; ++$bcw) { $this->addRawCwd($nbits, $this->tmpCdws[$bcw][1]); } + $idx += $binchrs; $this->encmode = $encmode; return true; } + $this->addRawCwd(5, $binchrs); $this->mergeTmpCwdRaw(); $idx += $binchrs; @@ -229,23 +240,22 @@ protected function processBinaryChars( } /** - * Count consecutive binary characters. - * - * @param array $chars The array of characters. - * @param int $idx The current character index. - * @param int $chrlen The total number of characters to process. - * - * @return int - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ + * Count consecutive binary characters. + * + * @param array $chars The array of characters. + * @param int $idx The current character index. + * @param int $chrlen The total number of characters to process. + * + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ protected function countBinaryChars( array &$chars, int $idx, int $chrlen ): int { - $this->tmpCdws = array(); + $this->tmpCdws = []; $count = 0; $nbits = Data::MODE_BITS[Data::MODE_BINARY]; while (($idx < $chrlen) && ($count < 2048)) { @@ -253,10 +263,12 @@ protected function countBinaryChars( if ($this->charMode($ord) != Data::MODE_BINARY) { return $count; } - $this->tmpCdws[] = array($nbits, $ord); - $count++; - $idx++; + + $this->tmpCdws[] = [$nbits, $ord]; + ++$count; + ++$idx; } + return $count; } @@ -282,6 +294,7 @@ protected function processPunctPairs( if ($ppairs == 0) { return false; } + switch ($this->encmode) { case Data::MODE_PUNCT: break; @@ -293,6 +306,7 @@ protected function processPunctPairs( if ($ppairs > 1) { $this->addLatch(Data::MODE_PUNCT); } + break; case Data::MODE_DIGIT: $common = $this->countPunctAndDigitChars($chars, $idx, $chrlen); @@ -303,11 +317,14 @@ protected function processPunctPairs( $idx += $clen; return true; } + if ($ppairs > 2) { $this->addLatch(Data::MODE_PUNCT); } + break; } + $this->mergeTmpCwd(Data::MODE_PUNCT); $idx += ($ppairs * 2); return true; @@ -319,8 +336,6 @@ protected function processPunctPairs( * @param array $chars The array of characters. * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. - * - * @return int */ protected function countPunctPairs( array &$chars, @@ -328,7 +343,7 @@ protected function countPunctPairs( int $chrlen ): int { - $this->tmpCdws = array(); + $this->tmpCdws = []; $pairs = 0; $maxidx = $chrlen - 1; while ($idx < $maxidx) { @@ -336,10 +351,12 @@ protected function countPunctPairs( if ($pmode == 0) { return $pairs; } - $this->tmpCdws[] = array(5, $pmode); - $pairs++; + + $this->tmpCdws[] = [5, $pmode]; + ++$pairs; $idx += 2; } + return $pairs; } @@ -350,8 +367,6 @@ protected function countPunctPairs( * @param array &$chars The string to count the characters in. * @param int $idx The starting index to count from. * @param int $chrlen The length of the string to count. - * - * @return array */ protected function countPunctAndDigitChars( array &$chars, @@ -359,15 +374,17 @@ protected function countPunctAndDigitChars( int $chrlen ): array { - $words = array(); + $words = []; while ($idx < $chrlen) { $ord = $chars[$idx]; if (!$this->isPunctAndDigitChar($ord)) { return $words; } - $words[] = array(4, $this->charEnc(Data::MODE_DIGIT, $ord)); - $idx++; + + $words[] = [4, $this->charEnc(Data::MODE_DIGIT, $ord)]; + ++$idx; } + return $words; } } diff --git a/src/Type/Square/Aztec/Codeword.php b/src/Type/Square/Aztec/Codeword.php index 425c7272..2ce0c0d0 100644 --- a/src/Type/Square/Aztec/Codeword.php +++ b/src/Type/Square/Aztec/Codeword.php @@ -36,36 +36,26 @@ abstract class Codeword { /** * Current character encoding mode. - * - * @var int */ protected int $encmode = Data::MODE_UPPER; /** * Array containing the high-level encoding bitstream. - * - * @var array */ - protected array $bitstream = array(); + protected array $bitstream = []; /** * Temporary array of codewords. - * - * @var array */ - protected array $tmpCdws = array(); + protected array $tmpCdws = []; /** * Array of data words. - * - * @var array */ - protected array $words = array(); + protected array $words = []; /** * Count the total number of bits in the bitstream. - * - * @var int */ protected int $totbits = 0; @@ -105,7 +95,7 @@ protected function charMode(int $ord): int protected function isSameMode(int $mode, int $ord): bool { return ( - ($mode == $this->charMode($ord)) + ($mode === $this->charMode($ord)) || (($ord == 32) && ($mode != Data::MODE_PUNCT)) || (($mode == Data::MODE_PUNCT) && (($ord == 13) || ($ord == 44) || ($ord == 46))) ); @@ -116,8 +106,6 @@ protected function isSameMode(int $mode, int $ord): bool * Characters ' ' (32), '.' (46) and ',' (44) are in common between the PUNCT and DIGIT modes. * * @param int $ord Integer ASCII code of the character to check. - * - * @return bool */ protected function isPunctAndDigitChar(int $ord): bool { @@ -130,23 +118,17 @@ protected function isPunctAndDigitChar(int $ord): bool * * @param int $ord The current curacter code. * @param int $next The next character code. - * - * @return int */ protected function punctPairMode(int $ord, int $next): int { $key = (($ord << 8) + $next); - switch ($key) { - case ((13 << 8) + 10): // '\r\n' (CR LF) - return 2; - case ((46 << 8) + 32): // '. ' (. SP) - return 3; - case ((44 << 8) + 32): // ', ' (, SP) - return 4; - case ((58 << 8) + 32): // ': ' (: SP) - return 5; - } - return 0; // no punct pair + return match ($key) { + (13 << 8) + 10 => 2, + (46 << 8) + 32 => 3, + (44 << 8) + 32 => 4, + (58 << 8) + 32 => 5, + default => 0, + }; // no punct pair } /** @@ -164,9 +146,10 @@ protected function appendWordToBitstream( int $value ): VOID { - for ($idx = ($wsize - 1); $idx >= 0; $idx--) { + for ($idx = ($wsize - 1); $idx >= 0; --$idx) { $bitstream[] = (($value >> $idx) & 1); } + $totbits += $wsize; } @@ -176,8 +159,6 @@ protected function appendWordToBitstream( * @param array $bitstream Array of bits to convert. * @param int $totbits Number of bits in the bitstream. * @param int $wsize The word size. - * - * @return array */ protected function bitstreamToWords( array $bitstream, @@ -185,18 +166,20 @@ protected function bitstreamToWords( int $wsize ): array { - $words = array(); - $numwords = intval(ceil($totbits / $wsize)); - for ($idx = 0; $idx < $numwords; $idx++) { + $words = []; + $numwords = (int) ceil($totbits / $wsize); + for ($idx = 0; $idx < $numwords; ++$idx) { $wrd = 0; - for ($bit = 0; $bit < $wsize; $bit++) { + for ($bit = 0; $bit < $wsize; ++$bit) { $pos = (($idx * $wsize) + $bit); if (!empty($bitstream[$pos]) || !isset($bitstream[$pos])) { $wrd |= (1 << ($wsize - $bit - 1)); // reverse order } } + $words[] = $wrd; } + return $words; } @@ -233,6 +216,7 @@ protected function addLatch(int $mode): void foreach ($latch as $cdw) { $this->addRawCwd($cdw[0], $cdw[1]); } + $this->encmode = $mode; } @@ -255,9 +239,9 @@ protected function addShift(int $mode): void */ protected function mergeTmpCwdWithShift(int $mode): void { - foreach ($this->tmpCdws as $item) { + foreach ($this->tmpCdws as $tmpCdw) { $this->addShift($mode); - $this->addRawCwd($item[0], $item[1]); + $this->addRawCwd($tmpCdw[0], $tmpCdw[1]); } } @@ -267,8 +251,8 @@ protected function mergeTmpCwdWithShift(int $mode): void */ protected function mergeTmpCwdRaw(): void { - foreach ($this->tmpCdws as $item) { - $this->addRawCwd($item[0], $item[1]); + foreach ($this->tmpCdws as $tmpCdw) { + $this->addRawCwd($tmpCdw[0], $tmpCdw[1]); } } @@ -285,7 +269,8 @@ protected function mergeTmpCwd(int $mode = -1): void } else { $this->mergeTmpCwdWithShift($mode); } - $this->tmpCdws = array(); + + $this->tmpCdws = []; } /** @@ -298,17 +283,20 @@ protected function addFLG(int $eci): void if ($eci < 0) { return; } + if ($this->encmode != Data::MODE_PUNCT) { $this->addShift(Data::MODE_PUNCT); } + if ($eci == 0) { $this->addRawCwd(3, 0); // FNC1 return; } + $seci = (string)$eci; $digits = strlen($seci); $this->addRawCwd(3, $digits); // 1–6 digits - for ($idx = 0; $idx < $digits; $idx++) { + for ($idx = 0; $idx < $digits; ++$idx) { $this->addCdw( Data::MODE_DIGIT, $this->charEnc(Data::MODE_DIGIT, ord($seci[$idx])) diff --git a/src/Type/Square/Aztec/Data.php b/src/Type/Square/Aztec/Data.php index 024283be..70aa111a 100644 --- a/src/Type/Square/Aztec/Data.php +++ b/src/Type/Square/Aztec/Data.php @@ -66,156 +66,275 @@ class Data /** * Number of bits for each character encoding mode. */ - public const MODE_BITS = array( - 5, // 0 = MODE_UPPER - 5, // 1 = MODE_LOWER - 4, // 2 = MODE_DIGIT - 5, // 3 = MODE_MIXED - 5, // 4 = MODE_PUNCT - 8 // 5 = MODE_BINARY - ); + public const MODE_BITS = [ + 5, + // 0 = MODE_UPPER + 5, + // 1 = MODE_LOWER + 4, + // 2 = MODE_DIGIT + 5, + // 3 = MODE_MIXED + 5, + // 4 = MODE_PUNCT + 8, + ]; /** * Code character encoding for each mode. */ - public const CHAR_ENC = array( + public const CHAR_ENC = [ // MODE_UPPER (initial mode) - 0 => array( - 32 => 1, // ' ' (SP) - 65 => 2, // 'A' - 66 => 3, // 'B' - 67 => 4, // 'C' - 68 => 5, // 'D' - 69 => 6, // 'E' - 70 => 7, // 'F' - 71 => 8, // 'G' - 72 => 9, // 'H' - 73 => 10, // 'I' - 74 => 11, // 'J' - 75 => 12, // 'K' - 76 => 13, // 'L' - 77 => 14, // 'M' - 78 => 15, // 'N' - 79 => 16, // 'O' - 80 => 17, // 'P' - 81 => 18, // 'Q' - 82 => 19, // 'R' - 83 => 20, // 'S' - 84 => 21, // 'T' - 85 => 22, // 'U' - 86 => 23, // 'V' - 87 => 24, // 'W' - 88 => 25, // 'X' - 89 => 26, // 'Y' - 90 => 27 // 'Z' - ), + 0 => [ + 32 => 1, + // ' ' (SP) + 65 => 2, + // 'A' + 66 => 3, + // 'B' + 67 => 4, + // 'C' + 68 => 5, + // 'D' + 69 => 6, + // 'E' + 70 => 7, + // 'F' + 71 => 8, + // 'G' + 72 => 9, + // 'H' + 73 => 10, + // 'I' + 74 => 11, + // 'J' + 75 => 12, + // 'K' + 76 => 13, + // 'L' + 77 => 14, + // 'M' + 78 => 15, + // 'N' + 79 => 16, + // 'O' + 80 => 17, + // 'P' + 81 => 18, + // 'Q' + 82 => 19, + // 'R' + 83 => 20, + // 'S' + 84 => 21, + // 'T' + 85 => 22, + // 'U' + 86 => 23, + // 'V' + 87 => 24, + // 'W' + 88 => 25, + // 'X' + 89 => 26, + // 'Y' + 90 => 27, + ], // MODE_LOWER - 1 => array( - 32 => 1, // ' ' (SP) - 97 => 2, // 'a' - 98 => 3, // 'b' - 99 => 4, // 'c' - 100 => 5, // 'd' - 101 => 6, // 'e' - 102 => 7, // 'f' - 103 => 8, // 'g' - 104 => 9, // 'h' - 105 => 10, // 'i' - 106 => 11, // 'j' - 107 => 12, // 'k' - 108 => 13, // 'l' - 109 => 14, // 'm' - 110 => 15, // 'n' - 111 => 16, // 'o' - 112 => 17, // 'p' - 113 => 18, // 'q' - 114 => 19, // 'r' - 115 => 20, // 's' - 116 => 21, // 't' - 117 => 22, // 'u' - 118 => 23, // 'v' - 119 => 24, // 'w' - 120 => 25, // 'x' - 121 => 26, // 'y' - 122 => 27 // 'z' - ), + 1 => [ + 32 => 1, + // ' ' (SP) + 97 => 2, + // 'a' + 98 => 3, + // 'b' + 99 => 4, + // 'c' + 100 => 5, + // 'd' + 101 => 6, + // 'e' + 102 => 7, + // 'f' + 103 => 8, + // 'g' + 104 => 9, + // 'h' + 105 => 10, + // 'i' + 106 => 11, + // 'j' + 107 => 12, + // 'k' + 108 => 13, + // 'l' + 109 => 14, + // 'm' + 110 => 15, + // 'n' + 111 => 16, + // 'o' + 112 => 17, + // 'p' + 113 => 18, + // 'q' + 114 => 19, + // 'r' + 115 => 20, + // 's' + 116 => 21, + // 't' + 117 => 22, + // 'u' + 118 => 23, + // 'v' + 119 => 24, + // 'w' + 120 => 25, + // 'x' + 121 => 26, + // 'y' + 122 => 27, + ], // MODE_DIGIT - 2 => array( - 32 => 1, // ' ' (SP) - 44 => 12, // ',' - 46 => 13, // '.' - 48 => 2, // '0' - 49 => 3, // '1' - 50 => 4, // '2' - 51 => 5, // '3' - 52 => 6, // '4' - 53 => 7, // '5' - 54 => 8, // '6' - 55 => 9, // '7' - 56 => 10, // '8' - 57 => 11 // '9' - ), + 2 => [ + 32 => 1, + // ' ' (SP) + 44 => 12, + // ',' + 46 => 13, + // '.' + 48 => 2, + // '0' + 49 => 3, + // '1' + 50 => 4, + // '2' + 51 => 5, + // '3' + 52 => 6, + // '4' + 53 => 7, + // '5' + 54 => 8, + // '6' + 55 => 9, + // '7' + 56 => 10, + // '8' + 57 => 11, + ], // MODE_MIXED - 3 => array( - 1 => 2, // '^A' (SOH) - 2 => 3, // '^B' (STX) - 3 => 4, // '^C' (ETX) - 4 => 5, // '^D' (EOT) - 5 => 6, // '^E' (ENQ) - 6 => 7, // '^F' (ACK) - 7 => 8, // '^G' (BEL) - 8 => 9, // '^H' (BS) - 9 => 10, // '^I' (HT) - 10 => 11, // '^J' (LF) - 11 => 12, // '^K' (VT) - 12 => 13, // '^L' (FF) - 13 => 14, // '^M' (CR) - 27 => 15, // '^[' (ESC) - 28 => 16, // '^\' (FS) - 29 => 17, // '^]' (GS) - 30 => 18, // '^^' (RS) - 31 => 19, // '^_' (US) - 64 => 20, // '@' - 92 => 21, // '\' - 94 => 22, // '^' - 95 => 23, // '_' - 96 => 24, // '`' - 124 => 25, // '|' - 126 => 26, // '~' - 127 => 27 // '^?' (DEL) - ), + 3 => [ + 1 => 2, + // '^A' (SOH) + 2 => 3, + // '^B' (STX) + 3 => 4, + // '^C' (ETX) + 4 => 5, + // '^D' (EOT) + 5 => 6, + // '^E' (ENQ) + 6 => 7, + // '^F' (ACK) + 7 => 8, + // '^G' (BEL) + 8 => 9, + // '^H' (BS) + 9 => 10, + // '^I' (HT) + 10 => 11, + // '^J' (LF) + 11 => 12, + // '^K' (VT) + 12 => 13, + // '^L' (FF) + 13 => 14, + // '^M' (CR) + 27 => 15, + // '^[' (ESC) + 28 => 16, + // '^\' (FS) + 29 => 17, + // '^]' (GS) + 30 => 18, + // '^^' (RS) + 31 => 19, + // '^_' (US) + 64 => 20, + // '@' + 92 => 21, + // '\' + 94 => 22, + // '^' + 95 => 23, + // '_' + 96 => 24, + // '`' + 124 => 25, + // '|' + 126 => 26, + // '~' + 127 => 27, + ], // MODE_PUNCT - 4 => array( - 13 => 1, // '\r' (CR) - 33 => 6, // '!' - 34 => 7, // '"' - 35 => 8, // '#' - 36 => 9, // '$' - 37 => 10, // '%' - 38 => 11, // '&' - 39 => 12, // ''' - 40 => 13, // '(' - 41 => 14, // ')' - 42 => 15, // '*' - 43 => 16, // '+' - 44 => 17, // ',' - 45 => 18, // '-' - 46 => 19, // '.' - 47 => 20, // '/' - 58 => 21, // ':' - 59 => 22, // ';' - 60 => 23, // '<' - 61 => 24, // '=' - 62 => 25, // '>' - 63 => 26, // '?' - 91 => 27, // '[' - 93 => 28, // ']' - 123 => 29, // '{' - 125 => 30 // '}' - ), + 4 => [ + 13 => 1, + // '\r' (CR) + 33 => 6, + // '!' + 34 => 7, + // '"' + 35 => 8, + // '#' + 36 => 9, + // '$' + 37 => 10, + // '%' + 38 => 11, + // '&' + 39 => 12, + // ''' + 40 => 13, + // '(' + 41 => 14, + // ')' + 42 => 15, + // '*' + 43 => 16, + // '+' + 44 => 17, + // ',' + 45 => 18, + // '-' + 46 => 19, + // '.' + 47 => 20, + // '/' + 58 => 21, + // ':' + 59 => 22, + // ';' + 60 => 23, + // '<' + 61 => 24, + // '=' + 62 => 25, + // '>' + 63 => 26, + // '?' + 91 => 27, + // '[' + 93 => 28, + // ']' + 123 => 29, + // '{' + 125 => 30, + ], // MODE_BINARY (all 8-bit values are valid) - 5 => array() - ); + 5 => [], + ]; /** * Map character ASCII codes to their non-binary mode. @@ -224,245 +343,400 @@ class Data * - the carriage return '\r' character (13) that maps for modes 3,4. * - the comma ',' and dot '.' characters (44,46) that map for modes 2,4. */ - public const CHAR_MODES = array( - 1 => 3, // '^A' (SOH) - 2 => 3, // '^B' (STX) - 3 => 3, // '^C' (ETX) - 4 => 3, // '^D' (EOT) - 5 => 3, // '^E' (ENQ) - 6 => 3, // '^F' (ACK) - 7 => 3, // '^G' (BEL) - 8 => 3, // '^H' (BS) - 9 => 3, // '^I' (HT) - 10 => 3, // '^J' (LF) - 11 => 3, // '^K' (VT) - 12 => 3, // '^L' (FF) - 13 => 3, // '^M' (CR) [3,4] - 27 => 3, // '^[' (ESC) - 28 => 3, // '^\' (FS) - 29 => 3, // '^]' (GS) - 30 => 3, // '^^' (RS) - 31 => 3, // '^_' (US) - 32 => 0, // ' ' [0,1,2] - 33 => 4, // '!' - 34 => 4, // '"' - 35 => 4, // '#' - 36 => 4, // '$' - 37 => 4, // '%' - 38 => 4, // '&' - 39 => 4, // ''' - 40 => 4, // '(' - 41 => 4, // ')' - 42 => 4, // '*' - 43 => 4, // '+'f - 44 => 2, // ',' [2,4] - 45 => 4, // '-' - 46 => 2, // '.' [2,4] - 47 => 4, // '/' - 48 => 2, // '0' - 49 => 2, // '1' - 50 => 2, // '2' - 51 => 2, // '3' - 52 => 2, // '4' - 53 => 2, // '5' - 54 => 2, // '6' - 55 => 2, // '7' - 56 => 2, // '8' - 57 => 2, // '9' - 58 => 4, // ':' - 59 => 4, // ';' - 60 => 4, // '<' - 61 => 4, // '=' - 62 => 4, // '>' - 63 => 4, // '?' - 64 => 3, // '@' - 65 => 0, // 'A' - 66 => 0, // 'B' - 67 => 0, // 'C' - 68 => 0, // 'D' - 69 => 0, // 'E' - 70 => 0, // 'F' - 71 => 0, // 'G' - 72 => 0, // 'H' - 73 => 0, // 'I' - 74 => 0, // 'J' - 75 => 0, // 'K' - 76 => 0, // 'L' - 77 => 0, // 'M' - 78 => 0, // 'N' - 79 => 0, // 'O' - 80 => 0, // 'P' - 81 => 0, // 'Q' - 82 => 0, // 'R' - 83 => 0, // 'S' - 84 => 0, // 'T' - 85 => 0, // 'U' - 86 => 0, // 'V' - 87 => 0, // 'W' - 88 => 0, // 'X' - 89 => 0, // 'Y' - 90 => 0, // 'Z' - 91 => 4, // '[' - 92 => 3, // '\' - 93 => 4, // ']' - 94 => 3, // '^' - 95 => 3, // '_' - 96 => 3, // '`' - 97 => 1, // 'a' - 98 => 1, // 'b' - 99 => 1, // 'c' - 100 => 1, // 'd' - 101 => 1, // 'e' - 102 => 1, // 'f' - 103 => 1, // 'g' - 104 => 1, // 'h' - 105 => 1, // 'i' - 106 => 1, // 'j' - 107 => 1, // 'k' - 108 => 1, // 'l' - 109 => 1, // 'm' - 110 => 1, // 'n' - 111 => 1, // 'o' - 112 => 1, // 'p' - 113 => 1, // 'q' - 114 => 1, // 'r' - 115 => 1, // 's' - 116 => 1, // 't' - 117 => 1, // 'u' - 118 => 1, // 'v' - 119 => 1, // 'w' - 120 => 1, // 'x' - 121 => 1, // 'y' - 122 => 1, // 'z' - 123 => 4, // '{' - 124 => 3, // '|' - 125 => 4, // '}' - 126 => 3, // '~' - 127 => 3 // '^?' (DEL) - ); + public const CHAR_MODES = [ + 1 => 3, + // '^A' (SOH) + 2 => 3, + // '^B' (STX) + 3 => 3, + // '^C' (ETX) + 4 => 3, + // '^D' (EOT) + 5 => 3, + // '^E' (ENQ) + 6 => 3, + // '^F' (ACK) + 7 => 3, + // '^G' (BEL) + 8 => 3, + // '^H' (BS) + 9 => 3, + // '^I' (HT) + 10 => 3, + // '^J' (LF) + 11 => 3, + // '^K' (VT) + 12 => 3, + // '^L' (FF) + 13 => 3, + // '^M' (CR) [3,4] + 27 => 3, + // '^[' (ESC) + 28 => 3, + // '^\' (FS) + 29 => 3, + // '^]' (GS) + 30 => 3, + // '^^' (RS) + 31 => 3, + // '^_' (US) + 32 => 0, + // ' ' [0,1,2] + 33 => 4, + // '!' + 34 => 4, + // '"' + 35 => 4, + // '#' + 36 => 4, + // '$' + 37 => 4, + // '%' + 38 => 4, + // '&' + 39 => 4, + // ''' + 40 => 4, + // '(' + 41 => 4, + // ')' + 42 => 4, + // '*' + 43 => 4, + // '+'f + 44 => 2, + // ',' [2,4] + 45 => 4, + // '-' + 46 => 2, + // '.' [2,4] + 47 => 4, + // '/' + 48 => 2, + // '0' + 49 => 2, + // '1' + 50 => 2, + // '2' + 51 => 2, + // '3' + 52 => 2, + // '4' + 53 => 2, + // '5' + 54 => 2, + // '6' + 55 => 2, + // '7' + 56 => 2, + // '8' + 57 => 2, + // '9' + 58 => 4, + // ':' + 59 => 4, + // ';' + 60 => 4, + // '<' + 61 => 4, + // '=' + 62 => 4, + // '>' + 63 => 4, + // '?' + 64 => 3, + // '@' + 65 => 0, + // 'A' + 66 => 0, + // 'B' + 67 => 0, + // 'C' + 68 => 0, + // 'D' + 69 => 0, + // 'E' + 70 => 0, + // 'F' + 71 => 0, + // 'G' + 72 => 0, + // 'H' + 73 => 0, + // 'I' + 74 => 0, + // 'J' + 75 => 0, + // 'K' + 76 => 0, + // 'L' + 77 => 0, + // 'M' + 78 => 0, + // 'N' + 79 => 0, + // 'O' + 80 => 0, + // 'P' + 81 => 0, + // 'Q' + 82 => 0, + // 'R' + 83 => 0, + // 'S' + 84 => 0, + // 'T' + 85 => 0, + // 'U' + 86 => 0, + // 'V' + 87 => 0, + // 'W' + 88 => 0, + // 'X' + 89 => 0, + // 'Y' + 90 => 0, + // 'Z' + 91 => 4, + // '[' + 92 => 3, + // '\' + 93 => 4, + // ']' + 94 => 3, + // '^' + 95 => 3, + // '_' + 96 => 3, + // '`' + 97 => 1, + // 'a' + 98 => 1, + // 'b' + 99 => 1, + // 'c' + 100 => 1, + // 'd' + 101 => 1, + // 'e' + 102 => 1, + // 'f' + 103 => 1, + // 'g' + 104 => 1, + // 'h' + 105 => 1, + // 'i' + 106 => 1, + // 'j' + 107 => 1, + // 'k' + 108 => 1, + // 'l' + 109 => 1, + // 'm' + 110 => 1, + // 'n' + 111 => 1, + // 'o' + 112 => 1, + // 'p' + 113 => 1, + // 'q' + 114 => 1, + // 'r' + 115 => 1, + // 's' + 116 => 1, + // 't' + 117 => 1, + // 'u' + 118 => 1, + // 'v' + 119 => 1, + // 'w' + 120 => 1, + // 'x' + 121 => 1, + // 'y' + 122 => 1, + // 'z' + 123 => 4, + // '{' + 124 => 3, + // '|' + 125 => 4, + // '}' + 126 => 3, + // '~' + 127 => 3, + ]; /** * Latch map for changing character encoding mode. * Numbers represent: [number of bits to change, latch code value]. */ - public const LATCH_MAP = array( + public const LATCH_MAP = [ // MODE_UPPER - 0 => array ( - 1 => array(array(5,28)), // -> LOWER - 2 => array(array(5,30)), // -> DIGIT - 3 => array(array(5,29)), // -> MIXED - 4 => array(array(5,29),array(5,30)) // -> MIXED -> PUNCT - ), - // MODE_LOWER - 1 => array ( - 0 => array(array(5,30),array(4,14)), // -> DIGIT -> UPPER - 2 => array(array(5,30)), // -> DIGIT - 3 => array(array(5,29)), // -> MIXED - 4 => array(array(5,29),array(5,30)) // -> MIXED -> PUNCT - ), - // MODE_DIGIT - 2 => array ( - 0 => array(array(4,14)), // -> UPPER - 1 => array(array(4,14),array(5,28)), // -> UPPER -> LOWER - 3 => array(array(4,14),array(5,29)), // -> UPPER -> MIXED - 4 => array(array(4,14),array(5,29),array(5,30)) // -> UPPER -> MIXED -> PUNCT - ), - // MODE_MIXED - 3 => array ( - 0 => array(array(5,29)), // -> UPPER - 1 => array(array(5,28)), // -> LOWER - 2 => array(array(5,29),array(5,30)), // -> UPPER -> DIGIT - 4 => array(array(5, 30)) // -> PUNCT - ), - // MODE_PUNCT - 4 => array ( - 0 => array(array(5,31)), // -> UPPER - 1 => array(array(5,31),array(5,28)), // -> UPPER -> LOWER - 2 => array(array(5,31),array(5,30)), // -> UPPER -> DIGIT - 3 => array(array(5,31),array(5,29)), // -> UPPER -> MIXED - ) - ); + 0 => [ + 1 => [[5, 28]], + // -> LOWER + 2 => [[5, 30]], + // -> DIGIT + 3 => [[5, 29]], + // -> MIXED + 4 => [[5, 29], [5, 30]], + ], + // MODE_LOWER + 1 => [ + 0 => [[5, 30], [4, 14]], + // -> DIGIT -> UPPER + 2 => [[5, 30]], + // -> DIGIT + 3 => [[5, 29]], + // -> MIXED + 4 => [[5, 29], [5, 30]], + ], + // MODE_DIGIT + 2 => [ + 0 => [[4, 14]], + // -> UPPER + 1 => [[4, 14], [5, 28]], + // -> UPPER -> LOWER + 3 => [[4, 14], [5, 29]], + // -> UPPER -> MIXED + 4 => [[4, 14], [5, 29], [5, 30]], + ], + // MODE_MIXED + 3 => [ + 0 => [[5, 29]], + // -> UPPER + 1 => [[5, 28]], + // -> LOWER + 2 => [[5, 29], [5, 30]], + // -> UPPER -> DIGIT + 4 => [[5, 30]], + ], + // MODE_PUNCT + 4 => [ + 0 => [[5, 31]], + // -> UPPER + 1 => [[5, 31], [5, 28]], + // -> UPPER -> LOWER + 2 => [[5, 31], [5, 30]], + // -> UPPER -> DIGIT + 3 => [[5, 31], [5, 29]], + ], + ]; /** * Shift map for changing character encoding mode. * Numbers represent: [number of bits to change, shift code value]. */ - public const SHIFT_MAP = array( - // MODE_UPPER - 0 => array( - 1 => array(), - 2 => array(), - 3 => array(), - 4 => array(array(5,0)), // -> PUNCT - 5 => array(array(5,31)) // -> BINARY - ), - // MODE_LOWER - 1 => array ( - 0 => array(array(5,28)), // -> UPPER - 2 => array(), - 3 => array(), - 4 => array(array(5,0)), // -> PUNCT - 5 => array(array(5,31)) // -> BINARY - ), - // MODE_DIGIT - 2 => array ( - 0 => array(array(4,15)), // -> UPPER - 1 => array(), - 3 => array(), - 4 => array(array(4,0)), // -> PUNCT - 5 => array(array(4,14),array(5,31)) // -> LATCH UPPER -> BINARY - ), - // MODE_MIXED - 3 => array ( - 0 => array(), - 1 => array(), - 2 => array(), - 4 => array(array(5,0)), // -> PUNCT - 5 => array(array(5,31)) // -> BINARY - ), - // MODE_PUNCT - 4 => array ( - 0 => array(), - 1 => array(), - 2 => array(), - 3 => array(), - 5 => array(array(5,31),array(5,31)) // -> LATCH UPPER -> BINARY - ) - ); + public const SHIFT_MAP = [ + // MODE_UPPER + 0 => [ + 1 => [], + 2 => [], + 3 => [], + 4 => [[5, 0]], + // -> PUNCT + 5 => [[5, 31]], + ], + // MODE_LOWER + 1 => [ + 0 => [[5, 28]], + // -> UPPER + 2 => [], + 3 => [], + 4 => [[5, 0]], + // -> PUNCT + 5 => [[5, 31]], + ], + // MODE_DIGIT + 2 => [ + 0 => [[4, 15]], + // -> UPPER + 1 => [], + 3 => [], + 4 => [[4, 0]], + // -> PUNCT + 5 => [[4, 14], [5, 31]], + ], + // MODE_MIXED + 3 => [ + 0 => [], + 1 => [], + 2 => [], + 4 => [[5, 0]], + // -> PUNCT + 5 => [[5, 31]], + ], + // MODE_PUNCT + 4 => [0 => [], 1 => [], 2 => [], 3 => [], 5 => [[5, 31], [5, 31]]], + ]; /** * Extended Channel Interpretation (ECI) codes. */ - public const ECI = array( - 0 => 'FNC1', // Function 1 character - 2 => 'Cp437', // Code page 437 - 3 => 'ISO-8859-1', // ISO/IEC 8859-1 - Latin-1 (Default encoding) - 4 => 'ISO-8859-2', // ISO/IEC 8859-2 - Latin-2 - 5 => 'ISO-8859-3', // ISO/IEC 8859-3 - Latin-3 - 6 => 'ISO-8859-4', // ISO/IEC 8859-4 - Latin-4 - 7 => 'ISO-8859-5', // ISO/IEC 8859-5 - Latin/Cyrillic - 8 => 'ISO-8859-6', // ISO/IEC 8859-6 - Latin/Arabic - 9 => 'ISO-8859-7', // ISO/IEC 8859-7 - Latin/Greek - 10 => 'ISO-8859-8', // ISO/IEC 8859-8 - Latin/Hebrew - 11 => 'ISO-8859-9', // ISO/IEC 8859-9 - Latin-5 - 12 => 'ISO-8859-10', // ISO/IEC 8859-10 - Latin-6 - 13 => 'ISO-8859-11', // ISO/IEC 8859-11 - Latin/Thai - 15 => 'ISO-8859-13', // ISO/IEC 8859-13 - Latin-7 - 16 => 'ISO-8859-14', // ISO/IEC 8859-14 - Latin-8 (Celtic) - 17 => 'ISO-8859-15', // ISO/IEC 8859-15 - Latin-9 - 18 => 'ISO-8859-16', // ISO/IEC 8859-16 - Latin-10 - 20 => 'Shift JIS', // - 21 => 'Cp1250', // Windows-1250 - Superset of Latin-2 - 22 => 'Cp1251', // Windows-1251 - Latin/Cyrillic - 23 => 'Cp1252', // Windows-1252 - Superset of Latin-1 - 24 => 'Cp1256', // Windows-1256 - Arabic - 25 => 'UTF-16BE', // UnicodeBig, UnicodeBigUnmarked - 26 => 'UTF-8', // - 27 => 'US-ASCII', // - 28 => 'Big5', // - 29 => 'GB18030', // GB2312, EUC_CN, GBK - 30 => 'EUC-KR' // - ); + public const ECI = [ + 0 => 'FNC1', + // Function 1 character + 2 => 'Cp437', + // Code page 437 + 3 => 'ISO-8859-1', + // ISO/IEC 8859-1 - Latin-1 (Default encoding) + 4 => 'ISO-8859-2', + // ISO/IEC 8859-2 - Latin-2 + 5 => 'ISO-8859-3', + // ISO/IEC 8859-3 - Latin-3 + 6 => 'ISO-8859-4', + // ISO/IEC 8859-4 - Latin-4 + 7 => 'ISO-8859-5', + // ISO/IEC 8859-5 - Latin/Cyrillic + 8 => 'ISO-8859-6', + // ISO/IEC 8859-6 - Latin/Arabic + 9 => 'ISO-8859-7', + // ISO/IEC 8859-7 - Latin/Greek + 10 => 'ISO-8859-8', + // ISO/IEC 8859-8 - Latin/Hebrew + 11 => 'ISO-8859-9', + // ISO/IEC 8859-9 - Latin-5 + 12 => 'ISO-8859-10', + // ISO/IEC 8859-10 - Latin-6 + 13 => 'ISO-8859-11', + // ISO/IEC 8859-11 - Latin/Thai + 15 => 'ISO-8859-13', + // ISO/IEC 8859-13 - Latin-7 + 16 => 'ISO-8859-14', + // ISO/IEC 8859-14 - Latin-8 (Celtic) + 17 => 'ISO-8859-15', + // ISO/IEC 8859-15 - Latin-9 + 18 => 'ISO-8859-16', + // ISO/IEC 8859-16 - Latin-10 + 20 => 'Shift JIS', + // + 21 => 'Cp1250', + // Windows-1250 - Superset of Latin-2 + 22 => 'Cp1251', + // Windows-1251 - Latin/Cyrillic + 23 => 'Cp1252', + // Windows-1252 - Superset of Latin-1 + 24 => 'Cp1256', + // Windows-1256 - Arabic + 25 => 'UTF-16BE', + // UnicodeBig, UnicodeBigUnmarked + 26 => 'UTF-8', + // + 27 => 'US-ASCII', + // + 28 => 'Big5', + // + 29 => 'GB18030', + // GB2312, EUC_CN, GBK + 30 => 'EUC-KR', + ]; /** * Size and capacities of Aztec Compact Code symbols by number of layers. @@ -475,12 +749,7 @@ class Data * - 5: symbol data text capacity; * - 6: symbol data bytes capacity. */ - public const SIZE_COMPACT = array( - 1 => array(15, 17, 6, 102, 13, 12, 6), - 2 => array(19, 40, 6, 240, 40, 33, 19), - 3 => array(23, 51, 8, 408, 70, 57, 33), - 4 => array(27, 76, 8, 608, 110, 89, 53) - ); + public const SIZE_COMPACT = [1 => [15, 17, 6, 102, 13, 12, 6], 2 => [19, 40, 6, 240, 40, 33, 19], 3 => [23, 51, 8, 408, 70, 57, 33], 4 => [27, 76, 8, 608, 110, 89, 53]]; /** * Size and capacities of Aztec Full-range Code symbols by number of layers. @@ -493,38 +762,5 @@ class Data * - 5: symbol data text capacity; * - 6: symbol data bytes capacity. */ - public const SIZE_FULL = array( - 1 => array( 19, 21, 6, 126, 18, 15, 8), - 2 => array( 23, 48, 6, 288, 49, 40, 24), - 3 => array( 27, 60, 8, 480, 84, 68, 40), - 4 => array( 31, 88, 8, 704, 128, 104, 62), - 5 => array( 37, 120, 8, 960, 178, 144, 87), - 6 => array( 41, 156, 8, 1248, 232, 187, 114), - 7 => array( 45, 196, 8, 1568, 294, 236, 145), - 8 => array( 49, 240, 8, 1920, 362, 291, 179), - 9 => array( 53, 230, 10, 2300, 433, 348, 214), - 10 => array( 57, 272, 10, 2720, 516, 414, 256), - 11 => array( 61, 316, 10, 3160, 601, 482, 298), - 12 => array( 67, 364, 10, 3640, 691, 554, 343), - 13 => array( 71, 416, 10, 4160, 793, 636, 394), - 14 => array( 75, 470, 10, 4700, 896, 718, 446), - 15 => array( 79, 528, 10, 5280, 1008, 808, 502), - 16 => array( 83, 588, 10, 5880, 1123, 900, 559), - 17 => array( 87, 652, 10, 6520, 1246, 998, 621), - 18 => array( 91, 720, 10, 7200, 1378, 1104, 687), - 19 => array( 95, 790, 10, 7900, 1511, 1210, 753), - 20 => array(101, 864, 10, 8640, 1653, 1324, 824), - 21 => array(105, 940, 10, 9400, 1801, 1442, 898), - 22 => array(109, 1020, 10, 10200, 1956, 1566, 976), - 23 => array(113, 920, 12, 11040, 2116, 1694, 1056), - 24 => array(117, 992, 12, 11904, 2281, 1826, 1138), - 25 => array(121, 1066, 12, 12792, 2452, 1963, 1224), - 26 => array(125, 1144, 12, 13728, 2632, 2107, 1314), - 27 => array(131, 1224, 12, 14688, 2818, 2256, 1407), - 28 => array(135, 1306, 12, 15672, 3007, 2407, 1501), - 29 => array(139, 1392, 12, 16704, 3205, 2565, 1600), - 30 => array(143, 1480, 12, 17760, 3409, 2728, 1702), - 31 => array(147, 1570, 12, 18840, 3616, 2894, 1806), - 32 => array(151, 1664, 12, 19968, 3832, 3067, 1914) - ); + public const SIZE_FULL = [1 => [19, 21, 6, 126, 18, 15, 8], 2 => [23, 48, 6, 288, 49, 40, 24], 3 => [27, 60, 8, 480, 84, 68, 40], 4 => [31, 88, 8, 704, 128, 104, 62], 5 => [37, 120, 8, 960, 178, 144, 87], 6 => [41, 156, 8, 1248, 232, 187, 114], 7 => [45, 196, 8, 1568, 294, 236, 145], 8 => [49, 240, 8, 1920, 362, 291, 179], 9 => [53, 230, 10, 2300, 433, 348, 214], 10 => [57, 272, 10, 2720, 516, 414, 256], 11 => [61, 316, 10, 3160, 601, 482, 298], 12 => [67, 364, 10, 3640, 691, 554, 343], 13 => [71, 416, 10, 4160, 793, 636, 394], 14 => [75, 470, 10, 4700, 896, 718, 446], 15 => [79, 528, 10, 5280, 1008, 808, 502], 16 => [83, 588, 10, 5880, 1123, 900, 559], 17 => [87, 652, 10, 6520, 1246, 998, 621], 18 => [91, 720, 10, 7200, 1378, 1104, 687], 19 => [95, 790, 10, 7900, 1511, 1210, 753], 20 => [101, 864, 10, 8640, 1653, 1324, 824], 21 => [105, 940, 10, 9400, 1801, 1442, 898], 22 => [109, 1020, 10, 10200, 1956, 1566, 976], 23 => [113, 920, 12, 11040, 2116, 1694, 1056], 24 => [117, 992, 12, 11904, 2281, 1826, 1138], 25 => [121, 1066, 12, 12792, 2452, 1963, 1224], 26 => [125, 1144, 12, 13728, 2632, 2107, 1314], 27 => [131, 1224, 12, 14688, 2818, 2256, 1407], 28 => [135, 1306, 12, 15672, 3007, 2407, 1501], 29 => [139, 1392, 12, 16704, 3205, 2565, 1600], 30 => [143, 1480, 12, 17760, 3409, 2728, 1702], 31 => [147, 1570, 12, 18840, 3616, 2894, 1806], 32 => [151, 1664, 12, 19968, 3832, 3067, 1914]]; } diff --git a/src/Type/Square/Aztec/Encode.php b/src/Type/Square/Aztec/Encode.php index 9acb922a..ed7e1af9 100644 --- a/src/Type/Square/Aztec/Encode.php +++ b/src/Type/Square/Aztec/Encode.php @@ -37,15 +37,11 @@ class Encode extends \Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream { /** * Bidimensional grid containing the encoded data. - * - * @var array */ - protected array $grid = array(); + protected array $grid = []; /** * Coordinate of the grid center. - * - * @var int */ protected int $gridcenter = 0; @@ -70,6 +66,7 @@ public function __construct( if (!$this->sizeAndBitStuffing($ecc, $mode)) { throw new BarcodeException('Data too long'); } + $wsize = $this->layer[2]; $nbits = $this->layer[3]; $numcdw = $this->addCheckWords($this->bitstream, $this->totbits, $nbits, $wsize); @@ -80,8 +77,6 @@ public function __construct( /** * Returns the bidimensional grid containing the encoded data. - * - * @return array */ public function getGrid(): array { @@ -103,18 +98,19 @@ protected function addCheckWords( int &$totbits, int $nbits, int $wsize - ): int + ): int { $cdw = $this->bitstreamToWords($bitstream, $totbits, $wsize); $numcdw = count($cdw); - $totwords = intval($nbits / $wsize); + $totwords = (int) ($nbits / $wsize); $eccwords = ($totwords - $numcdw); - $ecc = new ErrorCorrection($wsize); - $checkwords = $ecc->checkwords($cdw, $eccwords); + $errorCorrection = new ErrorCorrection($wsize); + $checkwords = $errorCorrection->checkwords($cdw, $eccwords); // append check codewords - foreach ($checkwords as $val) { - $this->appendWordToBitstream($bitstream, $totbits, $wsize, $val); + foreach ($checkwords as $checkword) { + $this->appendWordToBitstream($bitstream, $totbits, $wsize, $checkword); } + return $numcdw; } @@ -128,12 +124,12 @@ protected function setGrid(): void $row = array_fill(0, $size, 0); $this->grid = array_fill(0, $size, $row); // draw center - $center = intval(($size - 1) / 2); + $center = (int) (($size - 1) / 2); $this->gridcenter = $center; $this->grid[$center][$center] = 1; // draw finder pattern (bulls-eye) $bewidth = $this->compact ? 11 : 15; - $bemid = intval(($bewidth - 1) / 2); + $bemid = (int) (($bewidth - 1) / 2); for ($rng = 2; $rng < $bemid; $rng += 2) { // center cross points $this->grid[($center + $rng)][($center)] = 1; @@ -145,7 +141,7 @@ protected function setGrid(): void $this->grid[($center + $rng)][($center - $rng)] = 1; $this->grid[($center - $rng)][($center + $rng)] = 1; $this->grid[($center - $rng)][($center - $rng)] = 1; - for ($pos = 1; $pos < $rng; $pos++) { + for ($pos = 1; $pos < $rng; ++$pos) { // horizontal points $this->grid[($center + $rng)][($center + $pos)] = 1; $this->grid[($center + $rng)][($center - $pos)] = 1; @@ -158,6 +154,7 @@ protected function setGrid(): void $this->grid[($center - $pos)][($center - $rng)] = 1; } } + // draw orientation patterns $this->grid[($center - $bemid)][($center - $bemid)] = 1; // TL $this->grid[($center - $bemid)][($center - $bemid + 1)] = 1; // TL-R @@ -168,8 +165,9 @@ protected function setGrid(): void if ($this->compact) { return; } + // draw reference grid for full mode - $halfsize = intval(($size - 1) / 2); + $halfsize = (int) (($size - 1) / 2); // central cross for ($pos = 8; $pos <= $halfsize; $pos += 2) { // horizontal @@ -179,6 +177,7 @@ protected function setGrid(): void $this->grid[($center - $pos)][($center)] = 1; $this->grid[($center + $pos)][($center)] = 1; } + // grid lines for ($pos = 2; $pos <= $halfsize; $pos += 2) { for ($ref = 16; $ref <= $halfsize; $ref += 16) { @@ -206,7 +205,7 @@ protected function setGrid(): void */ protected function drawMode(int $numcdw): void { - $modebs = array(); + $modebs = []; $nbits = 0; $center = $this->gridcenter; $modebits = 40; @@ -223,6 +222,7 @@ protected function drawMode(int $numcdw): void $srow = -5; $scol = -3; } + $this->appendWordToBitstream($modebs, $nbits, $layersbits, ($this->numlayers - 1)); $this->appendWordToBitstream($modebs, $nbits, $codewordsbits, ($numcdw - 1)); $this->addCheckWords($modebs, $nbits, $modebits, 4); @@ -231,34 +231,37 @@ protected function drawMode(int $numcdw): void // top $ypos = ($center + $srow); $xpos = ($center + $scol); - for ($pos = 0; $pos < $sidelen; $pos++) { + for ($pos = 0; $pos < $sidelen; ++$pos) { $xpos += $this->skipModeRefGrid($pos); $this->grid[$ypos][$xpos] = (empty($modebs[$bit++]) ? 0 : 1); - $xpos++; + ++$xpos; } + // right $ypos += 2; - $xpos++; - for ($pos = 0; $pos < $sidelen; $pos++) { + ++$xpos; + for ($pos = 0; $pos < $sidelen; ++$pos) { $ypos += $this->skipModeRefGrid($pos); $this->grid[$ypos][$xpos] = (empty($modebs[$bit++]) ? 0 : 1); - $ypos++; + ++$ypos; } + // bottom - $ypos++; + ++$ypos; $xpos -= 2; - for ($pos = 0; $pos < $sidelen; $pos++) { + for ($pos = 0; $pos < $sidelen; ++$pos) { $xpos -= $this->skipModeRefGrid($pos); $this->grid[$ypos][$xpos] = (empty($modebs[$bit++]) ? 0 : 1); - $xpos--; + --$xpos; } + // left $ypos -= 2; - $xpos--; - for ($pos = 0; $pos < $sidelen; $pos++) { + --$xpos; + for ($pos = 0; $pos < $sidelen; ++$pos) { $ypos -= $this->skipModeRefGrid($pos); $this->grid[$ypos][$xpos] = (empty($modebs[$bit++]) ? 0 : 1); - $ypos--; + --$ypos; } } @@ -266,8 +269,6 @@ protected function drawMode(int $numcdw): void * Returns a bit from the end of the bitstream and update the index. * * @param int $bit Index of the bit to pop. - * - * @return int */ protected function popBit(int &$bit): int { @@ -279,12 +280,10 @@ protected function popBit(int &$bit): int * Returns 1 if the current position must be skipped in Full mode. * * @param int $pos Position in the grid. - * - * @return int */ protected function skipModeRefGrid(int $pos): int { - return intval((!$this->compact) && ($pos == 5)); + return (int) ((!$this->compact) && ($pos == 5)); } @@ -292,12 +291,10 @@ protected function skipModeRefGrid(int $pos): int * Returns the offset for the specified position to skip the reference grid. * * @param int $pos Position in the grid. - * - * @return int */ protected function skipRefGrid(int $pos): int { - return intval((!$this->compact) && (($pos % 16) == 0)); + return (int) ((!$this->compact) && (($pos % 16) == 0)); } /** @@ -314,45 +311,50 @@ protected function drawData(): void $srow = -6; $scol = -5; } + $skip = 0; // skip reference grid while drwaing dominoes $bit = ($this->totbits - 1); // index of last bitstream bit (first to draw) - for ($layer = 0; $layer < $this->numlayers; $layer++) { + for ($layer = 0; $layer < $this->numlayers; ++$layer) { // top $ypos = ($center + $srow); $xpos = ($center + $scol); - for ($pos = 0; $pos < $llen; $pos++) { + for ($pos = 0; $pos < $llen; ++$pos) { $xpos += $this->skipRefGrid($xpos - $center); // skip reference grid $this->grid[$ypos][$xpos] = $this->popBit($bit); $this->grid[($ypos - 1 - $skip)][$xpos] = $this->popBit($bit); - $xpos++; + ++$xpos; } + // right - $ypos++; + ++$ypos; $xpos -= (2 + $skip); - for ($pos = 0; $pos < $llen; $pos++) { + for ($pos = 0; $pos < $llen; ++$pos) { $ypos += $this->skipRefGrid($ypos - $center); // skip reference grid $this->grid[$ypos][$xpos] = $this->popBit($bit); $this->grid[$ypos][($xpos + 1 + $skip)] = $this->popBit($bit); - $ypos++; + ++$ypos; } + // bottom $ypos -= (2 + $skip); - $xpos--; - for ($pos = 0; $pos < $llen; $pos++) { + --$xpos; + for ($pos = 0; $pos < $llen; ++$pos) { $xpos -= $this->skipRefGrid($xpos - $center); // skip reference grid $this->grid[$ypos][$xpos] = $this->popBit($bit); $this->grid[($ypos + 1 + $skip)][$xpos] = $this->popBit($bit); - $xpos--; + --$xpos; } + // left - $ypos--; + --$ypos; $xpos += (2 + $skip); - for ($pos = 0; $pos < $llen; $pos++) { + for ($pos = 0; $pos < $llen; ++$pos) { $ypos -= $this->skipRefGrid($ypos - $center); // skip reference grid $this->grid[$ypos][$xpos] = $this->popBit($bit); $this->grid[$ypos][($xpos - 1 - $skip)] = $this->popBit($bit); - $ypos--; + --$ypos; } + $llen += 4; $srow = ($ypos - $center); $srow -= $this->skipRefGrid($srow); diff --git a/src/Type/Square/Aztec/ErrorCorrection.php b/src/Type/Square/Aztec/ErrorCorrection.php index 0ecd0e5e..2b8d1d02 100644 --- a/src/Type/Square/Aztec/ErrorCorrection.php +++ b/src/Type/Square/Aztec/ErrorCorrection.php @@ -36,35 +36,33 @@ class ErrorCorrection /** * Galois Field primitive by word size. */ - protected const GF = array( - 4 => 19, // 10011 GF(16) (x^4 + x + 1) Mode message - 6 => 67, // 1000011 GF(64) (x^6 + x + 1) 01–02 layers - 8 => 301, // 100101101 GF(256) (x^8 + x^5 + x^3 + x^2 + 1) 03–08 layers - 10 => 1033, // 10000001001 GF(1024) (x^10 + x^3 + 1) 09–22 layers - 12 => 4201 // 1000001101001 GF(4096) (x^12 + x^6 + x^5 + x^3 + 1) 23–32 layers - ); + protected const GF = [ + 4 => 19, + // 10011 GF(16) (x^4 + x + 1) Mode message + 6 => 67, + // 1000011 GF(64) (x^6 + x + 1) 01–02 layers + 8 => 301, + // 100101101 GF(256) (x^8 + x^5 + x^3 + x^2 + 1) 03–08 layers + 10 => 1033, + // 10000001001 GF(1024) (x^10 + x^3 + 1) 09–22 layers + 12 => 4201, + ]; /** * Map the log and exp (inverse log) tables by word size. * NOTE: It is equal to 2^word_size. */ - protected const TSIZE = array( - 4 => 16, - 6 => 64, - 8 => 256, - 10 => 1024, - 12 => 4096 - ); + protected const TSIZE = [4 => 16, 6 => 64, 8 => 256, 10 => 1024, 12 => 4096]; /** * Log table. */ - protected array $tlog = array(); + protected array $tlog = []; /** * Exponential (inverse log) table. */ - protected array $texp = array(); + protected array $texp = []; /** * Size of the log and exp tables. @@ -86,8 +84,6 @@ public function __construct(int $wsize) * * @param array $data Array of data codewords to process. * @param int $necc Number of error correction bytes. - * - * @return array */ public function checkwords(array $data, int $necc): array { @@ -108,7 +104,7 @@ protected function genTables(int $wsize): void $primitive = self::GF[$wsize]; $val = 1; $sizeminusone = ($this->tsize - 1); - for ($idx = 0; $idx < $this->tsize; $idx++) { + for ($idx = 0; $idx < $this->tsize; ++$idx) { $this->texp[$idx] = $val; $val <<= 1; // multiply by 2 if ($val >= $this->tsize) { @@ -116,7 +112,8 @@ protected function genTables(int $wsize): void $val &= $sizeminusone; } } - for ($idx = 0; $idx < $this->tsize - 1; $idx++) { + + for ($idx = 0; $idx < $this->tsize - 1; ++$idx) { $this->tlog[$this->texp[$idx]] = $idx; } } @@ -131,10 +128,11 @@ protected function genTables(int $wsize): void */ protected function getCoefficients(array $data, int $necc): array { - $gen = array(1); - for ($idx = 1; $idx <= $necc; $idx++) { - $gen = $this->multiplyCoeff(array(1, $this->texp[$idx]), $gen); + $gen = [1]; + for ($idx = 1; $idx <= $necc; ++$idx) { + $gen = $this->multiplyCoeff([1, $this->texp[$idx]], $gen); } + $deg = ($necc + 1); $coeff = $this->multiplyByMonomial($data, 1, $necc); $len = count($coeff); @@ -144,6 +142,7 @@ protected function getCoefficients(array $data, int $necc): array $coeff = $this->addOrSubtract($coeff, $largercoeffs); $len = count($coeff); } + return $coeff; } @@ -152,19 +151,18 @@ protected function getCoefficients(array $data, int $necc): array * * @param array $acf First array of coefficients. * @param array $bcf Second array of coefficients. - * - * @return array */ protected function multiplyCoeff(array $acf, array $bcf): array { $alen = count($acf); $blen = count($bcf); $coeff = array_fill(0, ($alen + $blen - 1), 0); - for ($aid = 0; $aid < $alen; $aid++) { - for ($bid = 0; $bid < $blen; $bid++) { + for ($aid = 0; $aid < $alen; ++$aid) { + for ($bid = 0; $bid < $blen; ++$bid) { $coeff[$aid + $bid] ^= ($this->multiply($acf[$aid], $bcf[$bid])); } } + return $this->trimCoefficients($coeff); } @@ -173,14 +171,13 @@ protected function multiplyCoeff(array $acf, array $bcf): array * * @param int $aval First value. * @param int $bval Second value. - * - * @return int */ protected function multiply(int $aval, int $bval): int { if ($aval == 0 || $bval == 0) { return 0; } + return $this->texp[($this->tlog[$aval] + $this->tlog[$bval]) % ($this->tsize - 1)]; } @@ -188,14 +185,13 @@ protected function multiply(int $aval, int $bval): int * Left-trim coefficients array. * * @param array $coeff Array of coefficients. - * - * @return array */ protected function trimCoefficients(array $coeff): array { - while (!empty($coeff) && $coeff[0] == 0) { + while ($coeff !== [] && $coeff[0] == 0) { array_shift($coeff); } + return $coeff; } @@ -205,8 +201,6 @@ protected function trimCoefficients(array $coeff): array * @param array $coeff Array of polynomial coefficients. * @param int $mon Monomial. * @param int $deg Degree of the monomial. - * - * @return array */ protected function multiplyByMonomial(array $coeff, int $mon, int $deg): array { @@ -215,9 +209,10 @@ protected function multiplyByMonomial(array $coeff, int $mon, int $deg): array // } $ncf = count($coeff); $prod = array_fill(0, ($ncf + $deg), 0); - for ($idx = 0; $idx < $ncf; $idx++) { + for ($idx = 0; $idx < $ncf; ++$idx) { $prod[$idx] = $this->multiply($coeff[$idx], $mon); } + return $this->trimCoefficients($prod); } @@ -226,8 +221,6 @@ protected function multiplyByMonomial(array $coeff, int $mon, int $deg): array * * @param array $smaller The smaller array of coefficients. * @param array $larger The larger array of coefficients. - * - * @return array */ protected function addOrSubtract(array $smaller, array $larger): array { @@ -246,9 +239,10 @@ protected function addOrSubtract(array $smaller, array $larger): array // } $lendiff = ($llen - $slen); $coeff = array_slice($larger, 0, $lendiff); - for ($idx = $lendiff; $idx < $llen; $idx++) { + for ($idx = $lendiff; $idx < $llen; ++$idx) { $coeff[$idx] = ($smaller[($idx - $lendiff)] ^ $larger[$idx]); } + return $this->trimCoefficients($coeff); } } diff --git a/src/Type/Square/Aztec/Layers.php b/src/Type/Square/Aztec/Layers.php index adc1d533..1447aa32 100644 --- a/src/Type/Square/Aztec/Layers.php +++ b/src/Type/Square/Aztec/Layers.php @@ -36,32 +36,24 @@ abstract class Layers extends \Com\Tecnick\Barcode\Type\Square\Aztec\Codeword { /** * True for compact mode (up to 4 layers), false for full-range mode (up to 32 layers). - * - * @var bool */ protected bool $compact = true; /** * Number of data layers. - * - * @var int */ protected int $numlayers = 0; /** * Size data for the selected layer. - * - * @var array */ - protected array $layer = array(); + protected array $layer = []; /** * Returns the minimum number of layers required. * * @param array $data Either the Data::SIZE_COMPACT or Data::SIZE_FULL array. * @param int $numbits The number of bits to encode. - * - * @return int */ protected function getMinLayers(array $data, int $numbits): int { @@ -72,6 +64,7 @@ protected function getMinLayers(array $data, int $numbits): int } } } + return 0; } @@ -90,13 +83,16 @@ protected function setLayerByBits(int $numbits, string $mode = 'A'): bool $this->compact = true; $this->numlayers = $this->getMinLayers(Data::SIZE_COMPACT, $numbits); } + if ($this->numlayers == 0) { $this->compact = false; $this->numlayers = $this->getMinLayers(Data::SIZE_FULL, $numbits); } + if ($this->numlayers == 0) { return false; } + $this->layer = $this->compact ? Data::SIZE_COMPACT[$this->numlayers] : Data::SIZE_FULL[$this->numlayers]; return true; } @@ -112,14 +108,16 @@ protected function setLayerByBits(int $numbits, string $mode = 'A'): bool protected function sizeAndBitStuffing(int $ecc, string $mode = 'A'): bool { $nsbits = 0; - $eccbits = (11 + intval(($this->totbits * $ecc) / 100)); + $eccbits = (11 + (int) (($this->totbits * $ecc) / 100)); do { if (!$this->setLayerByBits(($this->totbits + $nsbits + $eccbits), $mode)) { return false; } + $nsbits = $this->bitStuffing(); } while (($nsbits + $eccbits) > $this->layer[3]); - $this->bitstream = array(); + + $this->bitstream = []; $this->totbits = 0; $this->mergeTmpCwdRaw(); return true; @@ -136,27 +134,30 @@ protected function bitStuffing(): int $nsbits = 0; $wsize = $this->layer[2]; $mask = ((1 << $wsize) - 2); // b-1 bits at 1 and last bit at 0 - $this->tmpCdws = array(); + $this->tmpCdws = []; for ($wid = 0; $wid < $this->totbits; $wid += $wsize) { $word = 0; - for ($idx = 0; $idx < $wsize; $idx++) { + for ($idx = 0; $idx < $wsize; ++$idx) { $bid = ($wid + $idx); if (($bid >= $this->totbits) || ($this->bitstream[$bid] == 1)) { $word |= (1 << ($wsize - 1 - $idx)); // the first bit is MSB } } + // If the first b−1 bits of a code word have the same value, // an extra bit with the complementary value is inserted into the data stream. - if (($word & $mask) == $mask) { + if (($word & $mask) === $mask) { $word &= $mask; - $wid--; + --$wid; } elseif (($word & $mask) == 0) { $word |= 1; - $wid--; + --$wid; } - $this->tmpCdws[] = array($wsize, $word); + + $this->tmpCdws[] = [$wsize, $word]; $nsbits += $wsize; } + return $nsbits; } } diff --git a/src/Type/Square/Datamatrix.php b/src/Type/Square/Datamatrix.php index aa2ab873..23fc431a 100644 --- a/src/Type/Square/Datamatrix.php +++ b/src/Type/Square/Datamatrix.php @@ -45,36 +45,26 @@ class Datamatrix extends \Com\Tecnick\Barcode\Type\Square /** * Array of codewords. - * - * @var array */ - protected array $cdw = array(); + protected array $cdw = []; /** * Binary grid - * - * @var array */ - protected array $grid = array(); + protected array $grid = []; /** * Datamatrix Encoding object - * - * @var Encode */ protected Encode $dmx; /** * Datamatrix shape key (S=square, R=rectangular) - * - * @var string */ protected string $shape = 'S'; /** * Datamatrix variant (N=default, GS1=FNC1 codeword in first place) - * - * @var bool */ protected bool $gsonemode = false; @@ -93,9 +83,15 @@ protected function setParameters(): void } // mode - if (isset($this->params[1]) && ($this->params[1] == 'GS1')) { - $this->gsonemode = true; + if (!isset($this->params[1])) { + return; } + + if ($this->params[1] != 'GS1') { + return; + } + + $this->gsonemode = true; } /** @@ -111,15 +107,14 @@ protected function addPadding(int $size, int $ncw): void if ($size <= $ncw) { return; } + if (($this->dmx->last_enc != Data::ENC_ASCII) && ($this->dmx->last_enc != Data::ENC_BASE256)) { // return to ASCII encodation before padding - if ($this->dmx->last_enc == Data::ENC_EDF) { - $this->cdw[] = 124; - } else { - $this->cdw[] = 254; - } + $this->cdw[] = $this->dmx->last_enc == Data::ENC_EDF ? 124 : 254; + ++$ncw; } + if ($size > $ncw) { // add first pad $this->cdw[] = 129; @@ -167,15 +162,6 @@ protected function getCodewords(): array /** * Set the grid - * - * @param int $idx - * @param array $places - * @param int $row - * @param int $col - * @param int $rdx - * @param int $cdx - * @param int $rdri - * @param int $rdci */ protected function setGrid( int &$idx, @@ -191,7 +177,7 @@ protected function setGrid( // braw bits by case if ($rdx == 0) { // top finder pattern - $this->grid[$row][$col] = intval(($cdx % 2) == 0); + $this->grid[$row][$col] = (int) (($cdx % 2) == 0); } elseif ($rdx == $rdri) { // bottom finder pattern $this->grid[$row][$col] = 1; @@ -200,7 +186,7 @@ protected function setGrid( $this->grid[$row][$col] = 1; } elseif ($cdx == $rdci) { // right finder pattern - $this->grid[$row][$col] = intval(($rdx % 2) > 0); + $this->grid[$row][$col] = (int) (($rdx % 2) > 0); } else { // data bit if ($places[$idx] < 2) { @@ -209,9 +195,10 @@ protected function setGrid( // codeword ID $cdw_id = (floor($places[$idx] / 10) - 1); // codeword BIT mask - $cdw_bit = pow(2, (8 - ($places[$idx] % 10))); + $cdw_bit = 2 ** (8 - ($places[$idx] % 10)); $this->grid[$row][$col] = (($this->cdw[$cdw_id] & $cdw_bit) == 0) ? 0 : 1; } + ++$idx; } } @@ -231,7 +218,7 @@ protected function getHighLevelEncoding(string $data): array $enc = Data::ENC_ASCII; // current encoding mode $this->dmx->last_enc = $enc; // last used encoding $pos = 0; // current position - $cdw = array(); // array of codewords to be returned + $cdw = []; // array of codewords to be returned $cdw_num = 0; // number of data codewords $data_length = strlen($data); // number of chars $field_length = 0; // number of chars in current field @@ -243,6 +230,7 @@ protected function getHighLevelEncoding(string $data): array ++$cdw_num; continue; } + switch ($enc) { case Data::ENC_ASCII: // STEP B. While in ASCII encodation @@ -265,8 +253,10 @@ protected function getHighLevelEncoding(string $data): array $this->dmx->encodeBase256($cdw, $cdw_num, $pos, $data_length, $field_length, $data, $enc); break; } + $this->dmx->last_enc = $enc; } + return $cdw; } @@ -284,7 +274,7 @@ protected function setBars(): void // get placement map $places = $this->dmx->getPlacementMap($params[2], $params[3]); // fill the grid with data - $this->grid = array(); + $this->grid = []; $idx = 0; // region data row max index $rdri = ($params[4] - 1); @@ -307,6 +297,7 @@ protected function setBars(): void } } } + $this->processBinarySequence($this->grid); } } diff --git a/src/Type/Square/Datamatrix/Data.php b/src/Type/Square/Datamatrix/Data.php index 8f7f9515..99facf52 100644 --- a/src/Type/Square/Datamatrix/Data.php +++ b/src/Type/Square/Datamatrix/Data.php @@ -94,597 +94,82 @@ class Data *
  • error codewords per block
  • * */ - public const SYMBATTR = array( - 'S' => array( // square form - // 10x10 - array( - 0x00a, - 0x00a, - 0x008, - 0x008, - 0x00a, - 0x00a, - 0x008, - 0x008, - 0x001, - 0x001, - 0x001, - 0x003, - 0x005, - 0x001, - 0x003, - 0x005 - ), - // 12x12 - array( - 0x00c, - 0x00c, - 0x00a, - 0x00a, - 0x00c, - 0x00c, - 0x00a, - 0x00a, - 0x001, - 0x001, - 0x001, - 0x005, - 0x007, - 0x001, - 0x005, - 0x007 - ), - // 14x14 - array( - 0x00e, - 0x00e, - 0x00c, - 0x00c, - 0x00e, - 0x00e, - 0x00c, - 0x00c, - 0x001, - 0x001, - 0x001, - 0x008, - 0x00a, - 0x001, - 0x008, - 0x00a - ), - // 16x16 - array( - 0x010, - 0x010, - 0x00e, - 0x00e, - 0x010, - 0x010, - 0x00e, - 0x00e, - 0x001, - 0x001, - 0x001, - 0x00c, - 0x00c, - 0x001, - 0x00c, - 0x00c - ), - // 18x18 - array( - 0x012, - 0x012, - 0x010, - 0x010, - 0x012, - 0x012, - 0x010, - 0x010, - 0x001, - 0x001, - 0x001, - 0x012, - 0x00e, - 0x001, - 0x012, - 0x00e - ), - // 20x20 - array( - 0x014, - 0x014, - 0x012, - 0x012, - 0x014, - 0x014, - 0x012, - 0x012, - 0x001, - 0x001, - 0x001, - 0x016, - 0x012, - 0x001, - 0x016, - 0x012 - ), - // 22x22 - array( - 0x016, - 0x016, - 0x014, - 0x014, - 0x016, - 0x016, - 0x014, - 0x014, - 0x001, - 0x001, - 0x001, - 0x01e, - 0x014, - 0x001, - 0x01e, - 0x014 - ), - // 24x24 - array( - 0x018, - 0x018, - 0x016, - 0x016, - 0x018, - 0x018, - 0x016, - 0x016, - 0x001, - 0x001, - 0x001, - 0x024, - 0x018, - 0x001, - 0x024, - 0x018 - ), - // 26x26 - array( - 0x01a, - 0x01a, - 0x018, - 0x018, - 0x01a, - 0x01a, - 0x018, - 0x018, - 0x001, - 0x001, - 0x001, - 0x02c, - 0x01c, - 0x001, - 0x02c, - 0x01c - ), - // 32x32 - array( - 0x020, - 0x020, - 0x01c, - 0x01c, - 0x010, - 0x010, - 0x00e, - 0x00e, - 0x002, - 0x002, - 0x004, - 0x03e, - 0x024, - 0x001, - 0x03e, - 0x024 - ), - // 36x36 - array( - 0x024, - 0x024, - 0x020, - 0x020, - 0x012, - 0x012, - 0x010, - 0x010, - 0x002, - 0x002, - 0x004, - 0x056, - 0x02a, - 0x001, - 0x056, - 0x02a - ), - // 40x40 - array( - 0x028, - 0x028, - 0x024, - 0x024, - 0x014, - 0x014, - 0x012, - 0x012, - 0x002, - 0x002, - 0x004, - 0x072, - 0x030, - 0x001, - 0x072, - 0x030 - ), - // 44x44 - array( - 0x02c, - 0x02c, - 0x028, - 0x028, - 0x016, - 0x016, - 0x014, - 0x014, - 0x002, - 0x002, - 0x004, - 0x090, - 0x038, - 0x001, - 0x090, - 0x038 - ), - // 48x48 - array( - 0x030, - 0x030, - 0x02c, - 0x02c, - 0x018, - 0x018, - 0x016, - 0x016, - 0x002, - 0x002, - 0x004, - 0x0ae, - 0x044, - 0x001, - 0x0ae, - 0x044 - ), - // 52x52 - array( - 0x034, - 0x034, - 0x030, - 0x030, - 0x01a, - 0x01a, - 0x018, - 0x018, - 0x002, - 0x002, - 0x004, - 0x0cc, - 0x054, - 0x002, - 0x066, - 0x02a - ), - // 64x64 - array( - 0x040, - 0x040, - 0x038, - 0x038, - 0x010, - 0x010, - 0x00e, - 0x00e, - 0x004, - 0x004, - 0x010, - 0x118, - 0x070, - 0x002, - 0x08c, - 0x038 - ), - // 72x72 - array( - 0x048, - 0x048, - 0x040, - 0x040, - 0x012, - 0x012, - 0x010, - 0x010, - 0x004, - 0x004, - 0x010, - 0x170, - 0x090, - 0x004, - 0x05c, - 0x024 - ), - // 80x80 - array( - 0x050, - 0x050, - 0x048, - 0x048, - 0x014, - 0x014, - 0x012, - 0x012, - 0x004, - 0x004, - 0x010, - 0x1c8, - 0x0c0, - 0x004, - 0x072, - 0x030 - ), - // 88x88 - array( - 0x058, - 0x058, - 0x050, - 0x050, - 0x016, - 0x016, - 0x014, - 0x014, - 0x004, - 0x004, - 0x010, - 0x240, - 0x0e0, - 0x004, - 0x090, - 0x038 - ), - // 96x96 - array( - 0x060, - 0x060, - 0x058, - 0x058, - 0x018, - 0x018, - 0x016, - 0x016, - 0x004, - 0x004, - 0x010, - 0x2b8, - 0x110, - 0x004, - 0x0ae, - 0x044 - ), - // 104x104 - array( - 0x068, - 0x068, - 0x060, - 0x060, - 0x01a, - 0x01a, - 0x018, - 0x018, - 0x004, - 0x004, - 0x010, - 0x330, - 0x150, - 0x006, - 0x088, - 0x038 - ), - // 120x120 - array( - 0x078, - 0x078, - 0x06c, - 0x06c, - 0x014, - 0x014, - 0x012, - 0x012, - 0x006, - 0x006, - 0x024, - 0x41a, - 0x198, - 0x006, - 0x0af, - 0x044 - ), - // 132x132 - array( - 0x084, - 0x084, - 0x078, - 0x078, - 0x016, - 0x016, - 0x014, - 0x014, - 0x006, - 0x006, - 0x024, - 0x518, - 0x1f0, - 0x008, - 0x0a3, - 0x03e - ), - // 144x144 - array( - 0x090, - 0x090, - 0x084, - 0x084, - 0x018, - 0x018, - 0x016, - 0x016, - 0x006, - 0x006, - 0x024, - 0x618, - 0x26c, - 0x00a, - 0x09c, - 0x03e - ) - ), - 'R' => array( // rectangular form - // 8x18 - array( - 0x008, - 0x012, - 0x006, - 0x010, - 0x008, - 0x012, - 0x006, - 0x010, - 0x001, - 0x001, - 0x001, - 0x005, - 0x007, - 0x001, - 0x005, - 0x007 - ), - // 8x32 - array( - 0x008, - 0x020, - 0x006, - 0x01c, - 0x008, - 0x010, - 0x006, - 0x00e, - 0x001, - 0x002, - 0x002, - 0x00a, - 0x00b, - 0x001, - 0x00a, - 0x00b - ), - // 12x26 - array( - 0x00c, - 0x01a, - 0x00a, - 0x018, - 0x00c, - 0x01a, - 0x00a, - 0x018, - 0x001, - 0x001, - 0x001, - 0x010, - 0x00e, - 0x001, - 0x010, - 0x00e - ), - // 12x36 - array( - 0x00c, - 0x024, - 0x00a, - 0x020, - 0x00c, - 0x012, - 0x00a, - 0x010, - 0x001, - 0x002, - 0x002, - 0x00c, - 0x012, - 0x001, - 0x00c, - 0x012 - ), - // 16x36 - array( - 0x010, - 0x024, - 0x00e, - 0x020, - 0x010, - 0x012, - 0x00e, - 0x010, - 0x001, - 0x002, - 0x002, - 0x020, - 0x018, - 0x001, - 0x020, - 0x018 - ), - // 16x48 - array( - 0x010, - 0x030, - 0x00e, - 0x02c, - 0x010, - 0x018, - 0x00e, - 0x016, - 0x001, - 0x002, - 0x002, - 0x031, - 0x01c, - 0x001, - 0x031, - 0x01c - ) - ) - ); + public const SYMBATTR = ['S' => [ + // square form + // 10x10 + [0x00a, 0x00a, 0x008, 0x008, 0x00a, 0x00a, 0x008, 0x008, 0x001, 0x001, 0x001, 0x003, 0x005, 0x001, 0x003, 0x005], + // 12x12 + [0x00c, 0x00c, 0x00a, 0x00a, 0x00c, 0x00c, 0x00a, 0x00a, 0x001, 0x001, 0x001, 0x005, 0x007, 0x001, 0x005, 0x007], + // 14x14 + [0x00e, 0x00e, 0x00c, 0x00c, 0x00e, 0x00e, 0x00c, 0x00c, 0x001, 0x001, 0x001, 0x008, 0x00a, 0x001, 0x008, 0x00a], + // 16x16 + [0x010, 0x010, 0x00e, 0x00e, 0x010, 0x010, 0x00e, 0x00e, 0x001, 0x001, 0x001, 0x00c, 0x00c, 0x001, 0x00c, 0x00c], + // 18x18 + [0x012, 0x012, 0x010, 0x010, 0x012, 0x012, 0x010, 0x010, 0x001, 0x001, 0x001, 0x012, 0x00e, 0x001, 0x012, 0x00e], + // 20x20 + [0x014, 0x014, 0x012, 0x012, 0x014, 0x014, 0x012, 0x012, 0x001, 0x001, 0x001, 0x016, 0x012, 0x001, 0x016, 0x012], + // 22x22 + [0x016, 0x016, 0x014, 0x014, 0x016, 0x016, 0x014, 0x014, 0x001, 0x001, 0x001, 0x01e, 0x014, 0x001, 0x01e, 0x014], + // 24x24 + [0x018, 0x018, 0x016, 0x016, 0x018, 0x018, 0x016, 0x016, 0x001, 0x001, 0x001, 0x024, 0x018, 0x001, 0x024, 0x018], + // 26x26 + [0x01a, 0x01a, 0x018, 0x018, 0x01a, 0x01a, 0x018, 0x018, 0x001, 0x001, 0x001, 0x02c, 0x01c, 0x001, 0x02c, 0x01c], + // 32x32 + [0x020, 0x020, 0x01c, 0x01c, 0x010, 0x010, 0x00e, 0x00e, 0x002, 0x002, 0x004, 0x03e, 0x024, 0x001, 0x03e, 0x024], + // 36x36 + [0x024, 0x024, 0x020, 0x020, 0x012, 0x012, 0x010, 0x010, 0x002, 0x002, 0x004, 0x056, 0x02a, 0x001, 0x056, 0x02a], + // 40x40 + [0x028, 0x028, 0x024, 0x024, 0x014, 0x014, 0x012, 0x012, 0x002, 0x002, 0x004, 0x072, 0x030, 0x001, 0x072, 0x030], + // 44x44 + [0x02c, 0x02c, 0x028, 0x028, 0x016, 0x016, 0x014, 0x014, 0x002, 0x002, 0x004, 0x090, 0x038, 0x001, 0x090, 0x038], + // 48x48 + [0x030, 0x030, 0x02c, 0x02c, 0x018, 0x018, 0x016, 0x016, 0x002, 0x002, 0x004, 0x0ae, 0x044, 0x001, 0x0ae, 0x044], + // 52x52 + [0x034, 0x034, 0x030, 0x030, 0x01a, 0x01a, 0x018, 0x018, 0x002, 0x002, 0x004, 0x0cc, 0x054, 0x002, 0x066, 0x02a], + // 64x64 + [0x040, 0x040, 0x038, 0x038, 0x010, 0x010, 0x00e, 0x00e, 0x004, 0x004, 0x010, 0x118, 0x070, 0x002, 0x08c, 0x038], + // 72x72 + [0x048, 0x048, 0x040, 0x040, 0x012, 0x012, 0x010, 0x010, 0x004, 0x004, 0x010, 0x170, 0x090, 0x004, 0x05c, 0x024], + // 80x80 + [0x050, 0x050, 0x048, 0x048, 0x014, 0x014, 0x012, 0x012, 0x004, 0x004, 0x010, 0x1c8, 0x0c0, 0x004, 0x072, 0x030], + // 88x88 + [0x058, 0x058, 0x050, 0x050, 0x016, 0x016, 0x014, 0x014, 0x004, 0x004, 0x010, 0x240, 0x0e0, 0x004, 0x090, 0x038], + // 96x96 + [0x060, 0x060, 0x058, 0x058, 0x018, 0x018, 0x016, 0x016, 0x004, 0x004, 0x010, 0x2b8, 0x110, 0x004, 0x0ae, 0x044], + // 104x104 + [0x068, 0x068, 0x060, 0x060, 0x01a, 0x01a, 0x018, 0x018, 0x004, 0x004, 0x010, 0x330, 0x150, 0x006, 0x088, 0x038], + // 120x120 + [0x078, 0x078, 0x06c, 0x06c, 0x014, 0x014, 0x012, 0x012, 0x006, 0x006, 0x024, 0x41a, 0x198, 0x006, 0x0af, 0x044], + // 132x132 + [0x084, 0x084, 0x078, 0x078, 0x016, 0x016, 0x014, 0x014, 0x006, 0x006, 0x024, 0x518, 0x1f0, 0x008, 0x0a3, 0x03e], + // 144x144 + [0x090, 0x090, 0x084, 0x084, 0x018, 0x018, 0x016, 0x016, 0x006, 0x006, 0x024, 0x618, 0x26c, 0x00a, 0x09c, 0x03e], + ], 'R' => [ + // rectangular form + // 8x18 + [0x008, 0x012, 0x006, 0x010, 0x008, 0x012, 0x006, 0x010, 0x001, 0x001, 0x001, 0x005, 0x007, 0x001, 0x005, 0x007], + // 8x32 + [0x008, 0x020, 0x006, 0x01c, 0x008, 0x010, 0x006, 0x00e, 0x001, 0x002, 0x002, 0x00a, 0x00b, 0x001, 0x00a, 0x00b], + // 12x26 + [0x00c, 0x01a, 0x00a, 0x018, 0x00c, 0x01a, 0x00a, 0x018, 0x001, 0x001, 0x001, 0x010, 0x00e, 0x001, 0x010, 0x00e], + // 12x36 + [0x00c, 0x024, 0x00a, 0x020, 0x00c, 0x012, 0x00a, 0x010, 0x001, 0x002, 0x002, 0x00c, 0x012, 0x001, 0x00c, 0x012], + // 16x36 + [0x010, 0x024, 0x00e, 0x020, 0x010, 0x012, 0x00e, 0x010, 0x001, 0x002, 0x002, 0x020, 0x018, 0x001, 0x020, 0x018], + // 16x48 + [0x010, 0x030, 0x00e, 0x02c, 0x010, 0x018, 0x00e, 0x016, 0x001, 0x002, 0x002, 0x031, 0x01c, 0x001, 0x031, 0x01c], + ]]; /** * Map encodation modes whit character sets. */ - public const CHSET_ID = array( - self::ENC_C40 => 'C40', - self::ENC_TXT => 'TXT', - self::ENC_X12 => 'X12' - ); + public const CHSET_ID = [self::ENC_C40 => 'C40', self::ENC_TXT => 'TXT', self::ENC_X12 => 'X12']; /** * Basic set of characters for each encodation mode. */ - public const CHSET = array( - 'C40' => array( // Basic set for C40 + public const CHSET = ['C40' => [ + // Basic set for C40 'S1' => 0x00, 'S2' => 0x01, 'S3' => 0x02, @@ -724,9 +209,9 @@ class Data 0x57 => 0x24, 0x58 => 0x25, 0x59 => 0x26, - 0x5a => 0x27 - ), - 'TXT' => array( // Basic set for TEXT + 0x5a => 0x27, + ], 'TXT' => [ + // Basic set for TEXT 'S1' => 0x00, 'S2' => 0x01, 'S3' => 0x02, @@ -766,9 +251,9 @@ class Data 0x77 => 0x24, 0x78 => 0x25, 0x79 => 0x26, - 0x7a => 0x27 - ), - 'SH1' => array( // Shift 1 set + 0x7a => 0x27, + ], 'SH1' => [ + // Shift 1 set 0x00 => 0x00, 0x01 => 0x01, 0x02 => 0x02, @@ -800,9 +285,9 @@ class Data 0x1c => 0x1c, 0x1d => 0x1d, 0x1e => 0x1e, - 0x1f => 0x1f - ), - 'SH2' => array( // Shift 2 set + 0x1f => 0x1f, + ], 'SH2' => [ + // Shift 2 set 0x21 => 0x00, 0x22 => 0x01, 0x23 => 0x02, @@ -831,9 +316,9 @@ class Data 0x5e => 0x19, 0x5f => 0x1a, 'F1' => 0x1b, - 'US' => 0x1e - ), - 'S3C' => array( // Shift 3 set for C40 + 'US' => 0x1e, + ], 'S3C' => [ + // Shift 3 set for C40 0x60 => 0x00, 0x61 => 0x01, 0x62 => 0x02, @@ -865,9 +350,9 @@ class Data 0x7c => 0x1c, 0x7d => 0x1d, 0x7e => 0x1e, - 0x7f => 0x1f - ), - 'S3T' => array( // Shift 3 set for TEXT + 0x7f => 0x1f, + ], 'S3T' => [ + // Shift 3 set for TEXT 0x60 => 0x00, 0x41 => 0x01, 0x42 => 0x02, @@ -899,9 +384,9 @@ class Data 0x7c => 0x1c, 0x7d => 0x1d, 0x7e => 0x1e, - 0x7f => 0x1f - ), - 'X12' => array( // Set for X12 + 0x7f => 0x1f, + ], 'X12' => [ + // Set for X12 0x0d => 0x00, 0x2a => 0x01, 0x3e => 0x02, @@ -941,9 +426,8 @@ class Data 0x57 => 0x24, 0x58 => 0x25, 0x59 => 0x26, - 0x5a => 0x27 - ) - ); + 0x5a => 0x27, + ]]; /** * Get the required codewords padding size @@ -959,6 +443,7 @@ public static function getPaddingSize($shape, $ncw) return $params; } } + throw new BarcodeException('Unable to find the correct size'); } } diff --git a/src/Type/Square/Datamatrix/Encode.php b/src/Type/Square/Datamatrix/Encode.php index e0dd9dc8..077b698a 100644 --- a/src/Type/Square/Datamatrix/Encode.php +++ b/src/Type/Square/Datamatrix/Encode.php @@ -40,20 +40,13 @@ class Encode extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\EncodeTxt * * @param string $shape Datamatrix shape key (S=square, R=rectangular) */ - public function __construct($shape = 'S') + public function __construct(string $shape = 'S') { $this->shape = $shape; } /** * Encode ASCII - * - * @param array $cdw - * @param int $cdw_num - * @param int $pos - * @param int $data_length - * @param string $data - * @param int $enc */ public function encodeASCII( array &$cdw, @@ -73,13 +66,13 @@ public function encodeASCII( ) { // 1. If the next data sequence is at least 2 consecutive digits, // encode the next two digits as a double digit in ASCII mode. - $cdw[] = (intval(substr($data, $pos, 2)) + 130); + $cdw[] = ((int) substr($data, $pos, 2) + 130); ++$cdw_num; $pos += 2; } else { // 2. If the look-ahead test (starting at step J) indicates another mode, switch to that mode. $newenc = $this->lookAheadTest($data, $pos, $enc); - if ($newenc != $enc) { + if ($newenc !== $enc) { // switch to new encoding $enc = $newenc; $cdw[] = $this->getSwitchEncodingCodeword($enc); @@ -106,14 +99,6 @@ public function encodeASCII( /** * Encode EDF4 * - * @param int $epos - * @param array $cdw - * @param int $cdw_num - * @param int $pos - * @param int $data_length - * @param int $field_length - * @param int $enc - * @param array $temp_cw * * @return bool true to break the loop */ @@ -128,15 +113,17 @@ public function encodeEDFfour( array &$temp_cw ): bool { - if (($epos == $data_length)) { + if (($epos === $data_length)) { $enc = Data::ENC_ASCII; $params = Data::getPaddingSize($this->shape, ($cdw_num + $field_length)); if (($params[11] - $cdw_num) > 2) { $cdw[] = $this->getSwitchEncodingCodeword($enc); ++$cdw_num; } + return true; } + if ($field_length < 4) { $enc = Data::ENC_ASCII; $this->last_enc = $enc; @@ -153,36 +140,32 @@ public function encodeEDFfour( return true; } } + // encodes four data characters in three codewords $cdw[] = (($temp_cw[0] & 0x3F) << 2) + (($temp_cw[1] & 0x30) >> 4); - $cdw_num++; + ++$cdw_num; if ($field_length > 1) { $cdw[] = (($temp_cw[1] & 0x0F) << 4) + (($temp_cw[2] & 0x3C) >> 2); - $cdw_num++; + ++$cdw_num; } + if ($field_length > 2) { $cdw[] = (($temp_cw[2] & 0x03) << 6) + ($temp_cw[3] & 0x3F); - $cdw_num++; + ++$cdw_num; } - $temp_cw = array(); + + $temp_cw = []; $pos = $epos; $field_length = 0; if ($enc == Data::ENC_ASCII) { return true; // exit from EDIFACT mode } + return false; } /** * Encode EDF - * - * @param array $cdw - * @param int $cdw_num - * @param int $pos - * @param int $data_length - * @param int $field_length - * @param string $data - * @param int $enc */ public function encodeEDF( array &$cdw, @@ -195,7 +178,7 @@ public function encodeEDF( ): void { // initialize temporary array with 0 length - $temp_cw = array(); + $temp_cw = []; $epos = $pos; $field_length = 0; do { @@ -206,28 +189,18 @@ public function encodeEDF( $temp_cw[] = $chr; ++$field_length; } + if ( - ($field_length == 4) - || ($epos == $data_length) - || !$this->isCharMode($chr, Data::ENC_EDF) + (($field_length == 4) + || ($epos == $data_length) || !$this->isCharMode($chr, Data::ENC_EDF)) && $this->encodeEDFfour($epos, $cdw, $cdw_num, $pos, $data_length, $field_length, $enc, $temp_cw) ) { - if ($this->encodeEDFfour($epos, $cdw, $cdw_num, $pos, $data_length, $field_length, $enc, $temp_cw)) { - break; - } + break; } } while ($epos < $data_length); } /** * Encode Base256 - * - * @param array $cdw - * @param int $cdw_num - * @param int $pos - * @param int $data_length - * @param int $field_length - * @param string $data - * @param int $enc */ public function encodeBase256( array &$cdw, @@ -240,11 +213,11 @@ public function encodeBase256( ): void { // initialize temporary array with 0 length - $temp_cw = array(); + $temp_cw = []; $field_length = 0; while (($pos < $data_length) && ($field_length <= 1555)) { $newenc = $this->lookAheadTest($data, $pos, $enc); - if ($newenc != $enc) { + if ($newenc !== $enc) { // 1. If the look-ahead test (starting at step J) // indicates another mode, switch to that mode. $enc = $newenc; @@ -257,6 +230,7 @@ public function encodeBase256( ++$field_length; } } + // set field length if ($field_length <= 249) { $cdw[] = $this->get255StateCodeword($field_length, ($cdw_num + 1)); @@ -266,12 +240,11 @@ public function encodeBase256( $cdw[] = $this->get255StateCodeword(($field_length % 250), ($cdw_num + 2)); $cdw_num += 2; } - if (!empty($temp_cw)) { - // add B256 field - foreach ($temp_cw as $cht) { - $cdw[] = $this->get255StateCodeword($cht, ($cdw_num + 1)); - ++$cdw_num; - } + + // add B256 field + foreach ($temp_cw as $cht) { + $cdw[] = $this->get255StateCodeword($cht, ($cdw_num + 1)); + ++$cdw_num; } } } diff --git a/src/Type/Square/Datamatrix/EncodeTxt.php b/src/Type/Square/Datamatrix/EncodeTxt.php index 46438e06..46e764a9 100644 --- a/src/Type/Square/Datamatrix/EncodeTxt.php +++ b/src/Type/Square/Datamatrix/EncodeTxt.php @@ -37,11 +37,6 @@ class EncodeTxt extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Steps { /** * Encode TXTC40 shift - * - * @param int $chr - * @param int $enc - * @param array $temp_cw - * @param int $ptr */ public function encodeTXTC40shift( int &$chr, @@ -65,6 +60,7 @@ public function encodeTXTC40shift( } else { throw new BarcodeException('Error'); } + $temp_cw[] = $shiftset[$chr]; $ptr += 2; } @@ -72,12 +68,6 @@ public function encodeTXTC40shift( /** * Encode TXTC40 * - * @param string $data - * @param int $enc - * @param array $temp_cw - * @param int $ptr - * @param int $epos - * @param array $charset * * @return int Curent character code */ @@ -94,21 +84,24 @@ public function encodeTXTC40( $chr = ord($data[$epos]); ++$epos; // check for extended character - if ($chr & 0x80) { + if (($chr & 0x80) !== 0) { if ($enc == Data::ENC_X12) { throw new BarcodeException('TXTC40 Error'); } - $chr = ($chr & 0x7f); + + $chr &= 0x7f; $temp_cw[] = 1; // shift 2 $temp_cw[] = 30; // upper shift $ptr += 2; } + if (isset($charset[$chr])) { $temp_cw[] = $charset[$chr]; ++$ptr; } else { $this->encodeTXTC40shift($chr, $enc, $temp_cw, $ptr); } + return $chr; } @@ -116,14 +109,6 @@ public function encodeTXTC40( * Encode TXTC40 last * The following rules apply when only one or two symbol characters remain in the symbol * before the start of the error correction codewords. - * - * @param int $chr - * @param array $cdw - * @param int $cdw_num - * @param int $enc - * @param array $temp_cw - * @param int $ptr - * @param int $epos */ public function encodeTXTC40last( int $chr, @@ -163,27 +148,18 @@ public function encodeTXTC40last( $cdw_num += 2; $enc = Data::ENC_ASCII; $this->last_enc = $enc; - } else { + } elseif ($enc != Data::ENC_ASCII) { // switch to ASCII encoding - if ($enc != Data::ENC_ASCII) { - $enc = Data::ENC_ASCII; - $this->last_enc = $enc; - $cdw[] = $this->getSwitchEncodingCodeword($enc); - ++$cdw_num; - $epos -= $ptr; - } + $enc = Data::ENC_ASCII; + $this->last_enc = $enc; + $cdw[] = $this->getSwitchEncodingCodeword($enc); + ++$cdw_num; + $epos -= $ptr; } } /** * Encode TXT - * - * @param array $cdw - * @param int $cdw_num - * @param int $pos - * @param int $data_length - * @param string $data - * @param int $enc */ public function encodeTXT( array &$cdw, @@ -194,7 +170,7 @@ public function encodeTXT( int &$enc ): void { - $temp_cw = array(); + $temp_cw = []; $ptr = 0; $epos = $pos; // get charset ID @@ -224,6 +200,7 @@ public function encodeTXT( $cdw[] = $this->getSwitchEncodingCodeword(Data::ENC_ASCII); ++$cdw_num; } + $cdw[] = $this->getSwitchEncodingCodeword($enc); ++$cdw_num; $pos -= $ptr; @@ -232,6 +209,7 @@ public function encodeTXT( } } } while (($ptr > 0) && ($epos < $data_length)); + // process last data (if any) if ($ptr > 0) { $this->encodeTXTC40last($chr, $cdw, $cdw_num, $enc, $temp_cw, $ptr, $epos); diff --git a/src/Type/Square/Datamatrix/ErrorCorrection.php b/src/Type/Square/Datamatrix/ErrorCorrection.php index 13cec5a7..4ccada8c 100644 --- a/src/Type/Square/Datamatrix/ErrorCorrection.php +++ b/src/Type/Square/Datamatrix/ErrorCorrection.php @@ -53,6 +53,7 @@ protected function getGFProduct( if (($numa == 0) || ($numb == 0)) { return 0; } + return ($alog[($log[$numa] + $log[$numb]) % ($ngf - 1)]); } @@ -78,8 +79,8 @@ public function getErrorCorrection( ): array { // generate the log ($log) and antilog ($alog) tables - $log = array(0); - $alog = array(1); + $log = [0]; + $alog = [1]; $this->genLogs($log, $alog, $ngf, $vpp); // generate the polynomial coefficients (c) @@ -90,8 +91,10 @@ public function getErrorCorrection( for ($j = ($i - 1); $j >= 1; --$j) { $plc[$j] = $plc[($j - 1)] ^ $this->getGFProduct($plc[$j], $alog[$i], $log, $alog, $ngf); } + $plc[0] = $this->getGFProduct($plc[0], $alog[$i], $log, $alog, $ngf); } + ksort($plc); // total number of data codewords @@ -101,10 +104,11 @@ public function getErrorCorrection( // for each block for ($b = 0; $b < $nbk; ++$b) { // create interleaved data block - $block = array(); + $block = []; for ($n = $b; $n < $num_wd; $n += $nbk) { $block[] = $wdc[$n]; } + // initialize error codewords $wec = array_fill(0, ($ncc + 1), 0); // calculate error correction codewords for this block @@ -114,6 +118,7 @@ public function getErrorCorrection( $wec[$j] = ($wec[($j + 1)] ^ $this->getGFProduct($ker, $plc[($ncc - $j - 1)], $log, $alog, $ngf)); } } + // add error codewords at the end of data codewords $j = 0; for ($i = $b; $i < $num_we; $i += $nbk) { @@ -121,6 +126,7 @@ public function getErrorCorrection( ++$j; } } + // reorder codewords ksort($wdc); return $wdc; @@ -146,8 +152,10 @@ protected function genLogs( if ($alog[$i] >= $ngf) { $alog[$i] ^= $vpp; } + $log[$alog[$i]] = $i; } + ksort($log); } } diff --git a/src/Type/Square/Datamatrix/Modes.php b/src/Type/Square/Datamatrix/Modes.php index 9baf71e8..17d998cd 100644 --- a/src/Type/Square/Datamatrix/Modes.php +++ b/src/Type/Square/Datamatrix/Modes.php @@ -35,15 +35,11 @@ abstract class Modes extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Placeme { /** * Store last used encoding for data codewords. - * - * @var int */ public int $last_enc; /** * Datamatrix shape key (S=square, R=rectangular) - * - * @var string */ public string $shape; @@ -52,8 +48,6 @@ abstract class Modes extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Placeme * * @param int $cdwpad Pad codeword. * @param int $cdwpos Number of data codewords from the beginning of encoded data. - * - * @return int */ public function get253StateCodeword(int $cdwpad, int $cdwpos): int { @@ -61,6 +55,7 @@ public function get253StateCodeword(int $cdwpad, int $cdwpos): int if ($pad > 254) { $pad -= 254; } + return $pad; } @@ -72,12 +67,13 @@ public function get253StateCodeword(int $cdwpad, int $cdwpos): int * * @return int pad codeword */ - protected function get255StateCodeword(int $cdwpad, int $cdwpos): int + protected function get255StateCodeword(int $cdwpad, int $cdwpos): int { $pad = ($cdwpad + (((149 * $cdwpos) % 255) + 1)); if ($pad > 255) { $pad -= 256; } + return $pad; } @@ -91,7 +87,7 @@ protected function get255StateCodeword(int $cdwpad, int $cdwpos): int */ protected function isCharMode(int $chr, int $mode): bool { - $map = array( + $map = [ //Data::ENC_ASCII => 'isASCIIMode', Data::ENC_C40 => 'isC40Mode', Data::ENC_TXT => 'isTXTMode', @@ -99,8 +95,8 @@ protected function isCharMode(int $chr, int $mode): bool Data::ENC_EDF => 'isEDFMode', Data::ENC_BASE256 => 'isBASE256Mode', Data::ENC_ASCII_EXT => 'isASCIIEXTMode', - Data::ENC_ASCII_NUM => 'isASCIINUMMode' - ); + Data::ENC_ASCII_NUM => 'isASCIINUMMode', + ]; $method = $map[$mode]; return $this->$method($chr); } @@ -116,13 +112,10 @@ protected function isCharMode(int $chr, int $mode): bool //{ // return (($chr >= 0) && ($chr <= 127)); //} - /** * Tell if char is Upper-case alphanumeric * * @param int $chr Character (byte) to check. - * - * @return bool */ protected function isC40Mode(int $chr): bool { @@ -133,8 +126,6 @@ protected function isC40Mode(int $chr): bool * Tell if char is Lower-case alphanumeric * * @param int $chr Character (byte) to check. - * - * @return bool */ protected function isTXTMode(int $chr): bool { @@ -145,8 +136,6 @@ protected function isTXTMode(int $chr): bool * Tell if char is ANSI X12 * * @param int $chr Character (byte) to check. - * - * @return bool */ protected function isX12Mode(int $chr): bool { @@ -157,8 +146,6 @@ protected function isX12Mode(int $chr): bool * Tell if char is ASCII character 32 to 94 * * @param int $chr Character (byte) to check. - * - * @return bool */ protected function isEDFMode(int $chr): bool { @@ -169,8 +156,6 @@ protected function isEDFMode(int $chr): bool * Tell if char is Function character (FNC1, Structured Append, Reader Program, or Code Page) * * @param int $chr Character (byte) to check. - * - * @return bool */ protected function isBASE256Mode(int $chr): bool { @@ -181,8 +166,6 @@ protected function isBASE256Mode(int $chr): bool * Tell if char is ASCII character 128 to 255 * * @param int $chr Character (byte) to check. - * - * @return bool */ protected function isASCIIEXTMode(int $chr): bool { @@ -193,8 +176,6 @@ protected function isASCIIEXTMode(int $chr): bool * Tell if char is ASCII digits * * @param int $chr Character (byte) to check. - * - * @return bool */ protected function isASCIINUMMode(int $chr): bool { @@ -217,6 +198,7 @@ protected function getMaxDataCodewords(int $numcw): int break; } } + return $mdc; } @@ -228,18 +210,16 @@ protected function getMaxDataCodewords(int $numcw): int */ protected function getSwitchEncodingCodeword(int $mode): int { - $map = array( - Data::ENC_ASCII => 254, - Data::ENC_C40 => 230, - Data::ENC_TXT => 239, - Data::ENC_X12 => 238, - Data::ENC_EDF => 240, - Data::ENC_BASE256 => 231 - ); + $map = [Data::ENC_ASCII => 254, Data::ENC_C40 => 230, Data::ENC_TXT => 239, Data::ENC_X12 => 238, Data::ENC_EDF => 240, Data::ENC_BASE256 => 231]; $cdw = $map[$mode]; - if (($cdw == 254) && ($this->last_enc == Data::ENC_EDF)) { - $cdw = 124; + if ($cdw != 254) { + return $cdw; + } + + if ($this->last_enc != Data::ENC_EDF) { + return $cdw; } - return $cdw; + + return 124; } } diff --git a/src/Type/Square/Datamatrix/Placement.php b/src/Type/Square/Datamatrix/Placement.php index 330c6d5b..09a8a26e 100644 --- a/src/Type/Square/Datamatrix/Placement.php +++ b/src/Type/Square/Datamatrix/Placement.php @@ -44,8 +44,6 @@ abstract class Placement * @param int $col Column number. * @param int $chr Char byte. * @param int $bit Bit. - * - * @return array */ protected function placeModule( array $marr, @@ -61,10 +59,12 @@ protected function placeModule( $row += $nrow; $col += (4 - (($nrow + 4) % 8)); } + if ($col < 0) { $col += $ncol; $row += (4 - (($ncol + 4) % 8)); } + $marr[(($row * $ncol) + $col)] = ((10 * $chr) + $bit); return $marr; } @@ -79,8 +79,6 @@ protected function placeModule( * @param int $row Row number. * @param int $col Column number. * @param int $chr Char byte. - * - * @return array */ protected function placeUtah( array $marr, @@ -98,8 +96,7 @@ protected function placeUtah( $marr = $this->placeModule($marr, $nrow, $ncol, $row - 1, $col, $chr, 5); $marr = $this->placeModule($marr, $nrow, $ncol, $row, $col - 2, $chr, 6); $marr = $this->placeModule($marr, $nrow, $ncol, $row, $col - 1, $chr, 7); - $marr = $this->placeModule($marr, $nrow, $ncol, $row, $col, $chr, 8); - return $marr; + return $this->placeModule($marr, $nrow, $ncol, $row, $col, $chr, 8); } /** @@ -112,8 +109,6 @@ protected function placeUtah( * @param int $chr Char byte * @param int $row Current row * @param int $col Current column - * - * @return array */ protected function placeCornerA( array $marr, @@ -124,9 +119,10 @@ protected function placeCornerA( int $col ): array { - if (($row != $nrow) || ($col != 0)) { + if (($row !== $nrow) || ($col != 0)) { return $marr; } + $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 1, 0, $chr, 1); $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 1, 1, $chr, 2); $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 1, 2, $chr, 3); @@ -149,8 +145,6 @@ protected function placeCornerA( * @param int $chr Char byte * @param int $row Current row * @param int $col Current column - * - * @return array */ protected function placeCornerB( array $marr, @@ -161,9 +155,10 @@ protected function placeCornerB( int $col ): array { - if (($row != ($nrow - 2)) || ($col != 0) || (($ncol % 4) == 0)) { + if (($row !== $nrow - 2) || ($col != 0) || (($ncol % 4) == 0)) { return $marr; } + $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 3, 0, $chr, 1); $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 2, 0, $chr, 2); $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 1, 0, $chr, 3); @@ -186,8 +181,6 @@ protected function placeCornerB( * @param int $chr Char byte * @param int $row Current row * @param int $col Current column - * - * @return array */ protected function placeCornerC( array $marr, @@ -198,9 +191,10 @@ protected function placeCornerC( int $col ): array { - if (($row != ($nrow - 2)) || ($col != 0) || (($ncol % 8) != 4)) { + if (($row !== $nrow - 2) || ($col != 0) || ($ncol % 8 != 4)) { return $marr; } + $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 3, 0, $chr, 1); $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 2, 0, $chr, 2); $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 1, 0, $chr, 3); @@ -223,8 +217,6 @@ protected function placeCornerC( * @param int $chr Char byte * @param int $row Current row * @param int $col Current column - * - * @return array */ protected function placeCornerD( array $marr, @@ -235,9 +227,10 @@ protected function placeCornerD( int $col ): array { - if (($row != ($nrow + 4)) || ($col != 2) || ($ncol % 8)) { + if (($row !== $nrow + 4) || ($col != 2) || ($ncol % 8)) { return $marr; } + $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 1, 0, $chr, 1); $marr = $this->placeModule($marr, $nrow, $ncol, $nrow - 1, $ncol - 1, $chr, 2); $marr = $this->placeModule($marr, $nrow, $ncol, 0, $ncol - 3, $chr, 3); @@ -262,8 +255,6 @@ protected function placeCornerD( * @param int $chr Char byte * @param int $row Current row * @param int $col Current column - * - * @return array */ protected function placeSweepUpward( array $marr, @@ -279,9 +270,11 @@ protected function placeSweepUpward( $marr = $this->placeUtah($marr, $nrow, $ncol, $row, $col, $chr); ++$chr; } + $row -= 2; $col += 2; } while (($row >= 0) && ($col < $ncol)); + ++$row; $col += 3; return $marr; @@ -297,8 +290,6 @@ protected function placeSweepUpward( * @param int $chr Char byte * @param int $row Current row * @param int $col Current column - * - * @return array */ protected function placeSweepDownward( array $marr, @@ -314,9 +305,11 @@ protected function placeSweepDownward( $marr = $this->placeUtah($marr, $nrow, $ncol, $row, $col, $chr); ++$chr; } + $row += 2; $col -= 2; } while (($row < $nrow) && ($col >= 0)); + $row += 3; ++$col; return $marr; @@ -328,8 +321,6 @@ protected function placeSweepDownward( * * @param int $nrow Number of rows. * @param int $ncol Number of columns. - * - * @return array */ public function getPlacementMap( int $nrow, @@ -354,11 +345,13 @@ public function getPlacementMap( $marr = $this->placeSweepDownward($marr, $nrow, $ncol, $chr, $row, $col); // ... until the entire array is scanned } while (($row < $nrow) || ($col < $ncol)); + // lastly, if the lower righthand corner is untouched, fill in fixed pattern if (!$marr[(($nrow * $ncol) - 1)]) { $marr[(($nrow * $ncol) - 1)] = 1; $marr[(($nrow * $ncol) - $ncol - 2)] = 1; } + return $marr; } } diff --git a/src/Type/Square/Datamatrix/Steps.php b/src/Type/Square/Datamatrix/Steps.php index 8c666881..72a6abb5 100644 --- a/src/Type/Square/Datamatrix/Steps.php +++ b/src/Type/Square/Datamatrix/Steps.php @@ -49,20 +49,23 @@ public function lookAheadTest(string $data, int $pos, int $mode): int if ($pos >= $data_length) { return $mode; } + $charscount = 0; // count processed chars // STEP J if ($mode == Data::ENC_ASCII) { - $numch = array(0, 1, 1, 1, 1, 1.25); + $numch = [0, 1, 1, 1, 1, 1.25]; } else { - $numch = array(1, 2, 2, 2, 2, 2.25); + $numch = [1, 2, 2, 2, 2, 2.25]; $numch[$mode] = 0; } + while (true) { if (($pos + $charscount) == $data_length) { return $this->stepK($numch); } + $chr = ord($data[$pos + $charscount]); - $charscount++; + ++$charscount; $this->stepL($chr, $numch); $this->stepM($chr, $numch); $this->stepN($chr, $numch); @@ -81,9 +84,7 @@ public function lookAheadTest(string $data, int $pos, int $mode): int /** * Step K * - * @param array $numch * - * @return int */ protected function stepK(array $numch): int { @@ -98,6 +99,7 @@ protected function stepK(array $numch): int ) { return Data::ENC_ASCII; } + if ( $numch[Data::ENC_BASE256] < ceil(min( $numch[Data::ENC_ASCII], @@ -109,6 +111,7 @@ protected function stepK(array $numch): int ) { return Data::ENC_BASE256; } + if ( $numch[Data::ENC_EDF] < ceil(min( $numch[Data::ENC_ASCII], @@ -120,6 +123,7 @@ protected function stepK(array $numch): int ) { return Data::ENC_EDF; } + if ( $numch[Data::ENC_TXT] < ceil(min( $numch[Data::ENC_ASCII], @@ -131,6 +135,7 @@ protected function stepK(array $numch): int ) { return Data::ENC_TXT; } + if ( $numch[Data::ENC_X12] < ceil(min( $numch[Data::ENC_ASCII], @@ -142,14 +147,12 @@ protected function stepK(array $numch): int ) { return Data::ENC_X12; } + return Data::ENC_C40; } /** * Step L - * - * @param int $chr - * @param array $numch */ protected function stepL(int $chr, array &$numch): void { @@ -160,15 +163,12 @@ protected function stepL(int $chr, array &$numch): void $numch[Data::ENC_ASCII] += 2; } else { $numch[Data::ENC_ASCII] = ceil($numch[Data::ENC_ASCII]); - $numch[Data::ENC_ASCII] += 1; + ++$numch[Data::ENC_ASCII]; } } /** * Step M - * - * @param int $chr - * @param array $numch */ protected function stepM(int $chr, array &$numch): void { @@ -183,9 +183,6 @@ protected function stepM(int $chr, array &$numch): void /** * Step N - * - * @param int $chr - * @param array $numch */ protected function stepN(int $chr, array &$numch): void { @@ -200,9 +197,6 @@ protected function stepN(int $chr, array &$numch): void /** * Step O - * - * @param int $chr - * @param array $numch */ protected function stepO(int $chr, array &$numch): void { @@ -217,9 +211,6 @@ protected function stepO(int $chr, array &$numch): void /** * Step P - * - * @param int $chr - * @param array $numch */ protected function stepP(int $chr, array &$numch): void { @@ -234,27 +225,19 @@ protected function stepP(int $chr, array &$numch): void /** * Step Q - * - * @param int $chr - * @param array $numch */ protected function stepQ(int $chr, array &$numch): void { if ($this->isCharMode($chr, Data::ENC_BASE256)) { $numch[Data::ENC_BASE256] += 4; } else { - $numch[Data::ENC_BASE256] += 1; + ++$numch[Data::ENC_BASE256]; } } /** * Step R-f * - * @param array $numch - * @param int $pos - * @param int $data_length - * @param int $charscount - * @param string $data * * @return int Encoding mode */ @@ -277,31 +260,31 @@ protected function stepRf( if ($numch[Data::ENC_C40] < $numch[Data::ENC_X12]) { return Data::ENC_C40; } + if ($numch[Data::ENC_C40] == $numch[Data::ENC_X12]) { $ker = ($pos + $charscount + 1); while ($ker < $data_length) { $tmpchr = ord($data[$ker]); if ($this->isCharMode($tmpchr, Data::ENC_X12)) { return Data::ENC_X12; - } elseif ($this->isCharMode($tmpchr, Data::ENC_C40)) { + } + + if ($this->isCharMode($tmpchr, Data::ENC_C40)) { break; } + ++$ker; } + return Data::ENC_C40; } } + return -1; } /** * Step R - * - * @param array $numch - * @param int $pos - * @param int $data_length - * @param int $charscount - * @param string $data */ protected function stepR( array $numch, @@ -322,6 +305,7 @@ protected function stepR( ) { return Data::ENC_ASCII; } + if ( (($numch[Data::ENC_BASE256] + 1) <= $numch[Data::ENC_ASCII]) || (($numch[Data::ENC_BASE256] + 1) < min( @@ -333,6 +317,7 @@ protected function stepR( ) { return Data::ENC_BASE256; } + if ( ($numch[Data::ENC_EDF] + 1) < min( $numch[Data::ENC_ASCII], @@ -344,6 +329,7 @@ protected function stepR( ) { return Data::ENC_EDF; } + if ( ($numch[Data::ENC_TXT] + 1) < min( $numch[Data::ENC_ASCII], @@ -355,6 +341,7 @@ protected function stepR( ) { return Data::ENC_TXT; } + if ( ($numch[Data::ENC_X12] + 1) < min( $numch[Data::ENC_ASCII], @@ -366,6 +353,7 @@ protected function stepR( ) { return Data::ENC_X12; } + return $this->stepRf($numch, $pos, $data_length, $charscount, $data); } } diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index 98ec6970..dc9df4e5 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -56,46 +56,34 @@ class PdfFourOneSeven extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\C /** * Row height respect X dimension of single module - * - * @var int */ protected int $row_height = 2; /** * Horizontal quiet zone in modules - * - * @var int */ protected int $quiet_vertical = 2; /** * Vertical quiet zone in modules - * - * @var int */ protected int $quiet_horizontal = 2; /** * Aspect ratio (width / height) - * - * @var float */ protected float $aspectratio = 2; /** * Error correction level (0-8); * Default -1 = automatic correction level - * - * @var int */ protected int $ecl = -1; /** * Information for macro block - * - * @var array */ - protected array $macro = array(); + protected array $macro = []; /** * Set extra (optional) parameters @@ -105,12 +93,12 @@ protected function setParameters(): void parent::setParameters(); // aspect ratio - if (!empty($this->params[0]) && (($aspectratio = floatval($this->params[0])) >= 1)) { + if (!empty($this->params[0]) && (($aspectratio = (float) $this->params[0]) >= 1)) { $this->aspectratio = $aspectratio; } // error correction level (auto) - if (isset($this->params[1]) && (($ecl = intval($this->params[1])) >= 0) && ($ecl <= 8)) { + if (isset($this->params[1]) && (($ecl = (int) $this->params[1]) >= 0) && ($ecl <= 8)) { $this->ecl = $ecl; } @@ -129,8 +117,8 @@ protected function setMacroBlockParam(): void && ($this->params[3] !== '') && ($this->params[4] !== '') ) { - $this->macro['segment_total'] = intval($this->params[2]); - $this->macro['segment_index'] = intval($this->params[3]); + $this->macro['segment_total'] = (int) $this->params[2]; + $this->macro['segment_index'] = (int) $this->params[3]; $this->macro['file_id'] = strtr($this->params[4], "\xff", ','); for ($idx = 0; $idx < 7; ++$idx) { $opt = $idx + 5; @@ -151,23 +139,23 @@ protected function setBars(): void if (strlen((string)$this->code) == 0) { throw new BarcodeException('Empty input'); } - $barcode = $this->getBinSequence(); - $this->processBinarySequence($barcode); + + $binSequence = $this->getBinSequence(); + $this->processBinarySequence($binSequence); } /** * Get macro control block codewords * * @param int $numcw Number of codewords - * - * @return array */ protected function getMacroBlock(int &$numcw): array { - if (empty($this->macro)) { - return array(); + if ($this->macro === []) { + return []; } - $macrocw = array(); + + $macrocw = []; // beginning of macro control block $macrocw[] = 928; // segment index @@ -177,8 +165,8 @@ protected function getMacroBlock(int &$numcw): array $cdw = $this->getCompaction(900, $this->macro['file_id'], false); $macrocw = array_merge($macrocw, $cdw); // optional fields - $optmodes = array(900,902,902,900,900,902,902); - $optsize = array(-1,2,4,-1,-1,-1,2); + $optmodes = [900, 902, 902, 900, 900, 902, 902]; + $optsize = [-1, 2, 4, -1, -1, -1, 2]; foreach ($optmodes as $key => $omode) { if (isset($this->macro['option_' . $key])) { $macrocw[] = 923; @@ -188,14 +176,17 @@ protected function getMacroBlock(int &$numcw): array } elseif ($optsize[$key] == 4) { $this->macro['option_' . $key] = sprintf('%010d', $this->macro['option_' . $key]); } + $cdw = $this->getCompaction($omode, $this->macro['option_' . $key], false); $macrocw = array_merge($macrocw, $cdw); } } + if ($this->macro['segment_index'] == ($this->macro['segment_total'] - 1)) { // end of control block $macrocw[] = 922; } + // update total codewords $numcw += count($macrocw); return $macrocw; @@ -208,7 +199,6 @@ protected function getMacroBlock(int &$numcw): array * @param int $cols number of columns * @param int $ecl eroor correction level * - * @return array * * @throws BarcodeException in case of error */ @@ -218,22 +208,25 @@ public function getCodewords( int &$ecl ): array { - $codewords = array(); // array of code-words + $codewords = []; // array of code-words // get the input sequence array $sequence = $this->getInputSequences($this->code); foreach ($sequence as $seq) { $cws = $this->getCompaction($seq[0], $seq[1], true); $codewords = array_merge($codewords, $cws); } + if ($codewords[0] == 900) { // Text Alpha is the default mode, so remove the first code array_shift($codewords); } + // count number of codewords $numcw = count($codewords); if ($numcw > 925) { throw new BarcodeException('The maximum codeword capaciy has been reached: ' . $numcw . ' > 925'); } + $macrocw = $this->getMacroBlock($numcw); // set error correction level $ecl = $this->getErrorCorrectionLevel($this->ecl, $numcw); @@ -253,18 +246,22 @@ public function getCodewords( $cols = 16; $rows = 58; } + $size = 928; } + // calculate padding $pad = ($size - $nce); if ($pad > 0) { // add padding $codewords = array_merge($codewords, array_fill(0, $pad, 900)); } - if (!empty($macrocw)) { + + if ($macrocw !== []) { // add macro section $codewords = array_merge($codewords, $macrocw); } + // Symbol Length Descriptor (number of data codewords including Symbol Length Descriptor and pad codewords) $sld = ($size - $errsize); // add symbol length description @@ -303,21 +300,23 @@ public function getBinSequence(): string for ($rix = 0; $rix < $rows; ++$rix) { // row start code $row = $pstart; - $rval = $cval = 0; + $rval = 0; + $cval = 0; switch ($cid) { case 0: - $rval = ((30 * intval($rix / 3)) + intval(($rows - 1) / 3)); - $cval = ((30 * intval($rix / 3)) + ($cols - 1)); + $rval = ((30 * (int) ($rix / 3)) + (int) (($rows - 1) / 3)); + $cval = ((30 * (int) ($rix / 3)) + ($cols - 1)); break; case 1: - $rval = ((30 * intval($rix / 3)) + ($ecl * 3) + (($rows - 1) % 3)); - $cval = ((30 * intval($rix / 3)) + intval(($rows - 1) / 3)); + $rval = ((30 * (int) ($rix / 3)) + ($ecl * 3) + (($rows - 1) % 3)); + $cval = ((30 * (int) ($rix / 3)) + (int) (($rows - 1) / 3)); break; case 2: - $rval = ((30 * intval($rix / 3)) + ($cols - 1)); - $cval = ((30 * intval($rix / 3)) + ($ecl * 3) + (($rows - 1) % 3)); + $rval = ((30 * (int) ($rix / 3)) + ($cols - 1)); + $cval = ((30 * (int) ($rix / 3)) + ($ecl * 3) + (($rows - 1) % 3)); break; } + // left row indicator $row .= sprintf('%17b', Data::CLUSTERS[$cid][$rval]); // for each column @@ -325,6 +324,7 @@ public function getBinSequence(): string $row .= sprintf('%17b', Data::CLUSTERS[$cid][$codewords[$kcw]]); ++$kcw; } + // right row indicator $row .= sprintf('%17b', Data::CLUSTERS[$cid][$cval]); // row stop code @@ -336,7 +336,7 @@ public function getBinSequence(): string $cid = 0; } } - $barcode .= $empty_rows; - return $barcode; + + return $barcode . $empty_rows; } } diff --git a/src/Type/Square/PdfFourOneSeven/Compaction.php b/src/Type/Square/PdfFourOneSeven/Compaction.php index a5d0e5ae..ebc96b60 100644 --- a/src/Type/Square/PdfFourOneSeven/Compaction.php +++ b/src/Type/Square/PdfFourOneSeven/Compaction.php @@ -36,14 +36,6 @@ abstract class Compaction extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSev { /** * Process Sub Text Compaction - * - * @param array $txtarr - * @param int $submode - * @param int $sub - * @param string $code - * @param int $key - * @param int $idx - * @param int $codelen */ protected function processTextCompactionSub( array &$txtarr, @@ -56,25 +48,18 @@ protected function processTextCompactionSub( ): void { // $sub is the new submode - if ( - ((($idx + 1) == $codelen) || ((($idx + 1) < $codelen) - && (array_search(ord($code[($idx + 1)]), Data::TEXT_SUB_MODES[$submode]) !== false))) - && (($sub == 3) || (($sub == 0) && ($submode == 1))) - ) { + if ((($idx + 1 === $codelen) || ((($idx + 1) < $codelen) + && (in_array(ord($code[($idx + 1)]), Data::TEXT_SUB_MODES[$submode])))) + && (($sub == 3) || (($sub == 0) && ($submode == 1)))) { // shift (temporary change only for this char) - if ($sub == 3) { - // shift to puntuaction - $txtarr[] = 29; - } else { - // shift from lower to alpha - $txtarr[] = 27; - } + $txtarr[] = $sub == 3 ? 29 : 27; } else { // latch $txtarr = array_merge($txtarr, Data::TEXT_LATCH['' . $submode . $sub]); // set new submode $submode = $sub; } + // add characted code to array $txtarr[] = $key; } @@ -88,30 +73,32 @@ protected function processTextCompactionSub( protected function processTextCompaction(string $code, array &$codewords): void { $submode = 0; // default Alpha sub-mode - $txtarr = array(); // array of characters and sub-mode switching characters + $txtarr = []; // array of characters and sub-mode switching characters $codelen = strlen($code); for ($idx = 0; $idx < $codelen; ++$idx) { $chval = ord($code[$idx]); - if (($key = array_search($chval, Data::TEXT_SUB_MODES[$submode])) !== false) { + if (($key = array_search($chval, Data::TEXT_SUB_MODES[$submode], true)) !== false) { // we are on the same sub-mode $txtarr[] = $key; } else { // the sub-mode is changed for ($sub = 0; $sub < 4; ++$sub) { // search new sub-mode - if (($sub != $submode) && (($key = array_search($chval, Data::TEXT_SUB_MODES[$sub])) !== false)) { + if (($sub != $submode) && (($key = array_search($chval, Data::TEXT_SUB_MODES[$sub], true)) !== false)) { $this->processTextCompactionSub($txtarr, $submode, $sub, $code, $key, $idx, $codelen); break; } } } } + $txtarrlen = count($txtarr); - if (($txtarrlen % 2) != 0) { + if ($txtarrlen % 2 != 0) { // add padding $txtarr[] = 29; ++$txtarrlen; } + // calculate codewords for ($idx = 0; $idx < $txtarrlen; $idx += 2) { $codewords[] = (30 * $txtarr[$idx]) + $txtarr[($idx + 1)]; @@ -135,6 +122,7 @@ protected function processByteCompaction(string $code, array &$codewords): void $rest = ''; $sublen = strlen($code); } + if ($sublen == 6) { $tdg = bcmul('' . ord($code[0]), '1099511627776'); $tdg = bcadd($tdg, bcmul('' . ord($code[1]), '4294967296')); @@ -143,13 +131,14 @@ protected function processByteCompaction(string $code, array &$codewords): void $tdg = bcadd($tdg, bcmul('' . ord($code[4]), '256')); $tdg = bcadd($tdg, '' . ord($code[5])); // tmp array for the 6 bytes block - $cw6 = array(); + $cw6 = []; for ($idx = 0; $idx < 5; ++$idx) { $ddg = bcmod($tdg, '900'); $tdg = bcdiv($tdg, '900'); // prepend the value to the beginning of the array array_unshift($cw6, $ddg); } + // append the result array at the end $codewords = array_merge($codewords, $cw6); } else { @@ -157,6 +146,7 @@ protected function processByteCompaction(string $code, array &$codewords): void $codewords[] = ord($code[$idx]); } } + $code = $rest; } } @@ -175,12 +165,14 @@ protected function processNumericCompaction(string $code, array &$codewords): vo $rest = substr($code, 44); $code = substr($code, 0, 44); } + $tdg = '1' . $code; do { $ddg = bcmod($tdg, '900'); $tdg = bcdiv($tdg, '900'); array_unshift($codewords, $ddg); } while ($tdg != '0'); + $code = $rest; } } @@ -200,7 +192,7 @@ protected function getCompaction( bool $addmode = true ): array { - $codewords = array(); // array of codewords to return + $codewords = []; // array of codewords to return switch ($mode) { case 900: // Text Compaction mode latch @@ -220,10 +212,12 @@ protected function getCompaction( $codewords[] = ord($code); break; } + if ($addmode) { // add the compaction mode codeword at the beginning array_unshift($codewords, $mode); } + return $codewords; } } diff --git a/src/Type/Square/PdfFourOneSeven/Data.php b/src/Type/Square/PdfFourOneSeven/Data.php index 2b1834c0..846c8cc1 100644 --- a/src/Type/Square/PdfFourOneSeven/Data.php +++ b/src/Type/Square/PdfFourOneSeven/Data.php @@ -44,46 +44,140 @@ abstract class Data /** * Array of text Compaction Sub-Modes (values 0xFB - 0xFF are used for submode changers) */ - public const TEXT_SUB_MODES = array( - array( // Alpha - 0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a, - 0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54, - 0x55,0x56,0x57,0x58,0x59,0x5a,0x20,0xFD,0xFE,0xFF - ), - array( // Lower - 0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a, - 0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74, - 0x75,0x76,0x77,0x78,0x79,0x7a,0x20,0xFD,0xFE,0xFF - ), - array( // Mixed - 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39, - 0x26,0x0d,0x09,0x2c,0x3a,0x23,0x2d,0x2e,0x24,0x2f, - 0x2b,0x25,0x2a,0x3d,0x5e,0xFB,0x20,0xFD,0xFE,0xFF - ), - array( // Puntuaction - 0x3b,0x3c,0x3e,0x40,0x5b,0x5c,0x5d,0x5f,0x60,0x7e, - 0x21,0x0d,0x09,0x2c,0x3a,0x0a,0x2d,0x2e,0x24,0x2f, - 0x22,0x7c,0x2a,0x28,0x29,0x3f,0x7b,0x7d,0x27,0xFF - ) - ); + public const TEXT_SUB_MODES = [[ + // Alpha + 0x41, + 0x42, + 0x43, + 0x44, + 0x45, + 0x46, + 0x47, + 0x48, + 0x49, + 0x4a, + 0x4b, + 0x4c, + 0x4d, + 0x4e, + 0x4f, + 0x50, + 0x51, + 0x52, + 0x53, + 0x54, + 0x55, + 0x56, + 0x57, + 0x58, + 0x59, + 0x5a, + 0x20, + 0xFD, + 0xFE, + 0xFF, + ], [ + // Lower + 0x61, + 0x62, + 0x63, + 0x64, + 0x65, + 0x66, + 0x67, + 0x68, + 0x69, + 0x6a, + 0x6b, + 0x6c, + 0x6d, + 0x6e, + 0x6f, + 0x70, + 0x71, + 0x72, + 0x73, + 0x74, + 0x75, + 0x76, + 0x77, + 0x78, + 0x79, + 0x7a, + 0x20, + 0xFD, + 0xFE, + 0xFF, + ], [ + // Mixed + 0x30, + 0x31, + 0x32, + 0x33, + 0x34, + 0x35, + 0x36, + 0x37, + 0x38, + 0x39, + 0x26, + 0x0d, + 0x09, + 0x2c, + 0x3a, + 0x23, + 0x2d, + 0x2e, + 0x24, + 0x2f, + 0x2b, + 0x25, + 0x2a, + 0x3d, + 0x5e, + 0xFB, + 0x20, + 0xFD, + 0xFE, + 0xFF, + ], [ + // Puntuaction + 0x3b, + 0x3c, + 0x3e, + 0x40, + 0x5b, + 0x5c, + 0x5d, + 0x5f, + 0x60, + 0x7e, + 0x21, + 0x0d, + 0x09, + 0x2c, + 0x3a, + 0x0a, + 0x2d, + 0x2e, + 0x24, + 0x2f, + 0x22, + 0x7c, + 0x2a, + 0x28, + 0x29, + 0x3f, + 0x7b, + 0x7d, + 0x27, + 0xFF, + ]]; /** * Array of switching codes for Text Compaction Sub-Modes */ - public const TEXT_LATCH = array( - '01' => array(27), - '02' => array(28), - '03' => array(28,25), - '10' => array(28,28), - '12' => array(28), - '13' => array(28,25), - '20' => array(28), - '21' => array(27), - '23' => array(25), - '30' => array(29), - '31' => array(29,27), - '32' => array(29,28) - ); + public const TEXT_LATCH = ['01' => [27], '02' => [28], '03' => [28, 25], '10' => [28, 28], '12' => [28], '13' => [28, 25], '20' => [28], '21' => [27], '23' => [25], '30' => [29], '31' => [29, 27], '32' => [29, 28]]; /** * Clusters of codewords (0, 3, 6). @@ -106,382 +200,4177 @@ abstract class Data * 927 : Identifier for an ECI of a character set or code page * 928 : Macro marker codeword to indicate the beginning of a Macro PDF Control Block */ - public const CLUSTERS = array( - array( // cluster 0 ----------------------------------------------------------------------- - 0x1d5c0,0x1eaf0,0x1f57c,0x1d4e0,0x1ea78,0x1f53e,0x1a8c0,0x1d470,0x1a860,0x15040, // 10 - 0x1a830,0x15020,0x1adc0,0x1d6f0,0x1eb7c,0x1ace0,0x1d678,0x1eb3e,0x158c0,0x1ac70, // 20 - 0x15860,0x15dc0,0x1aef0,0x1d77c,0x15ce0,0x1ae78,0x1d73e,0x15c70,0x1ae3c,0x15ef0, // 30 - 0x1af7c,0x15e78,0x1af3e,0x15f7c,0x1f5fa,0x1d2e0,0x1e978,0x1f4be,0x1a4c0,0x1d270, // 40 - 0x1e93c,0x1a460,0x1d238,0x14840,0x1a430,0x1d21c,0x14820,0x1a418,0x14810,0x1a6e0, // 50 - 0x1d378,0x1e9be,0x14cc0,0x1a670,0x1d33c,0x14c60,0x1a638,0x1d31e,0x14c30,0x1a61c, // 60 - 0x14ee0,0x1a778,0x1d3be,0x14e70,0x1a73c,0x14e38,0x1a71e,0x14f78,0x1a7be,0x14f3c, // 70 - 0x14f1e,0x1a2c0,0x1d170,0x1e8bc,0x1a260,0x1d138,0x1e89e,0x14440,0x1a230,0x1d11c, // 80 - 0x14420,0x1a218,0x14410,0x14408,0x146c0,0x1a370,0x1d1bc,0x14660,0x1a338,0x1d19e, // 90 - 0x14630,0x1a31c,0x14618,0x1460c,0x14770,0x1a3bc,0x14738,0x1a39e,0x1471c,0x147bc, // 100 - 0x1a160,0x1d0b8,0x1e85e,0x14240,0x1a130,0x1d09c,0x14220,0x1a118,0x1d08e,0x14210, // 110 - 0x1a10c,0x14208,0x1a106,0x14360,0x1a1b8,0x1d0de,0x14330,0x1a19c,0x14318,0x1a18e, // 120 - 0x1430c,0x14306,0x1a1de,0x1438e,0x14140,0x1a0b0,0x1d05c,0x14120,0x1a098,0x1d04e, // 130 - 0x14110,0x1a08c,0x14108,0x1a086,0x14104,0x141b0,0x14198,0x1418c,0x140a0,0x1d02e, // 140 - 0x1a04c,0x1a046,0x14082,0x1cae0,0x1e578,0x1f2be,0x194c0,0x1ca70,0x1e53c,0x19460, // 150 - 0x1ca38,0x1e51e,0x12840,0x19430,0x12820,0x196e0,0x1cb78,0x1e5be,0x12cc0,0x19670, // 160 - 0x1cb3c,0x12c60,0x19638,0x12c30,0x12c18,0x12ee0,0x19778,0x1cbbe,0x12e70,0x1973c, // 170 - 0x12e38,0x12e1c,0x12f78,0x197be,0x12f3c,0x12fbe,0x1dac0,0x1ed70,0x1f6bc,0x1da60, // 180 - 0x1ed38,0x1f69e,0x1b440,0x1da30,0x1ed1c,0x1b420,0x1da18,0x1ed0e,0x1b410,0x1da0c, // 190 - 0x192c0,0x1c970,0x1e4bc,0x1b6c0,0x19260,0x1c938,0x1e49e,0x1b660,0x1db38,0x1ed9e, // 200 - 0x16c40,0x12420,0x19218,0x1c90e,0x16c20,0x1b618,0x16c10,0x126c0,0x19370,0x1c9bc, // 210 - 0x16ec0,0x12660,0x19338,0x1c99e,0x16e60,0x1b738,0x1db9e,0x16e30,0x12618,0x16e18, // 220 - 0x12770,0x193bc,0x16f70,0x12738,0x1939e,0x16f38,0x1b79e,0x16f1c,0x127bc,0x16fbc, // 230 - 0x1279e,0x16f9e,0x1d960,0x1ecb8,0x1f65e,0x1b240,0x1d930,0x1ec9c,0x1b220,0x1d918, // 240 - 0x1ec8e,0x1b210,0x1d90c,0x1b208,0x1b204,0x19160,0x1c8b8,0x1e45e,0x1b360,0x19130, // 250 - 0x1c89c,0x16640,0x12220,0x1d99c,0x1c88e,0x16620,0x12210,0x1910c,0x16610,0x1b30c, // 260 - 0x19106,0x12204,0x12360,0x191b8,0x1c8de,0x16760,0x12330,0x1919c,0x16730,0x1b39c, // 270 - 0x1918e,0x16718,0x1230c,0x12306,0x123b8,0x191de,0x167b8,0x1239c,0x1679c,0x1238e, // 280 - 0x1678e,0x167de,0x1b140,0x1d8b0,0x1ec5c,0x1b120,0x1d898,0x1ec4e,0x1b110,0x1d88c, // 290 - 0x1b108,0x1d886,0x1b104,0x1b102,0x12140,0x190b0,0x1c85c,0x16340,0x12120,0x19098, // 300 - 0x1c84e,0x16320,0x1b198,0x1d8ce,0x16310,0x12108,0x19086,0x16308,0x1b186,0x16304, // 310 - 0x121b0,0x190dc,0x163b0,0x12198,0x190ce,0x16398,0x1b1ce,0x1638c,0x12186,0x16386, // 320 - 0x163dc,0x163ce,0x1b0a0,0x1d858,0x1ec2e,0x1b090,0x1d84c,0x1b088,0x1d846,0x1b084, // 330 - 0x1b082,0x120a0,0x19058,0x1c82e,0x161a0,0x12090,0x1904c,0x16190,0x1b0cc,0x19046, // 340 - 0x16188,0x12084,0x16184,0x12082,0x120d8,0x161d8,0x161cc,0x161c6,0x1d82c,0x1d826, // 350 - 0x1b042,0x1902c,0x12048,0x160c8,0x160c4,0x160c2,0x18ac0,0x1c570,0x1e2bc,0x18a60, // 360 - 0x1c538,0x11440,0x18a30,0x1c51c,0x11420,0x18a18,0x11410,0x11408,0x116c0,0x18b70, // 370 - 0x1c5bc,0x11660,0x18b38,0x1c59e,0x11630,0x18b1c,0x11618,0x1160c,0x11770,0x18bbc, // 380 - 0x11738,0x18b9e,0x1171c,0x117bc,0x1179e,0x1cd60,0x1e6b8,0x1f35e,0x19a40,0x1cd30, // 390 - 0x1e69c,0x19a20,0x1cd18,0x1e68e,0x19a10,0x1cd0c,0x19a08,0x1cd06,0x18960,0x1c4b8, // 400 - 0x1e25e,0x19b60,0x18930,0x1c49c,0x13640,0x11220,0x1cd9c,0x1c48e,0x13620,0x19b18, // 410 - 0x1890c,0x13610,0x11208,0x13608,0x11360,0x189b8,0x1c4de,0x13760,0x11330,0x1cdde, // 420 - 0x13730,0x19b9c,0x1898e,0x13718,0x1130c,0x1370c,0x113b8,0x189de,0x137b8,0x1139c, // 430 - 0x1379c,0x1138e,0x113de,0x137de,0x1dd40,0x1eeb0,0x1f75c,0x1dd20,0x1ee98,0x1f74e, // 440 - 0x1dd10,0x1ee8c,0x1dd08,0x1ee86,0x1dd04,0x19940,0x1ccb0,0x1e65c,0x1bb40,0x19920, // 450 - 0x1eedc,0x1e64e,0x1bb20,0x1dd98,0x1eece,0x1bb10,0x19908,0x1cc86,0x1bb08,0x1dd86, // 460 - 0x19902,0x11140,0x188b0,0x1c45c,0x13340,0x11120,0x18898,0x1c44e,0x17740,0x13320, // 470 - 0x19998,0x1ccce,0x17720,0x1bb98,0x1ddce,0x18886,0x17710,0x13308,0x19986,0x17708, // 480 - 0x11102,0x111b0,0x188dc,0x133b0,0x11198,0x188ce,0x177b0,0x13398,0x199ce,0x17798, // 490 - 0x1bbce,0x11186,0x13386,0x111dc,0x133dc,0x111ce,0x177dc,0x133ce,0x1dca0,0x1ee58, // 500 - 0x1f72e,0x1dc90,0x1ee4c,0x1dc88,0x1ee46,0x1dc84,0x1dc82,0x198a0,0x1cc58,0x1e62e, // 510 - 0x1b9a0,0x19890,0x1ee6e,0x1b990,0x1dccc,0x1cc46,0x1b988,0x19884,0x1b984,0x19882, // 520 - 0x1b982,0x110a0,0x18858,0x1c42e,0x131a0,0x11090,0x1884c,0x173a0,0x13190,0x198cc, // 530 - 0x18846,0x17390,0x1b9cc,0x11084,0x17388,0x13184,0x11082,0x13182,0x110d8,0x1886e, // 540 - 0x131d8,0x110cc,0x173d8,0x131cc,0x110c6,0x173cc,0x131c6,0x110ee,0x173ee,0x1dc50, // 550 - 0x1ee2c,0x1dc48,0x1ee26,0x1dc44,0x1dc42,0x19850,0x1cc2c,0x1b8d0,0x19848,0x1cc26, // 560 - 0x1b8c8,0x1dc66,0x1b8c4,0x19842,0x1b8c2,0x11050,0x1882c,0x130d0,0x11048,0x18826, // 570 - 0x171d0,0x130c8,0x19866,0x171c8,0x1b8e6,0x11042,0x171c4,0x130c2,0x171c2,0x130ec, // 580 - 0x171ec,0x171e6,0x1ee16,0x1dc22,0x1cc16,0x19824,0x19822,0x11028,0x13068,0x170e8, // 590 - 0x11022,0x13062,0x18560,0x10a40,0x18530,0x10a20,0x18518,0x1c28e,0x10a10,0x1850c, // 600 - 0x10a08,0x18506,0x10b60,0x185b8,0x1c2de,0x10b30,0x1859c,0x10b18,0x1858e,0x10b0c, // 610 - 0x10b06,0x10bb8,0x185de,0x10b9c,0x10b8e,0x10bde,0x18d40,0x1c6b0,0x1e35c,0x18d20, // 620 - 0x1c698,0x18d10,0x1c68c,0x18d08,0x1c686,0x18d04,0x10940,0x184b0,0x1c25c,0x11b40, // 630 - 0x10920,0x1c6dc,0x1c24e,0x11b20,0x18d98,0x1c6ce,0x11b10,0x10908,0x18486,0x11b08, // 640 - 0x18d86,0x10902,0x109b0,0x184dc,0x11bb0,0x10998,0x184ce,0x11b98,0x18dce,0x11b8c, // 650 - 0x10986,0x109dc,0x11bdc,0x109ce,0x11bce,0x1cea0,0x1e758,0x1f3ae,0x1ce90,0x1e74c, // 660 - 0x1ce88,0x1e746,0x1ce84,0x1ce82,0x18ca0,0x1c658,0x19da0,0x18c90,0x1c64c,0x19d90, // 670 - 0x1cecc,0x1c646,0x19d88,0x18c84,0x19d84,0x18c82,0x19d82,0x108a0,0x18458,0x119a0, // 680 - 0x10890,0x1c66e,0x13ba0,0x11990,0x18ccc,0x18446,0x13b90,0x19dcc,0x10884,0x13b88, // 690 - 0x11984,0x10882,0x11982,0x108d8,0x1846e,0x119d8,0x108cc,0x13bd8,0x119cc,0x108c6, // 700 - 0x13bcc,0x119c6,0x108ee,0x119ee,0x13bee,0x1ef50,0x1f7ac,0x1ef48,0x1f7a6,0x1ef44, // 710 - 0x1ef42,0x1ce50,0x1e72c,0x1ded0,0x1ef6c,0x1e726,0x1dec8,0x1ef66,0x1dec4,0x1ce42, // 720 - 0x1dec2,0x18c50,0x1c62c,0x19cd0,0x18c48,0x1c626,0x1bdd0,0x19cc8,0x1ce66,0x1bdc8, // 730 - 0x1dee6,0x18c42,0x1bdc4,0x19cc2,0x1bdc2,0x10850,0x1842c,0x118d0,0x10848,0x18426, // 740 - 0x139d0,0x118c8,0x18c66,0x17bd0,0x139c8,0x19ce6,0x10842,0x17bc8,0x1bde6,0x118c2, // 750 - 0x17bc4,0x1086c,0x118ec,0x10866,0x139ec,0x118e6,0x17bec,0x139e6,0x17be6,0x1ef28, // 760 - 0x1f796,0x1ef24,0x1ef22,0x1ce28,0x1e716,0x1de68,0x1ef36,0x1de64,0x1ce22,0x1de62, // 770 - 0x18c28,0x1c616,0x19c68,0x18c24,0x1bce8,0x19c64,0x18c22,0x1bce4,0x19c62,0x1bce2, // 780 - 0x10828,0x18416,0x11868,0x18c36,0x138e8,0x11864,0x10822,0x179e8,0x138e4,0x11862, // 790 - 0x179e4,0x138e2,0x179e2,0x11876,0x179f6,0x1ef12,0x1de34,0x1de32,0x19c34,0x1bc74, // 800 - 0x1bc72,0x11834,0x13874,0x178f4,0x178f2,0x10540,0x10520,0x18298,0x10510,0x10508, // 810 - 0x10504,0x105b0,0x10598,0x1058c,0x10586,0x105dc,0x105ce,0x186a0,0x18690,0x1c34c, // 820 - 0x18688,0x1c346,0x18684,0x18682,0x104a0,0x18258,0x10da0,0x186d8,0x1824c,0x10d90, // 830 - 0x186cc,0x10d88,0x186c6,0x10d84,0x10482,0x10d82,0x104d8,0x1826e,0x10dd8,0x186ee, // 840 - 0x10dcc,0x104c6,0x10dc6,0x104ee,0x10dee,0x1c750,0x1c748,0x1c744,0x1c742,0x18650, // 850 - 0x18ed0,0x1c76c,0x1c326,0x18ec8,0x1c766,0x18ec4,0x18642,0x18ec2,0x10450,0x10cd0, // 860 - 0x10448,0x18226,0x11dd0,0x10cc8,0x10444,0x11dc8,0x10cc4,0x10442,0x11dc4,0x10cc2, // 870 - 0x1046c,0x10cec,0x10466,0x11dec,0x10ce6,0x11de6,0x1e7a8,0x1e7a4,0x1e7a2,0x1c728, // 880 - 0x1cf68,0x1e7b6,0x1cf64,0x1c722,0x1cf62,0x18628,0x1c316,0x18e68,0x1c736,0x19ee8, // 890 - 0x18e64,0x18622,0x19ee4,0x18e62,0x19ee2,0x10428,0x18216,0x10c68,0x18636,0x11ce8, // 900 - 0x10c64,0x10422,0x13de8,0x11ce4,0x10c62,0x13de4,0x11ce2,0x10436,0x10c76,0x11cf6, // 910 - 0x13df6,0x1f7d4,0x1f7d2,0x1e794,0x1efb4,0x1e792,0x1efb2,0x1c714,0x1cf34,0x1c712, // 920 - 0x1df74,0x1cf32,0x1df72,0x18614,0x18e34,0x18612,0x19e74,0x18e32,0x1bef4 // 929 - ), - array( // cluster 3 ----------------------------------------------------------------------- - 0x1f560,0x1fab8,0x1ea40,0x1f530,0x1fa9c,0x1ea20,0x1f518,0x1fa8e,0x1ea10,0x1f50c, // 10 - 0x1ea08,0x1f506,0x1ea04,0x1eb60,0x1f5b8,0x1fade,0x1d640,0x1eb30,0x1f59c,0x1d620, // 20 - 0x1eb18,0x1f58e,0x1d610,0x1eb0c,0x1d608,0x1eb06,0x1d604,0x1d760,0x1ebb8,0x1f5de, // 30 - 0x1ae40,0x1d730,0x1eb9c,0x1ae20,0x1d718,0x1eb8e,0x1ae10,0x1d70c,0x1ae08,0x1d706, // 40 - 0x1ae04,0x1af60,0x1d7b8,0x1ebde,0x15e40,0x1af30,0x1d79c,0x15e20,0x1af18,0x1d78e, // 50 - 0x15e10,0x1af0c,0x15e08,0x1af06,0x15f60,0x1afb8,0x1d7de,0x15f30,0x1af9c,0x15f18, // 60 - 0x1af8e,0x15f0c,0x15fb8,0x1afde,0x15f9c,0x15f8e,0x1e940,0x1f4b0,0x1fa5c,0x1e920, // 70 - 0x1f498,0x1fa4e,0x1e910,0x1f48c,0x1e908,0x1f486,0x1e904,0x1e902,0x1d340,0x1e9b0, // 80 - 0x1f4dc,0x1d320,0x1e998,0x1f4ce,0x1d310,0x1e98c,0x1d308,0x1e986,0x1d304,0x1d302, // 90 - 0x1a740,0x1d3b0,0x1e9dc,0x1a720,0x1d398,0x1e9ce,0x1a710,0x1d38c,0x1a708,0x1d386, // 100 - 0x1a704,0x1a702,0x14f40,0x1a7b0,0x1d3dc,0x14f20,0x1a798,0x1d3ce,0x14f10,0x1a78c, // 110 - 0x14f08,0x1a786,0x14f04,0x14fb0,0x1a7dc,0x14f98,0x1a7ce,0x14f8c,0x14f86,0x14fdc, // 120 - 0x14fce,0x1e8a0,0x1f458,0x1fa2e,0x1e890,0x1f44c,0x1e888,0x1f446,0x1e884,0x1e882, // 130 - 0x1d1a0,0x1e8d8,0x1f46e,0x1d190,0x1e8cc,0x1d188,0x1e8c6,0x1d184,0x1d182,0x1a3a0, // 140 - 0x1d1d8,0x1e8ee,0x1a390,0x1d1cc,0x1a388,0x1d1c6,0x1a384,0x1a382,0x147a0,0x1a3d8, // 150 - 0x1d1ee,0x14790,0x1a3cc,0x14788,0x1a3c6,0x14784,0x14782,0x147d8,0x1a3ee,0x147cc, // 160 - 0x147c6,0x147ee,0x1e850,0x1f42c,0x1e848,0x1f426,0x1e844,0x1e842,0x1d0d0,0x1e86c, // 170 - 0x1d0c8,0x1e866,0x1d0c4,0x1d0c2,0x1a1d0,0x1d0ec,0x1a1c8,0x1d0e6,0x1a1c4,0x1a1c2, // 180 - 0x143d0,0x1a1ec,0x143c8,0x1a1e6,0x143c4,0x143c2,0x143ec,0x143e6,0x1e828,0x1f416, // 190 - 0x1e824,0x1e822,0x1d068,0x1e836,0x1d064,0x1d062,0x1a0e8,0x1d076,0x1a0e4,0x1a0e2, // 200 - 0x141e8,0x1a0f6,0x141e4,0x141e2,0x1e814,0x1e812,0x1d034,0x1d032,0x1a074,0x1a072, // 210 - 0x1e540,0x1f2b0,0x1f95c,0x1e520,0x1f298,0x1f94e,0x1e510,0x1f28c,0x1e508,0x1f286, // 220 - 0x1e504,0x1e502,0x1cb40,0x1e5b0,0x1f2dc,0x1cb20,0x1e598,0x1f2ce,0x1cb10,0x1e58c, // 230 - 0x1cb08,0x1e586,0x1cb04,0x1cb02,0x19740,0x1cbb0,0x1e5dc,0x19720,0x1cb98,0x1e5ce, // 240 - 0x19710,0x1cb8c,0x19708,0x1cb86,0x19704,0x19702,0x12f40,0x197b0,0x1cbdc,0x12f20, // 250 - 0x19798,0x1cbce,0x12f10,0x1978c,0x12f08,0x19786,0x12f04,0x12fb0,0x197dc,0x12f98, // 260 - 0x197ce,0x12f8c,0x12f86,0x12fdc,0x12fce,0x1f6a0,0x1fb58,0x16bf0,0x1f690,0x1fb4c, // 270 - 0x169f8,0x1f688,0x1fb46,0x168fc,0x1f684,0x1f682,0x1e4a0,0x1f258,0x1f92e,0x1eda0, // 280 - 0x1e490,0x1fb6e,0x1ed90,0x1f6cc,0x1f246,0x1ed88,0x1e484,0x1ed84,0x1e482,0x1ed82, // 290 - 0x1c9a0,0x1e4d8,0x1f26e,0x1dba0,0x1c990,0x1e4cc,0x1db90,0x1edcc,0x1e4c6,0x1db88, // 300 - 0x1c984,0x1db84,0x1c982,0x1db82,0x193a0,0x1c9d8,0x1e4ee,0x1b7a0,0x19390,0x1c9cc, // 310 - 0x1b790,0x1dbcc,0x1c9c6,0x1b788,0x19384,0x1b784,0x19382,0x1b782,0x127a0,0x193d8, // 320 - 0x1c9ee,0x16fa0,0x12790,0x193cc,0x16f90,0x1b7cc,0x193c6,0x16f88,0x12784,0x16f84, // 330 - 0x12782,0x127d8,0x193ee,0x16fd8,0x127cc,0x16fcc,0x127c6,0x16fc6,0x127ee,0x1f650, // 340 - 0x1fb2c,0x165f8,0x1f648,0x1fb26,0x164fc,0x1f644,0x1647e,0x1f642,0x1e450,0x1f22c, // 350 - 0x1ecd0,0x1e448,0x1f226,0x1ecc8,0x1f666,0x1ecc4,0x1e442,0x1ecc2,0x1c8d0,0x1e46c, // 360 - 0x1d9d0,0x1c8c8,0x1e466,0x1d9c8,0x1ece6,0x1d9c4,0x1c8c2,0x1d9c2,0x191d0,0x1c8ec, // 370 - 0x1b3d0,0x191c8,0x1c8e6,0x1b3c8,0x1d9e6,0x1b3c4,0x191c2,0x1b3c2,0x123d0,0x191ec, // 380 - 0x167d0,0x123c8,0x191e6,0x167c8,0x1b3e6,0x167c4,0x123c2,0x167c2,0x123ec,0x167ec, // 390 - 0x123e6,0x167e6,0x1f628,0x1fb16,0x162fc,0x1f624,0x1627e,0x1f622,0x1e428,0x1f216, // 400 - 0x1ec68,0x1f636,0x1ec64,0x1e422,0x1ec62,0x1c868,0x1e436,0x1d8e8,0x1c864,0x1d8e4, // 410 - 0x1c862,0x1d8e2,0x190e8,0x1c876,0x1b1e8,0x1d8f6,0x1b1e4,0x190e2,0x1b1e2,0x121e8, // 420 - 0x190f6,0x163e8,0x121e4,0x163e4,0x121e2,0x163e2,0x121f6,0x163f6,0x1f614,0x1617e, // 430 - 0x1f612,0x1e414,0x1ec34,0x1e412,0x1ec32,0x1c834,0x1d874,0x1c832,0x1d872,0x19074, // 440 - 0x1b0f4,0x19072,0x1b0f2,0x120f4,0x161f4,0x120f2,0x161f2,0x1f60a,0x1e40a,0x1ec1a, // 450 - 0x1c81a,0x1d83a,0x1903a,0x1b07a,0x1e2a0,0x1f158,0x1f8ae,0x1e290,0x1f14c,0x1e288, // 460 - 0x1f146,0x1e284,0x1e282,0x1c5a0,0x1e2d8,0x1f16e,0x1c590,0x1e2cc,0x1c588,0x1e2c6, // 470 - 0x1c584,0x1c582,0x18ba0,0x1c5d8,0x1e2ee,0x18b90,0x1c5cc,0x18b88,0x1c5c6,0x18b84, // 480 - 0x18b82,0x117a0,0x18bd8,0x1c5ee,0x11790,0x18bcc,0x11788,0x18bc6,0x11784,0x11782, // 490 - 0x117d8,0x18bee,0x117cc,0x117c6,0x117ee,0x1f350,0x1f9ac,0x135f8,0x1f348,0x1f9a6, // 500 - 0x134fc,0x1f344,0x1347e,0x1f342,0x1e250,0x1f12c,0x1e6d0,0x1e248,0x1f126,0x1e6c8, // 510 - 0x1f366,0x1e6c4,0x1e242,0x1e6c2,0x1c4d0,0x1e26c,0x1cdd0,0x1c4c8,0x1e266,0x1cdc8, // 520 - 0x1e6e6,0x1cdc4,0x1c4c2,0x1cdc2,0x189d0,0x1c4ec,0x19bd0,0x189c8,0x1c4e6,0x19bc8, // 530 - 0x1cde6,0x19bc4,0x189c2,0x19bc2,0x113d0,0x189ec,0x137d0,0x113c8,0x189e6,0x137c8, // 540 - 0x19be6,0x137c4,0x113c2,0x137c2,0x113ec,0x137ec,0x113e6,0x137e6,0x1fba8,0x175f0, // 550 - 0x1bafc,0x1fba4,0x174f8,0x1ba7e,0x1fba2,0x1747c,0x1743e,0x1f328,0x1f996,0x132fc, // 560 - 0x1f768,0x1fbb6,0x176fc,0x1327e,0x1f764,0x1f322,0x1767e,0x1f762,0x1e228,0x1f116, // 570 - 0x1e668,0x1e224,0x1eee8,0x1f776,0x1e222,0x1eee4,0x1e662,0x1eee2,0x1c468,0x1e236, // 580 - 0x1cce8,0x1c464,0x1dde8,0x1cce4,0x1c462,0x1dde4,0x1cce2,0x1dde2,0x188e8,0x1c476, // 590 - 0x199e8,0x188e4,0x1bbe8,0x199e4,0x188e2,0x1bbe4,0x199e2,0x1bbe2,0x111e8,0x188f6, // 600 - 0x133e8,0x111e4,0x177e8,0x133e4,0x111e2,0x177e4,0x133e2,0x177e2,0x111f6,0x133f6, // 610 - 0x1fb94,0x172f8,0x1b97e,0x1fb92,0x1727c,0x1723e,0x1f314,0x1317e,0x1f734,0x1f312, // 620 - 0x1737e,0x1f732,0x1e214,0x1e634,0x1e212,0x1ee74,0x1e632,0x1ee72,0x1c434,0x1cc74, // 630 - 0x1c432,0x1dcf4,0x1cc72,0x1dcf2,0x18874,0x198f4,0x18872,0x1b9f4,0x198f2,0x1b9f2, // 640 - 0x110f4,0x131f4,0x110f2,0x173f4,0x131f2,0x173f2,0x1fb8a,0x1717c,0x1713e,0x1f30a, // 650 - 0x1f71a,0x1e20a,0x1e61a,0x1ee3a,0x1c41a,0x1cc3a,0x1dc7a,0x1883a,0x1987a,0x1b8fa, // 660 - 0x1107a,0x130fa,0x171fa,0x170be,0x1e150,0x1f0ac,0x1e148,0x1f0a6,0x1e144,0x1e142, // 670 - 0x1c2d0,0x1e16c,0x1c2c8,0x1e166,0x1c2c4,0x1c2c2,0x185d0,0x1c2ec,0x185c8,0x1c2e6, // 680 - 0x185c4,0x185c2,0x10bd0,0x185ec,0x10bc8,0x185e6,0x10bc4,0x10bc2,0x10bec,0x10be6, // 690 - 0x1f1a8,0x1f8d6,0x11afc,0x1f1a4,0x11a7e,0x1f1a2,0x1e128,0x1f096,0x1e368,0x1e124, // 700 - 0x1e364,0x1e122,0x1e362,0x1c268,0x1e136,0x1c6e8,0x1c264,0x1c6e4,0x1c262,0x1c6e2, // 710 - 0x184e8,0x1c276,0x18de8,0x184e4,0x18de4,0x184e2,0x18de2,0x109e8,0x184f6,0x11be8, // 720 - 0x109e4,0x11be4,0x109e2,0x11be2,0x109f6,0x11bf6,0x1f9d4,0x13af8,0x19d7e,0x1f9d2, // 730 - 0x13a7c,0x13a3e,0x1f194,0x1197e,0x1f3b4,0x1f192,0x13b7e,0x1f3b2,0x1e114,0x1e334, // 740 - 0x1e112,0x1e774,0x1e332,0x1e772,0x1c234,0x1c674,0x1c232,0x1cef4,0x1c672,0x1cef2, // 750 - 0x18474,0x18cf4,0x18472,0x19df4,0x18cf2,0x19df2,0x108f4,0x119f4,0x108f2,0x13bf4, // 760 - 0x119f2,0x13bf2,0x17af0,0x1bd7c,0x17a78,0x1bd3e,0x17a3c,0x17a1e,0x1f9ca,0x1397c, // 770 - 0x1fbda,0x17b7c,0x1393e,0x17b3e,0x1f18a,0x1f39a,0x1f7ba,0x1e10a,0x1e31a,0x1e73a, // 780 - 0x1ef7a,0x1c21a,0x1c63a,0x1ce7a,0x1defa,0x1843a,0x18c7a,0x19cfa,0x1bdfa,0x1087a, // 790 - 0x118fa,0x139fa,0x17978,0x1bcbe,0x1793c,0x1791e,0x138be,0x179be,0x178bc,0x1789e, // 800 - 0x1785e,0x1e0a8,0x1e0a4,0x1e0a2,0x1c168,0x1e0b6,0x1c164,0x1c162,0x182e8,0x1c176, // 810 - 0x182e4,0x182e2,0x105e8,0x182f6,0x105e4,0x105e2,0x105f6,0x1f0d4,0x10d7e,0x1f0d2, // 820 - 0x1e094,0x1e1b4,0x1e092,0x1e1b2,0x1c134,0x1c374,0x1c132,0x1c372,0x18274,0x186f4, // 830 - 0x18272,0x186f2,0x104f4,0x10df4,0x104f2,0x10df2,0x1f8ea,0x11d7c,0x11d3e,0x1f0ca, // 840 - 0x1f1da,0x1e08a,0x1e19a,0x1e3ba,0x1c11a,0x1c33a,0x1c77a,0x1823a,0x1867a,0x18efa, // 850 - 0x1047a,0x10cfa,0x11dfa,0x13d78,0x19ebe,0x13d3c,0x13d1e,0x11cbe,0x13dbe,0x17d70, // 860 - 0x1bebc,0x17d38,0x1be9e,0x17d1c,0x17d0e,0x13cbc,0x17dbc,0x13c9e,0x17d9e,0x17cb8, // 870 - 0x1be5e,0x17c9c,0x17c8e,0x13c5e,0x17cde,0x17c5c,0x17c4e,0x17c2e,0x1c0b4,0x1c0b2, // 880 - 0x18174,0x18172,0x102f4,0x102f2,0x1e0da,0x1c09a,0x1c1ba,0x1813a,0x1837a,0x1027a, // 890 - 0x106fa,0x10ebe,0x11ebc,0x11e9e,0x13eb8,0x19f5e,0x13e9c,0x13e8e,0x11e5e,0x13ede, // 900 - 0x17eb0,0x1bf5c,0x17e98,0x1bf4e,0x17e8c,0x17e86,0x13e5c,0x17edc,0x13e4e,0x17ece, // 910 - 0x17e58,0x1bf2e,0x17e4c,0x17e46,0x13e2e,0x17e6e,0x17e2c,0x17e26,0x10f5e,0x11f5c, // 920 - 0x11f4e,0x13f58,0x19fae,0x13f4c,0x13f46,0x11f2e,0x13f6e,0x13f2c,0x13f26 // 929 - ), - array( // cluster 6 ----------------------------------------------------------------------- - 0x1abe0,0x1d5f8,0x153c0,0x1a9f0,0x1d4fc,0x151e0,0x1a8f8,0x1d47e,0x150f0,0x1a87c, // 10 - 0x15078,0x1fad0,0x15be0,0x1adf8,0x1fac8,0x159f0,0x1acfc,0x1fac4,0x158f8,0x1ac7e, // 20 - 0x1fac2,0x1587c,0x1f5d0,0x1faec,0x15df8,0x1f5c8,0x1fae6,0x15cfc,0x1f5c4,0x15c7e, // 30 - 0x1f5c2,0x1ebd0,0x1f5ec,0x1ebc8,0x1f5e6,0x1ebc4,0x1ebc2,0x1d7d0,0x1ebec,0x1d7c8, // 40 - 0x1ebe6,0x1d7c4,0x1d7c2,0x1afd0,0x1d7ec,0x1afc8,0x1d7e6,0x1afc4,0x14bc0,0x1a5f0, // 50 - 0x1d2fc,0x149e0,0x1a4f8,0x1d27e,0x148f0,0x1a47c,0x14878,0x1a43e,0x1483c,0x1fa68, // 60 - 0x14df0,0x1a6fc,0x1fa64,0x14cf8,0x1a67e,0x1fa62,0x14c7c,0x14c3e,0x1f4e8,0x1fa76, // 70 - 0x14efc,0x1f4e4,0x14e7e,0x1f4e2,0x1e9e8,0x1f4f6,0x1e9e4,0x1e9e2,0x1d3e8,0x1e9f6, // 80 - 0x1d3e4,0x1d3e2,0x1a7e8,0x1d3f6,0x1a7e4,0x1a7e2,0x145e0,0x1a2f8,0x1d17e,0x144f0, // 90 - 0x1a27c,0x14478,0x1a23e,0x1443c,0x1441e,0x1fa34,0x146f8,0x1a37e,0x1fa32,0x1467c, // 100 - 0x1463e,0x1f474,0x1477e,0x1f472,0x1e8f4,0x1e8f2,0x1d1f4,0x1d1f2,0x1a3f4,0x1a3f2, // 110 - 0x142f0,0x1a17c,0x14278,0x1a13e,0x1423c,0x1421e,0x1fa1a,0x1437c,0x1433e,0x1f43a, // 120 - 0x1e87a,0x1d0fa,0x14178,0x1a0be,0x1413c,0x1411e,0x141be,0x140bc,0x1409e,0x12bc0, // 130 - 0x195f0,0x1cafc,0x129e0,0x194f8,0x1ca7e,0x128f0,0x1947c,0x12878,0x1943e,0x1283c, // 140 - 0x1f968,0x12df0,0x196fc,0x1f964,0x12cf8,0x1967e,0x1f962,0x12c7c,0x12c3e,0x1f2e8, // 150 - 0x1f976,0x12efc,0x1f2e4,0x12e7e,0x1f2e2,0x1e5e8,0x1f2f6,0x1e5e4,0x1e5e2,0x1cbe8, // 160 - 0x1e5f6,0x1cbe4,0x1cbe2,0x197e8,0x1cbf6,0x197e4,0x197e2,0x1b5e0,0x1daf8,0x1ed7e, // 170 - 0x169c0,0x1b4f0,0x1da7c,0x168e0,0x1b478,0x1da3e,0x16870,0x1b43c,0x16838,0x1b41e, // 180 - 0x1681c,0x125e0,0x192f8,0x1c97e,0x16de0,0x124f0,0x1927c,0x16cf0,0x1b67c,0x1923e, // 190 - 0x16c78,0x1243c,0x16c3c,0x1241e,0x16c1e,0x1f934,0x126f8,0x1937e,0x1fb74,0x1f932, // 200 - 0x16ef8,0x1267c,0x1fb72,0x16e7c,0x1263e,0x16e3e,0x1f274,0x1277e,0x1f6f4,0x1f272, // 210 - 0x16f7e,0x1f6f2,0x1e4f4,0x1edf4,0x1e4f2,0x1edf2,0x1c9f4,0x1dbf4,0x1c9f2,0x1dbf2, // 220 - 0x193f4,0x193f2,0x165c0,0x1b2f0,0x1d97c,0x164e0,0x1b278,0x1d93e,0x16470,0x1b23c, // 230 - 0x16438,0x1b21e,0x1641c,0x1640e,0x122f0,0x1917c,0x166f0,0x12278,0x1913e,0x16678, // 240 - 0x1b33e,0x1663c,0x1221e,0x1661e,0x1f91a,0x1237c,0x1fb3a,0x1677c,0x1233e,0x1673e, // 250 - 0x1f23a,0x1f67a,0x1e47a,0x1ecfa,0x1c8fa,0x1d9fa,0x191fa,0x162e0,0x1b178,0x1d8be, // 260 - 0x16270,0x1b13c,0x16238,0x1b11e,0x1621c,0x1620e,0x12178,0x190be,0x16378,0x1213c, // 270 - 0x1633c,0x1211e,0x1631e,0x121be,0x163be,0x16170,0x1b0bc,0x16138,0x1b09e,0x1611c, // 280 - 0x1610e,0x120bc,0x161bc,0x1209e,0x1619e,0x160b8,0x1b05e,0x1609c,0x1608e,0x1205e, // 290 - 0x160de,0x1605c,0x1604e,0x115e0,0x18af8,0x1c57e,0x114f0,0x18a7c,0x11478,0x18a3e, // 300 - 0x1143c,0x1141e,0x1f8b4,0x116f8,0x18b7e,0x1f8b2,0x1167c,0x1163e,0x1f174,0x1177e, // 310 - 0x1f172,0x1e2f4,0x1e2f2,0x1c5f4,0x1c5f2,0x18bf4,0x18bf2,0x135c0,0x19af0,0x1cd7c, // 320 - 0x134e0,0x19a78,0x1cd3e,0x13470,0x19a3c,0x13438,0x19a1e,0x1341c,0x1340e,0x112f0, // 330 - 0x1897c,0x136f0,0x11278,0x1893e,0x13678,0x19b3e,0x1363c,0x1121e,0x1361e,0x1f89a, // 340 - 0x1137c,0x1f9ba,0x1377c,0x1133e,0x1373e,0x1f13a,0x1f37a,0x1e27a,0x1e6fa,0x1c4fa, // 350 - 0x1cdfa,0x189fa,0x1bae0,0x1dd78,0x1eebe,0x174c0,0x1ba70,0x1dd3c,0x17460,0x1ba38, // 360 - 0x1dd1e,0x17430,0x1ba1c,0x17418,0x1ba0e,0x1740c,0x132e0,0x19978,0x1ccbe,0x176e0, // 370 - 0x13270,0x1993c,0x17670,0x1bb3c,0x1991e,0x17638,0x1321c,0x1761c,0x1320e,0x1760e, // 380 - 0x11178,0x188be,0x13378,0x1113c,0x17778,0x1333c,0x1111e,0x1773c,0x1331e,0x1771e, // 390 - 0x111be,0x133be,0x177be,0x172c0,0x1b970,0x1dcbc,0x17260,0x1b938,0x1dc9e,0x17230, // 400 - 0x1b91c,0x17218,0x1b90e,0x1720c,0x17206,0x13170,0x198bc,0x17370,0x13138,0x1989e, // 410 - 0x17338,0x1b99e,0x1731c,0x1310e,0x1730e,0x110bc,0x131bc,0x1109e,0x173bc,0x1319e, // 420 - 0x1739e,0x17160,0x1b8b8,0x1dc5e,0x17130,0x1b89c,0x17118,0x1b88e,0x1710c,0x17106, // 430 - 0x130b8,0x1985e,0x171b8,0x1309c,0x1719c,0x1308e,0x1718e,0x1105e,0x130de,0x171de, // 440 - 0x170b0,0x1b85c,0x17098,0x1b84e,0x1708c,0x17086,0x1305c,0x170dc,0x1304e,0x170ce, // 450 - 0x17058,0x1b82e,0x1704c,0x17046,0x1302e,0x1706e,0x1702c,0x17026,0x10af0,0x1857c, // 460 - 0x10a78,0x1853e,0x10a3c,0x10a1e,0x10b7c,0x10b3e,0x1f0ba,0x1e17a,0x1c2fa,0x185fa, // 470 - 0x11ae0,0x18d78,0x1c6be,0x11a70,0x18d3c,0x11a38,0x18d1e,0x11a1c,0x11a0e,0x10978, // 480 - 0x184be,0x11b78,0x1093c,0x11b3c,0x1091e,0x11b1e,0x109be,0x11bbe,0x13ac0,0x19d70, // 490 - 0x1cebc,0x13a60,0x19d38,0x1ce9e,0x13a30,0x19d1c,0x13a18,0x19d0e,0x13a0c,0x13a06, // 500 - 0x11970,0x18cbc,0x13b70,0x11938,0x18c9e,0x13b38,0x1191c,0x13b1c,0x1190e,0x13b0e, // 510 - 0x108bc,0x119bc,0x1089e,0x13bbc,0x1199e,0x13b9e,0x1bd60,0x1deb8,0x1ef5e,0x17a40, // 520 - 0x1bd30,0x1de9c,0x17a20,0x1bd18,0x1de8e,0x17a10,0x1bd0c,0x17a08,0x1bd06,0x17a04, // 530 - 0x13960,0x19cb8,0x1ce5e,0x17b60,0x13930,0x19c9c,0x17b30,0x1bd9c,0x19c8e,0x17b18, // 540 - 0x1390c,0x17b0c,0x13906,0x17b06,0x118b8,0x18c5e,0x139b8,0x1189c,0x17bb8,0x1399c, // 550 - 0x1188e,0x17b9c,0x1398e,0x17b8e,0x1085e,0x118de,0x139de,0x17bde,0x17940,0x1bcb0, // 560 - 0x1de5c,0x17920,0x1bc98,0x1de4e,0x17910,0x1bc8c,0x17908,0x1bc86,0x17904,0x17902, // 570 - 0x138b0,0x19c5c,0x179b0,0x13898,0x19c4e,0x17998,0x1bcce,0x1798c,0x13886,0x17986, // 580 - 0x1185c,0x138dc,0x1184e,0x179dc,0x138ce,0x179ce,0x178a0,0x1bc58,0x1de2e,0x17890, // 590 - 0x1bc4c,0x17888,0x1bc46,0x17884,0x17882,0x13858,0x19c2e,0x178d8,0x1384c,0x178cc, // 600 - 0x13846,0x178c6,0x1182e,0x1386e,0x178ee,0x17850,0x1bc2c,0x17848,0x1bc26,0x17844, // 610 - 0x17842,0x1382c,0x1786c,0x13826,0x17866,0x17828,0x1bc16,0x17824,0x17822,0x13816, // 620 - 0x17836,0x10578,0x182be,0x1053c,0x1051e,0x105be,0x10d70,0x186bc,0x10d38,0x1869e, // 630 - 0x10d1c,0x10d0e,0x104bc,0x10dbc,0x1049e,0x10d9e,0x11d60,0x18eb8,0x1c75e,0x11d30, // 640 - 0x18e9c,0x11d18,0x18e8e,0x11d0c,0x11d06,0x10cb8,0x1865e,0x11db8,0x10c9c,0x11d9c, // 650 - 0x10c8e,0x11d8e,0x1045e,0x10cde,0x11dde,0x13d40,0x19eb0,0x1cf5c,0x13d20,0x19e98, // 660 - 0x1cf4e,0x13d10,0x19e8c,0x13d08,0x19e86,0x13d04,0x13d02,0x11cb0,0x18e5c,0x13db0, // 670 - 0x11c98,0x18e4e,0x13d98,0x19ece,0x13d8c,0x11c86,0x13d86,0x10c5c,0x11cdc,0x10c4e, // 680 - 0x13ddc,0x11cce,0x13dce,0x1bea0,0x1df58,0x1efae,0x1be90,0x1df4c,0x1be88,0x1df46, // 690 - 0x1be84,0x1be82,0x13ca0,0x19e58,0x1cf2e,0x17da0,0x13c90,0x19e4c,0x17d90,0x1becc, // 700 - 0x19e46,0x17d88,0x13c84,0x17d84,0x13c82,0x17d82,0x11c58,0x18e2e,0x13cd8,0x11c4c, // 710 - 0x17dd8,0x13ccc,0x11c46,0x17dcc,0x13cc6,0x17dc6,0x10c2e,0x11c6e,0x13cee,0x17dee, // 720 - 0x1be50,0x1df2c,0x1be48,0x1df26,0x1be44,0x1be42,0x13c50,0x19e2c,0x17cd0,0x13c48, // 730 - 0x19e26,0x17cc8,0x1be66,0x17cc4,0x13c42,0x17cc2,0x11c2c,0x13c6c,0x11c26,0x17cec, // 740 - 0x13c66,0x17ce6,0x1be28,0x1df16,0x1be24,0x1be22,0x13c28,0x19e16,0x17c68,0x13c24, // 750 - 0x17c64,0x13c22,0x17c62,0x11c16,0x13c36,0x17c76,0x1be14,0x1be12,0x13c14,0x17c34, // 760 - 0x13c12,0x17c32,0x102bc,0x1029e,0x106b8,0x1835e,0x1069c,0x1068e,0x1025e,0x106de, // 770 - 0x10eb0,0x1875c,0x10e98,0x1874e,0x10e8c,0x10e86,0x1065c,0x10edc,0x1064e,0x10ece, // 780 - 0x11ea0,0x18f58,0x1c7ae,0x11e90,0x18f4c,0x11e88,0x18f46,0x11e84,0x11e82,0x10e58, // 790 - 0x1872e,0x11ed8,0x18f6e,0x11ecc,0x10e46,0x11ec6,0x1062e,0x10e6e,0x11eee,0x19f50, // 800 - 0x1cfac,0x19f48,0x1cfa6,0x19f44,0x19f42,0x11e50,0x18f2c,0x13ed0,0x19f6c,0x18f26, // 810 - 0x13ec8,0x11e44,0x13ec4,0x11e42,0x13ec2,0x10e2c,0x11e6c,0x10e26,0x13eec,0x11e66, // 820 - 0x13ee6,0x1dfa8,0x1efd6,0x1dfa4,0x1dfa2,0x19f28,0x1cf96,0x1bf68,0x19f24,0x1bf64, // 830 - 0x19f22,0x1bf62,0x11e28,0x18f16,0x13e68,0x11e24,0x17ee8,0x13e64,0x11e22,0x17ee4, // 840 - 0x13e62,0x17ee2,0x10e16,0x11e36,0x13e76,0x17ef6,0x1df94,0x1df92,0x19f14,0x1bf34, // 850 - 0x19f12,0x1bf32,0x11e14,0x13e34,0x11e12,0x17e74,0x13e32,0x17e72,0x1df8a,0x19f0a, // 860 - 0x1bf1a,0x11e0a,0x13e1a,0x17e3a,0x1035c,0x1034e,0x10758,0x183ae,0x1074c,0x10746, // 870 - 0x1032e,0x1076e,0x10f50,0x187ac,0x10f48,0x187a6,0x10f44,0x10f42,0x1072c,0x10f6c, // 880 - 0x10726,0x10f66,0x18fa8,0x1c7d6,0x18fa4,0x18fa2,0x10f28,0x18796,0x11f68,0x18fb6, // 890 - 0x11f64,0x10f22,0x11f62,0x10716,0x10f36,0x11f76,0x1cfd4,0x1cfd2,0x18f94,0x19fb4, // 900 - 0x18f92,0x19fb2,0x10f14,0x11f34,0x10f12,0x13f74,0x11f32,0x13f72,0x1cfca,0x18f8a, // 910 - 0x19f9a,0x10f0a,0x11f1a,0x13f3a,0x103ac,0x103a6,0x107a8,0x183d6,0x107a4,0x107a2, // 920 - 0x10396,0x107b6,0x187d4,0x187d2,0x10794,0x10fb4,0x10792,0x10fb2,0x1c7ea // 929 - ) - ); + public const CLUSTERS = [[ + // cluster 0 ----------------------------------------------------------------------- + 0x1d5c0, + 0x1eaf0, + 0x1f57c, + 0x1d4e0, + 0x1ea78, + 0x1f53e, + 0x1a8c0, + 0x1d470, + 0x1a860, + 0x15040, + // 10 + 0x1a830, + 0x15020, + 0x1adc0, + 0x1d6f0, + 0x1eb7c, + 0x1ace0, + 0x1d678, + 0x1eb3e, + 0x158c0, + 0x1ac70, + // 20 + 0x15860, + 0x15dc0, + 0x1aef0, + 0x1d77c, + 0x15ce0, + 0x1ae78, + 0x1d73e, + 0x15c70, + 0x1ae3c, + 0x15ef0, + // 30 + 0x1af7c, + 0x15e78, + 0x1af3e, + 0x15f7c, + 0x1f5fa, + 0x1d2e0, + 0x1e978, + 0x1f4be, + 0x1a4c0, + 0x1d270, + // 40 + 0x1e93c, + 0x1a460, + 0x1d238, + 0x14840, + 0x1a430, + 0x1d21c, + 0x14820, + 0x1a418, + 0x14810, + 0x1a6e0, + // 50 + 0x1d378, + 0x1e9be, + 0x14cc0, + 0x1a670, + 0x1d33c, + 0x14c60, + 0x1a638, + 0x1d31e, + 0x14c30, + 0x1a61c, + // 60 + 0x14ee0, + 0x1a778, + 0x1d3be, + 0x14e70, + 0x1a73c, + 0x14e38, + 0x1a71e, + 0x14f78, + 0x1a7be, + 0x14f3c, + // 70 + 0x14f1e, + 0x1a2c0, + 0x1d170, + 0x1e8bc, + 0x1a260, + 0x1d138, + 0x1e89e, + 0x14440, + 0x1a230, + 0x1d11c, + // 80 + 0x14420, + 0x1a218, + 0x14410, + 0x14408, + 0x146c0, + 0x1a370, + 0x1d1bc, + 0x14660, + 0x1a338, + 0x1d19e, + // 90 + 0x14630, + 0x1a31c, + 0x14618, + 0x1460c, + 0x14770, + 0x1a3bc, + 0x14738, + 0x1a39e, + 0x1471c, + 0x147bc, + // 100 + 0x1a160, + 0x1d0b8, + 0x1e85e, + 0x14240, + 0x1a130, + 0x1d09c, + 0x14220, + 0x1a118, + 0x1d08e, + 0x14210, + // 110 + 0x1a10c, + 0x14208, + 0x1a106, + 0x14360, + 0x1a1b8, + 0x1d0de, + 0x14330, + 0x1a19c, + 0x14318, + 0x1a18e, + // 120 + 0x1430c, + 0x14306, + 0x1a1de, + 0x1438e, + 0x14140, + 0x1a0b0, + 0x1d05c, + 0x14120, + 0x1a098, + 0x1d04e, + // 130 + 0x14110, + 0x1a08c, + 0x14108, + 0x1a086, + 0x14104, + 0x141b0, + 0x14198, + 0x1418c, + 0x140a0, + 0x1d02e, + // 140 + 0x1a04c, + 0x1a046, + 0x14082, + 0x1cae0, + 0x1e578, + 0x1f2be, + 0x194c0, + 0x1ca70, + 0x1e53c, + 0x19460, + // 150 + 0x1ca38, + 0x1e51e, + 0x12840, + 0x19430, + 0x12820, + 0x196e0, + 0x1cb78, + 0x1e5be, + 0x12cc0, + 0x19670, + // 160 + 0x1cb3c, + 0x12c60, + 0x19638, + 0x12c30, + 0x12c18, + 0x12ee0, + 0x19778, + 0x1cbbe, + 0x12e70, + 0x1973c, + // 170 + 0x12e38, + 0x12e1c, + 0x12f78, + 0x197be, + 0x12f3c, + 0x12fbe, + 0x1dac0, + 0x1ed70, + 0x1f6bc, + 0x1da60, + // 180 + 0x1ed38, + 0x1f69e, + 0x1b440, + 0x1da30, + 0x1ed1c, + 0x1b420, + 0x1da18, + 0x1ed0e, + 0x1b410, + 0x1da0c, + // 190 + 0x192c0, + 0x1c970, + 0x1e4bc, + 0x1b6c0, + 0x19260, + 0x1c938, + 0x1e49e, + 0x1b660, + 0x1db38, + 0x1ed9e, + // 200 + 0x16c40, + 0x12420, + 0x19218, + 0x1c90e, + 0x16c20, + 0x1b618, + 0x16c10, + 0x126c0, + 0x19370, + 0x1c9bc, + // 210 + 0x16ec0, + 0x12660, + 0x19338, + 0x1c99e, + 0x16e60, + 0x1b738, + 0x1db9e, + 0x16e30, + 0x12618, + 0x16e18, + // 220 + 0x12770, + 0x193bc, + 0x16f70, + 0x12738, + 0x1939e, + 0x16f38, + 0x1b79e, + 0x16f1c, + 0x127bc, + 0x16fbc, + // 230 + 0x1279e, + 0x16f9e, + 0x1d960, + 0x1ecb8, + 0x1f65e, + 0x1b240, + 0x1d930, + 0x1ec9c, + 0x1b220, + 0x1d918, + // 240 + 0x1ec8e, + 0x1b210, + 0x1d90c, + 0x1b208, + 0x1b204, + 0x19160, + 0x1c8b8, + 0x1e45e, + 0x1b360, + 0x19130, + // 250 + 0x1c89c, + 0x16640, + 0x12220, + 0x1d99c, + 0x1c88e, + 0x16620, + 0x12210, + 0x1910c, + 0x16610, + 0x1b30c, + // 260 + 0x19106, + 0x12204, + 0x12360, + 0x191b8, + 0x1c8de, + 0x16760, + 0x12330, + 0x1919c, + 0x16730, + 0x1b39c, + // 270 + 0x1918e, + 0x16718, + 0x1230c, + 0x12306, + 0x123b8, + 0x191de, + 0x167b8, + 0x1239c, + 0x1679c, + 0x1238e, + // 280 + 0x1678e, + 0x167de, + 0x1b140, + 0x1d8b0, + 0x1ec5c, + 0x1b120, + 0x1d898, + 0x1ec4e, + 0x1b110, + 0x1d88c, + // 290 + 0x1b108, + 0x1d886, + 0x1b104, + 0x1b102, + 0x12140, + 0x190b0, + 0x1c85c, + 0x16340, + 0x12120, + 0x19098, + // 300 + 0x1c84e, + 0x16320, + 0x1b198, + 0x1d8ce, + 0x16310, + 0x12108, + 0x19086, + 0x16308, + 0x1b186, + 0x16304, + // 310 + 0x121b0, + 0x190dc, + 0x163b0, + 0x12198, + 0x190ce, + 0x16398, + 0x1b1ce, + 0x1638c, + 0x12186, + 0x16386, + // 320 + 0x163dc, + 0x163ce, + 0x1b0a0, + 0x1d858, + 0x1ec2e, + 0x1b090, + 0x1d84c, + 0x1b088, + 0x1d846, + 0x1b084, + // 330 + 0x1b082, + 0x120a0, + 0x19058, + 0x1c82e, + 0x161a0, + 0x12090, + 0x1904c, + 0x16190, + 0x1b0cc, + 0x19046, + // 340 + 0x16188, + 0x12084, + 0x16184, + 0x12082, + 0x120d8, + 0x161d8, + 0x161cc, + 0x161c6, + 0x1d82c, + 0x1d826, + // 350 + 0x1b042, + 0x1902c, + 0x12048, + 0x160c8, + 0x160c4, + 0x160c2, + 0x18ac0, + 0x1c570, + 0x1e2bc, + 0x18a60, + // 360 + 0x1c538, + 0x11440, + 0x18a30, + 0x1c51c, + 0x11420, + 0x18a18, + 0x11410, + 0x11408, + 0x116c0, + 0x18b70, + // 370 + 0x1c5bc, + 0x11660, + 0x18b38, + 0x1c59e, + 0x11630, + 0x18b1c, + 0x11618, + 0x1160c, + 0x11770, + 0x18bbc, + // 380 + 0x11738, + 0x18b9e, + 0x1171c, + 0x117bc, + 0x1179e, + 0x1cd60, + 0x1e6b8, + 0x1f35e, + 0x19a40, + 0x1cd30, + // 390 + 0x1e69c, + 0x19a20, + 0x1cd18, + 0x1e68e, + 0x19a10, + 0x1cd0c, + 0x19a08, + 0x1cd06, + 0x18960, + 0x1c4b8, + // 400 + 0x1e25e, + 0x19b60, + 0x18930, + 0x1c49c, + 0x13640, + 0x11220, + 0x1cd9c, + 0x1c48e, + 0x13620, + 0x19b18, + // 410 + 0x1890c, + 0x13610, + 0x11208, + 0x13608, + 0x11360, + 0x189b8, + 0x1c4de, + 0x13760, + 0x11330, + 0x1cdde, + // 420 + 0x13730, + 0x19b9c, + 0x1898e, + 0x13718, + 0x1130c, + 0x1370c, + 0x113b8, + 0x189de, + 0x137b8, + 0x1139c, + // 430 + 0x1379c, + 0x1138e, + 0x113de, + 0x137de, + 0x1dd40, + 0x1eeb0, + 0x1f75c, + 0x1dd20, + 0x1ee98, + 0x1f74e, + // 440 + 0x1dd10, + 0x1ee8c, + 0x1dd08, + 0x1ee86, + 0x1dd04, + 0x19940, + 0x1ccb0, + 0x1e65c, + 0x1bb40, + 0x19920, + // 450 + 0x1eedc, + 0x1e64e, + 0x1bb20, + 0x1dd98, + 0x1eece, + 0x1bb10, + 0x19908, + 0x1cc86, + 0x1bb08, + 0x1dd86, + // 460 + 0x19902, + 0x11140, + 0x188b0, + 0x1c45c, + 0x13340, + 0x11120, + 0x18898, + 0x1c44e, + 0x17740, + 0x13320, + // 470 + 0x19998, + 0x1ccce, + 0x17720, + 0x1bb98, + 0x1ddce, + 0x18886, + 0x17710, + 0x13308, + 0x19986, + 0x17708, + // 480 + 0x11102, + 0x111b0, + 0x188dc, + 0x133b0, + 0x11198, + 0x188ce, + 0x177b0, + 0x13398, + 0x199ce, + 0x17798, + // 490 + 0x1bbce, + 0x11186, + 0x13386, + 0x111dc, + 0x133dc, + 0x111ce, + 0x177dc, + 0x133ce, + 0x1dca0, + 0x1ee58, + // 500 + 0x1f72e, + 0x1dc90, + 0x1ee4c, + 0x1dc88, + 0x1ee46, + 0x1dc84, + 0x1dc82, + 0x198a0, + 0x1cc58, + 0x1e62e, + // 510 + 0x1b9a0, + 0x19890, + 0x1ee6e, + 0x1b990, + 0x1dccc, + 0x1cc46, + 0x1b988, + 0x19884, + 0x1b984, + 0x19882, + // 520 + 0x1b982, + 0x110a0, + 0x18858, + 0x1c42e, + 0x131a0, + 0x11090, + 0x1884c, + 0x173a0, + 0x13190, + 0x198cc, + // 530 + 0x18846, + 0x17390, + 0x1b9cc, + 0x11084, + 0x17388, + 0x13184, + 0x11082, + 0x13182, + 0x110d8, + 0x1886e, + // 540 + 0x131d8, + 0x110cc, + 0x173d8, + 0x131cc, + 0x110c6, + 0x173cc, + 0x131c6, + 0x110ee, + 0x173ee, + 0x1dc50, + // 550 + 0x1ee2c, + 0x1dc48, + 0x1ee26, + 0x1dc44, + 0x1dc42, + 0x19850, + 0x1cc2c, + 0x1b8d0, + 0x19848, + 0x1cc26, + // 560 + 0x1b8c8, + 0x1dc66, + 0x1b8c4, + 0x19842, + 0x1b8c2, + 0x11050, + 0x1882c, + 0x130d0, + 0x11048, + 0x18826, + // 570 + 0x171d0, + 0x130c8, + 0x19866, + 0x171c8, + 0x1b8e6, + 0x11042, + 0x171c4, + 0x130c2, + 0x171c2, + 0x130ec, + // 580 + 0x171ec, + 0x171e6, + 0x1ee16, + 0x1dc22, + 0x1cc16, + 0x19824, + 0x19822, + 0x11028, + 0x13068, + 0x170e8, + // 590 + 0x11022, + 0x13062, + 0x18560, + 0x10a40, + 0x18530, + 0x10a20, + 0x18518, + 0x1c28e, + 0x10a10, + 0x1850c, + // 600 + 0x10a08, + 0x18506, + 0x10b60, + 0x185b8, + 0x1c2de, + 0x10b30, + 0x1859c, + 0x10b18, + 0x1858e, + 0x10b0c, + // 610 + 0x10b06, + 0x10bb8, + 0x185de, + 0x10b9c, + 0x10b8e, + 0x10bde, + 0x18d40, + 0x1c6b0, + 0x1e35c, + 0x18d20, + // 620 + 0x1c698, + 0x18d10, + 0x1c68c, + 0x18d08, + 0x1c686, + 0x18d04, + 0x10940, + 0x184b0, + 0x1c25c, + 0x11b40, + // 630 + 0x10920, + 0x1c6dc, + 0x1c24e, + 0x11b20, + 0x18d98, + 0x1c6ce, + 0x11b10, + 0x10908, + 0x18486, + 0x11b08, + // 640 + 0x18d86, + 0x10902, + 0x109b0, + 0x184dc, + 0x11bb0, + 0x10998, + 0x184ce, + 0x11b98, + 0x18dce, + 0x11b8c, + // 650 + 0x10986, + 0x109dc, + 0x11bdc, + 0x109ce, + 0x11bce, + 0x1cea0, + 0x1e758, + 0x1f3ae, + 0x1ce90, + 0x1e74c, + // 660 + 0x1ce88, + 0x1e746, + 0x1ce84, + 0x1ce82, + 0x18ca0, + 0x1c658, + 0x19da0, + 0x18c90, + 0x1c64c, + 0x19d90, + // 670 + 0x1cecc, + 0x1c646, + 0x19d88, + 0x18c84, + 0x19d84, + 0x18c82, + 0x19d82, + 0x108a0, + 0x18458, + 0x119a0, + // 680 + 0x10890, + 0x1c66e, + 0x13ba0, + 0x11990, + 0x18ccc, + 0x18446, + 0x13b90, + 0x19dcc, + 0x10884, + 0x13b88, + // 690 + 0x11984, + 0x10882, + 0x11982, + 0x108d8, + 0x1846e, + 0x119d8, + 0x108cc, + 0x13bd8, + 0x119cc, + 0x108c6, + // 700 + 0x13bcc, + 0x119c6, + 0x108ee, + 0x119ee, + 0x13bee, + 0x1ef50, + 0x1f7ac, + 0x1ef48, + 0x1f7a6, + 0x1ef44, + // 710 + 0x1ef42, + 0x1ce50, + 0x1e72c, + 0x1ded0, + 0x1ef6c, + 0x1e726, + 0x1dec8, + 0x1ef66, + 0x1dec4, + 0x1ce42, + // 720 + 0x1dec2, + 0x18c50, + 0x1c62c, + 0x19cd0, + 0x18c48, + 0x1c626, + 0x1bdd0, + 0x19cc8, + 0x1ce66, + 0x1bdc8, + // 730 + 0x1dee6, + 0x18c42, + 0x1bdc4, + 0x19cc2, + 0x1bdc2, + 0x10850, + 0x1842c, + 0x118d0, + 0x10848, + 0x18426, + // 740 + 0x139d0, + 0x118c8, + 0x18c66, + 0x17bd0, + 0x139c8, + 0x19ce6, + 0x10842, + 0x17bc8, + 0x1bde6, + 0x118c2, + // 750 + 0x17bc4, + 0x1086c, + 0x118ec, + 0x10866, + 0x139ec, + 0x118e6, + 0x17bec, + 0x139e6, + 0x17be6, + 0x1ef28, + // 760 + 0x1f796, + 0x1ef24, + 0x1ef22, + 0x1ce28, + 0x1e716, + 0x1de68, + 0x1ef36, + 0x1de64, + 0x1ce22, + 0x1de62, + // 770 + 0x18c28, + 0x1c616, + 0x19c68, + 0x18c24, + 0x1bce8, + 0x19c64, + 0x18c22, + 0x1bce4, + 0x19c62, + 0x1bce2, + // 780 + 0x10828, + 0x18416, + 0x11868, + 0x18c36, + 0x138e8, + 0x11864, + 0x10822, + 0x179e8, + 0x138e4, + 0x11862, + // 790 + 0x179e4, + 0x138e2, + 0x179e2, + 0x11876, + 0x179f6, + 0x1ef12, + 0x1de34, + 0x1de32, + 0x19c34, + 0x1bc74, + // 800 + 0x1bc72, + 0x11834, + 0x13874, + 0x178f4, + 0x178f2, + 0x10540, + 0x10520, + 0x18298, + 0x10510, + 0x10508, + // 810 + 0x10504, + 0x105b0, + 0x10598, + 0x1058c, + 0x10586, + 0x105dc, + 0x105ce, + 0x186a0, + 0x18690, + 0x1c34c, + // 820 + 0x18688, + 0x1c346, + 0x18684, + 0x18682, + 0x104a0, + 0x18258, + 0x10da0, + 0x186d8, + 0x1824c, + 0x10d90, + // 830 + 0x186cc, + 0x10d88, + 0x186c6, + 0x10d84, + 0x10482, + 0x10d82, + 0x104d8, + 0x1826e, + 0x10dd8, + 0x186ee, + // 840 + 0x10dcc, + 0x104c6, + 0x10dc6, + 0x104ee, + 0x10dee, + 0x1c750, + 0x1c748, + 0x1c744, + 0x1c742, + 0x18650, + // 850 + 0x18ed0, + 0x1c76c, + 0x1c326, + 0x18ec8, + 0x1c766, + 0x18ec4, + 0x18642, + 0x18ec2, + 0x10450, + 0x10cd0, + // 860 + 0x10448, + 0x18226, + 0x11dd0, + 0x10cc8, + 0x10444, + 0x11dc8, + 0x10cc4, + 0x10442, + 0x11dc4, + 0x10cc2, + // 870 + 0x1046c, + 0x10cec, + 0x10466, + 0x11dec, + 0x10ce6, + 0x11de6, + 0x1e7a8, + 0x1e7a4, + 0x1e7a2, + 0x1c728, + // 880 + 0x1cf68, + 0x1e7b6, + 0x1cf64, + 0x1c722, + 0x1cf62, + 0x18628, + 0x1c316, + 0x18e68, + 0x1c736, + 0x19ee8, + // 890 + 0x18e64, + 0x18622, + 0x19ee4, + 0x18e62, + 0x19ee2, + 0x10428, + 0x18216, + 0x10c68, + 0x18636, + 0x11ce8, + // 900 + 0x10c64, + 0x10422, + 0x13de8, + 0x11ce4, + 0x10c62, + 0x13de4, + 0x11ce2, + 0x10436, + 0x10c76, + 0x11cf6, + // 910 + 0x13df6, + 0x1f7d4, + 0x1f7d2, + 0x1e794, + 0x1efb4, + 0x1e792, + 0x1efb2, + 0x1c714, + 0x1cf34, + 0x1c712, + // 920 + 0x1df74, + 0x1cf32, + 0x1df72, + 0x18614, + 0x18e34, + 0x18612, + 0x19e74, + 0x18e32, + 0x1bef4, + ], [ + // cluster 3 ----------------------------------------------------------------------- + 0x1f560, + 0x1fab8, + 0x1ea40, + 0x1f530, + 0x1fa9c, + 0x1ea20, + 0x1f518, + 0x1fa8e, + 0x1ea10, + 0x1f50c, + // 10 + 0x1ea08, + 0x1f506, + 0x1ea04, + 0x1eb60, + 0x1f5b8, + 0x1fade, + 0x1d640, + 0x1eb30, + 0x1f59c, + 0x1d620, + // 20 + 0x1eb18, + 0x1f58e, + 0x1d610, + 0x1eb0c, + 0x1d608, + 0x1eb06, + 0x1d604, + 0x1d760, + 0x1ebb8, + 0x1f5de, + // 30 + 0x1ae40, + 0x1d730, + 0x1eb9c, + 0x1ae20, + 0x1d718, + 0x1eb8e, + 0x1ae10, + 0x1d70c, + 0x1ae08, + 0x1d706, + // 40 + 0x1ae04, + 0x1af60, + 0x1d7b8, + 0x1ebde, + 0x15e40, + 0x1af30, + 0x1d79c, + 0x15e20, + 0x1af18, + 0x1d78e, + // 50 + 0x15e10, + 0x1af0c, + 0x15e08, + 0x1af06, + 0x15f60, + 0x1afb8, + 0x1d7de, + 0x15f30, + 0x1af9c, + 0x15f18, + // 60 + 0x1af8e, + 0x15f0c, + 0x15fb8, + 0x1afde, + 0x15f9c, + 0x15f8e, + 0x1e940, + 0x1f4b0, + 0x1fa5c, + 0x1e920, + // 70 + 0x1f498, + 0x1fa4e, + 0x1e910, + 0x1f48c, + 0x1e908, + 0x1f486, + 0x1e904, + 0x1e902, + 0x1d340, + 0x1e9b0, + // 80 + 0x1f4dc, + 0x1d320, + 0x1e998, + 0x1f4ce, + 0x1d310, + 0x1e98c, + 0x1d308, + 0x1e986, + 0x1d304, + 0x1d302, + // 90 + 0x1a740, + 0x1d3b0, + 0x1e9dc, + 0x1a720, + 0x1d398, + 0x1e9ce, + 0x1a710, + 0x1d38c, + 0x1a708, + 0x1d386, + // 100 + 0x1a704, + 0x1a702, + 0x14f40, + 0x1a7b0, + 0x1d3dc, + 0x14f20, + 0x1a798, + 0x1d3ce, + 0x14f10, + 0x1a78c, + // 110 + 0x14f08, + 0x1a786, + 0x14f04, + 0x14fb0, + 0x1a7dc, + 0x14f98, + 0x1a7ce, + 0x14f8c, + 0x14f86, + 0x14fdc, + // 120 + 0x14fce, + 0x1e8a0, + 0x1f458, + 0x1fa2e, + 0x1e890, + 0x1f44c, + 0x1e888, + 0x1f446, + 0x1e884, + 0x1e882, + // 130 + 0x1d1a0, + 0x1e8d8, + 0x1f46e, + 0x1d190, + 0x1e8cc, + 0x1d188, + 0x1e8c6, + 0x1d184, + 0x1d182, + 0x1a3a0, + // 140 + 0x1d1d8, + 0x1e8ee, + 0x1a390, + 0x1d1cc, + 0x1a388, + 0x1d1c6, + 0x1a384, + 0x1a382, + 0x147a0, + 0x1a3d8, + // 150 + 0x1d1ee, + 0x14790, + 0x1a3cc, + 0x14788, + 0x1a3c6, + 0x14784, + 0x14782, + 0x147d8, + 0x1a3ee, + 0x147cc, + // 160 + 0x147c6, + 0x147ee, + 0x1e850, + 0x1f42c, + 0x1e848, + 0x1f426, + 0x1e844, + 0x1e842, + 0x1d0d0, + 0x1e86c, + // 170 + 0x1d0c8, + 0x1e866, + 0x1d0c4, + 0x1d0c2, + 0x1a1d0, + 0x1d0ec, + 0x1a1c8, + 0x1d0e6, + 0x1a1c4, + 0x1a1c2, + // 180 + 0x143d0, + 0x1a1ec, + 0x143c8, + 0x1a1e6, + 0x143c4, + 0x143c2, + 0x143ec, + 0x143e6, + 0x1e828, + 0x1f416, + // 190 + 0x1e824, + 0x1e822, + 0x1d068, + 0x1e836, + 0x1d064, + 0x1d062, + 0x1a0e8, + 0x1d076, + 0x1a0e4, + 0x1a0e2, + // 200 + 0x141e8, + 0x1a0f6, + 0x141e4, + 0x141e2, + 0x1e814, + 0x1e812, + 0x1d034, + 0x1d032, + 0x1a074, + 0x1a072, + // 210 + 0x1e540, + 0x1f2b0, + 0x1f95c, + 0x1e520, + 0x1f298, + 0x1f94e, + 0x1e510, + 0x1f28c, + 0x1e508, + 0x1f286, + // 220 + 0x1e504, + 0x1e502, + 0x1cb40, + 0x1e5b0, + 0x1f2dc, + 0x1cb20, + 0x1e598, + 0x1f2ce, + 0x1cb10, + 0x1e58c, + // 230 + 0x1cb08, + 0x1e586, + 0x1cb04, + 0x1cb02, + 0x19740, + 0x1cbb0, + 0x1e5dc, + 0x19720, + 0x1cb98, + 0x1e5ce, + // 240 + 0x19710, + 0x1cb8c, + 0x19708, + 0x1cb86, + 0x19704, + 0x19702, + 0x12f40, + 0x197b0, + 0x1cbdc, + 0x12f20, + // 250 + 0x19798, + 0x1cbce, + 0x12f10, + 0x1978c, + 0x12f08, + 0x19786, + 0x12f04, + 0x12fb0, + 0x197dc, + 0x12f98, + // 260 + 0x197ce, + 0x12f8c, + 0x12f86, + 0x12fdc, + 0x12fce, + 0x1f6a0, + 0x1fb58, + 0x16bf0, + 0x1f690, + 0x1fb4c, + // 270 + 0x169f8, + 0x1f688, + 0x1fb46, + 0x168fc, + 0x1f684, + 0x1f682, + 0x1e4a0, + 0x1f258, + 0x1f92e, + 0x1eda0, + // 280 + 0x1e490, + 0x1fb6e, + 0x1ed90, + 0x1f6cc, + 0x1f246, + 0x1ed88, + 0x1e484, + 0x1ed84, + 0x1e482, + 0x1ed82, + // 290 + 0x1c9a0, + 0x1e4d8, + 0x1f26e, + 0x1dba0, + 0x1c990, + 0x1e4cc, + 0x1db90, + 0x1edcc, + 0x1e4c6, + 0x1db88, + // 300 + 0x1c984, + 0x1db84, + 0x1c982, + 0x1db82, + 0x193a0, + 0x1c9d8, + 0x1e4ee, + 0x1b7a0, + 0x19390, + 0x1c9cc, + // 310 + 0x1b790, + 0x1dbcc, + 0x1c9c6, + 0x1b788, + 0x19384, + 0x1b784, + 0x19382, + 0x1b782, + 0x127a0, + 0x193d8, + // 320 + 0x1c9ee, + 0x16fa0, + 0x12790, + 0x193cc, + 0x16f90, + 0x1b7cc, + 0x193c6, + 0x16f88, + 0x12784, + 0x16f84, + // 330 + 0x12782, + 0x127d8, + 0x193ee, + 0x16fd8, + 0x127cc, + 0x16fcc, + 0x127c6, + 0x16fc6, + 0x127ee, + 0x1f650, + // 340 + 0x1fb2c, + 0x165f8, + 0x1f648, + 0x1fb26, + 0x164fc, + 0x1f644, + 0x1647e, + 0x1f642, + 0x1e450, + 0x1f22c, + // 350 + 0x1ecd0, + 0x1e448, + 0x1f226, + 0x1ecc8, + 0x1f666, + 0x1ecc4, + 0x1e442, + 0x1ecc2, + 0x1c8d0, + 0x1e46c, + // 360 + 0x1d9d0, + 0x1c8c8, + 0x1e466, + 0x1d9c8, + 0x1ece6, + 0x1d9c4, + 0x1c8c2, + 0x1d9c2, + 0x191d0, + 0x1c8ec, + // 370 + 0x1b3d0, + 0x191c8, + 0x1c8e6, + 0x1b3c8, + 0x1d9e6, + 0x1b3c4, + 0x191c2, + 0x1b3c2, + 0x123d0, + 0x191ec, + // 380 + 0x167d0, + 0x123c8, + 0x191e6, + 0x167c8, + 0x1b3e6, + 0x167c4, + 0x123c2, + 0x167c2, + 0x123ec, + 0x167ec, + // 390 + 0x123e6, + 0x167e6, + 0x1f628, + 0x1fb16, + 0x162fc, + 0x1f624, + 0x1627e, + 0x1f622, + 0x1e428, + 0x1f216, + // 400 + 0x1ec68, + 0x1f636, + 0x1ec64, + 0x1e422, + 0x1ec62, + 0x1c868, + 0x1e436, + 0x1d8e8, + 0x1c864, + 0x1d8e4, + // 410 + 0x1c862, + 0x1d8e2, + 0x190e8, + 0x1c876, + 0x1b1e8, + 0x1d8f6, + 0x1b1e4, + 0x190e2, + 0x1b1e2, + 0x121e8, + // 420 + 0x190f6, + 0x163e8, + 0x121e4, + 0x163e4, + 0x121e2, + 0x163e2, + 0x121f6, + 0x163f6, + 0x1f614, + 0x1617e, + // 430 + 0x1f612, + 0x1e414, + 0x1ec34, + 0x1e412, + 0x1ec32, + 0x1c834, + 0x1d874, + 0x1c832, + 0x1d872, + 0x19074, + // 440 + 0x1b0f4, + 0x19072, + 0x1b0f2, + 0x120f4, + 0x161f4, + 0x120f2, + 0x161f2, + 0x1f60a, + 0x1e40a, + 0x1ec1a, + // 450 + 0x1c81a, + 0x1d83a, + 0x1903a, + 0x1b07a, + 0x1e2a0, + 0x1f158, + 0x1f8ae, + 0x1e290, + 0x1f14c, + 0x1e288, + // 460 + 0x1f146, + 0x1e284, + 0x1e282, + 0x1c5a0, + 0x1e2d8, + 0x1f16e, + 0x1c590, + 0x1e2cc, + 0x1c588, + 0x1e2c6, + // 470 + 0x1c584, + 0x1c582, + 0x18ba0, + 0x1c5d8, + 0x1e2ee, + 0x18b90, + 0x1c5cc, + 0x18b88, + 0x1c5c6, + 0x18b84, + // 480 + 0x18b82, + 0x117a0, + 0x18bd8, + 0x1c5ee, + 0x11790, + 0x18bcc, + 0x11788, + 0x18bc6, + 0x11784, + 0x11782, + // 490 + 0x117d8, + 0x18bee, + 0x117cc, + 0x117c6, + 0x117ee, + 0x1f350, + 0x1f9ac, + 0x135f8, + 0x1f348, + 0x1f9a6, + // 500 + 0x134fc, + 0x1f344, + 0x1347e, + 0x1f342, + 0x1e250, + 0x1f12c, + 0x1e6d0, + 0x1e248, + 0x1f126, + 0x1e6c8, + // 510 + 0x1f366, + 0x1e6c4, + 0x1e242, + 0x1e6c2, + 0x1c4d0, + 0x1e26c, + 0x1cdd0, + 0x1c4c8, + 0x1e266, + 0x1cdc8, + // 520 + 0x1e6e6, + 0x1cdc4, + 0x1c4c2, + 0x1cdc2, + 0x189d0, + 0x1c4ec, + 0x19bd0, + 0x189c8, + 0x1c4e6, + 0x19bc8, + // 530 + 0x1cde6, + 0x19bc4, + 0x189c2, + 0x19bc2, + 0x113d0, + 0x189ec, + 0x137d0, + 0x113c8, + 0x189e6, + 0x137c8, + // 540 + 0x19be6, + 0x137c4, + 0x113c2, + 0x137c2, + 0x113ec, + 0x137ec, + 0x113e6, + 0x137e6, + 0x1fba8, + 0x175f0, + // 550 + 0x1bafc, + 0x1fba4, + 0x174f8, + 0x1ba7e, + 0x1fba2, + 0x1747c, + 0x1743e, + 0x1f328, + 0x1f996, + 0x132fc, + // 560 + 0x1f768, + 0x1fbb6, + 0x176fc, + 0x1327e, + 0x1f764, + 0x1f322, + 0x1767e, + 0x1f762, + 0x1e228, + 0x1f116, + // 570 + 0x1e668, + 0x1e224, + 0x1eee8, + 0x1f776, + 0x1e222, + 0x1eee4, + 0x1e662, + 0x1eee2, + 0x1c468, + 0x1e236, + // 580 + 0x1cce8, + 0x1c464, + 0x1dde8, + 0x1cce4, + 0x1c462, + 0x1dde4, + 0x1cce2, + 0x1dde2, + 0x188e8, + 0x1c476, + // 590 + 0x199e8, + 0x188e4, + 0x1bbe8, + 0x199e4, + 0x188e2, + 0x1bbe4, + 0x199e2, + 0x1bbe2, + 0x111e8, + 0x188f6, + // 600 + 0x133e8, + 0x111e4, + 0x177e8, + 0x133e4, + 0x111e2, + 0x177e4, + 0x133e2, + 0x177e2, + 0x111f6, + 0x133f6, + // 610 + 0x1fb94, + 0x172f8, + 0x1b97e, + 0x1fb92, + 0x1727c, + 0x1723e, + 0x1f314, + 0x1317e, + 0x1f734, + 0x1f312, + // 620 + 0x1737e, + 0x1f732, + 0x1e214, + 0x1e634, + 0x1e212, + 0x1ee74, + 0x1e632, + 0x1ee72, + 0x1c434, + 0x1cc74, + // 630 + 0x1c432, + 0x1dcf4, + 0x1cc72, + 0x1dcf2, + 0x18874, + 0x198f4, + 0x18872, + 0x1b9f4, + 0x198f2, + 0x1b9f2, + // 640 + 0x110f4, + 0x131f4, + 0x110f2, + 0x173f4, + 0x131f2, + 0x173f2, + 0x1fb8a, + 0x1717c, + 0x1713e, + 0x1f30a, + // 650 + 0x1f71a, + 0x1e20a, + 0x1e61a, + 0x1ee3a, + 0x1c41a, + 0x1cc3a, + 0x1dc7a, + 0x1883a, + 0x1987a, + 0x1b8fa, + // 660 + 0x1107a, + 0x130fa, + 0x171fa, + 0x170be, + 0x1e150, + 0x1f0ac, + 0x1e148, + 0x1f0a6, + 0x1e144, + 0x1e142, + // 670 + 0x1c2d0, + 0x1e16c, + 0x1c2c8, + 0x1e166, + 0x1c2c4, + 0x1c2c2, + 0x185d0, + 0x1c2ec, + 0x185c8, + 0x1c2e6, + // 680 + 0x185c4, + 0x185c2, + 0x10bd0, + 0x185ec, + 0x10bc8, + 0x185e6, + 0x10bc4, + 0x10bc2, + 0x10bec, + 0x10be6, + // 690 + 0x1f1a8, + 0x1f8d6, + 0x11afc, + 0x1f1a4, + 0x11a7e, + 0x1f1a2, + 0x1e128, + 0x1f096, + 0x1e368, + 0x1e124, + // 700 + 0x1e364, + 0x1e122, + 0x1e362, + 0x1c268, + 0x1e136, + 0x1c6e8, + 0x1c264, + 0x1c6e4, + 0x1c262, + 0x1c6e2, + // 710 + 0x184e8, + 0x1c276, + 0x18de8, + 0x184e4, + 0x18de4, + 0x184e2, + 0x18de2, + 0x109e8, + 0x184f6, + 0x11be8, + // 720 + 0x109e4, + 0x11be4, + 0x109e2, + 0x11be2, + 0x109f6, + 0x11bf6, + 0x1f9d4, + 0x13af8, + 0x19d7e, + 0x1f9d2, + // 730 + 0x13a7c, + 0x13a3e, + 0x1f194, + 0x1197e, + 0x1f3b4, + 0x1f192, + 0x13b7e, + 0x1f3b2, + 0x1e114, + 0x1e334, + // 740 + 0x1e112, + 0x1e774, + 0x1e332, + 0x1e772, + 0x1c234, + 0x1c674, + 0x1c232, + 0x1cef4, + 0x1c672, + 0x1cef2, + // 750 + 0x18474, + 0x18cf4, + 0x18472, + 0x19df4, + 0x18cf2, + 0x19df2, + 0x108f4, + 0x119f4, + 0x108f2, + 0x13bf4, + // 760 + 0x119f2, + 0x13bf2, + 0x17af0, + 0x1bd7c, + 0x17a78, + 0x1bd3e, + 0x17a3c, + 0x17a1e, + 0x1f9ca, + 0x1397c, + // 770 + 0x1fbda, + 0x17b7c, + 0x1393e, + 0x17b3e, + 0x1f18a, + 0x1f39a, + 0x1f7ba, + 0x1e10a, + 0x1e31a, + 0x1e73a, + // 780 + 0x1ef7a, + 0x1c21a, + 0x1c63a, + 0x1ce7a, + 0x1defa, + 0x1843a, + 0x18c7a, + 0x19cfa, + 0x1bdfa, + 0x1087a, + // 790 + 0x118fa, + 0x139fa, + 0x17978, + 0x1bcbe, + 0x1793c, + 0x1791e, + 0x138be, + 0x179be, + 0x178bc, + 0x1789e, + // 800 + 0x1785e, + 0x1e0a8, + 0x1e0a4, + 0x1e0a2, + 0x1c168, + 0x1e0b6, + 0x1c164, + 0x1c162, + 0x182e8, + 0x1c176, + // 810 + 0x182e4, + 0x182e2, + 0x105e8, + 0x182f6, + 0x105e4, + 0x105e2, + 0x105f6, + 0x1f0d4, + 0x10d7e, + 0x1f0d2, + // 820 + 0x1e094, + 0x1e1b4, + 0x1e092, + 0x1e1b2, + 0x1c134, + 0x1c374, + 0x1c132, + 0x1c372, + 0x18274, + 0x186f4, + // 830 + 0x18272, + 0x186f2, + 0x104f4, + 0x10df4, + 0x104f2, + 0x10df2, + 0x1f8ea, + 0x11d7c, + 0x11d3e, + 0x1f0ca, + // 840 + 0x1f1da, + 0x1e08a, + 0x1e19a, + 0x1e3ba, + 0x1c11a, + 0x1c33a, + 0x1c77a, + 0x1823a, + 0x1867a, + 0x18efa, + // 850 + 0x1047a, + 0x10cfa, + 0x11dfa, + 0x13d78, + 0x19ebe, + 0x13d3c, + 0x13d1e, + 0x11cbe, + 0x13dbe, + 0x17d70, + // 860 + 0x1bebc, + 0x17d38, + 0x1be9e, + 0x17d1c, + 0x17d0e, + 0x13cbc, + 0x17dbc, + 0x13c9e, + 0x17d9e, + 0x17cb8, + // 870 + 0x1be5e, + 0x17c9c, + 0x17c8e, + 0x13c5e, + 0x17cde, + 0x17c5c, + 0x17c4e, + 0x17c2e, + 0x1c0b4, + 0x1c0b2, + // 880 + 0x18174, + 0x18172, + 0x102f4, + 0x102f2, + 0x1e0da, + 0x1c09a, + 0x1c1ba, + 0x1813a, + 0x1837a, + 0x1027a, + // 890 + 0x106fa, + 0x10ebe, + 0x11ebc, + 0x11e9e, + 0x13eb8, + 0x19f5e, + 0x13e9c, + 0x13e8e, + 0x11e5e, + 0x13ede, + // 900 + 0x17eb0, + 0x1bf5c, + 0x17e98, + 0x1bf4e, + 0x17e8c, + 0x17e86, + 0x13e5c, + 0x17edc, + 0x13e4e, + 0x17ece, + // 910 + 0x17e58, + 0x1bf2e, + 0x17e4c, + 0x17e46, + 0x13e2e, + 0x17e6e, + 0x17e2c, + 0x17e26, + 0x10f5e, + 0x11f5c, + // 920 + 0x11f4e, + 0x13f58, + 0x19fae, + 0x13f4c, + 0x13f46, + 0x11f2e, + 0x13f6e, + 0x13f2c, + 0x13f26, + ], [ + // cluster 6 ----------------------------------------------------------------------- + 0x1abe0, + 0x1d5f8, + 0x153c0, + 0x1a9f0, + 0x1d4fc, + 0x151e0, + 0x1a8f8, + 0x1d47e, + 0x150f0, + 0x1a87c, + // 10 + 0x15078, + 0x1fad0, + 0x15be0, + 0x1adf8, + 0x1fac8, + 0x159f0, + 0x1acfc, + 0x1fac4, + 0x158f8, + 0x1ac7e, + // 20 + 0x1fac2, + 0x1587c, + 0x1f5d0, + 0x1faec, + 0x15df8, + 0x1f5c8, + 0x1fae6, + 0x15cfc, + 0x1f5c4, + 0x15c7e, + // 30 + 0x1f5c2, + 0x1ebd0, + 0x1f5ec, + 0x1ebc8, + 0x1f5e6, + 0x1ebc4, + 0x1ebc2, + 0x1d7d0, + 0x1ebec, + 0x1d7c8, + // 40 + 0x1ebe6, + 0x1d7c4, + 0x1d7c2, + 0x1afd0, + 0x1d7ec, + 0x1afc8, + 0x1d7e6, + 0x1afc4, + 0x14bc0, + 0x1a5f0, + // 50 + 0x1d2fc, + 0x149e0, + 0x1a4f8, + 0x1d27e, + 0x148f0, + 0x1a47c, + 0x14878, + 0x1a43e, + 0x1483c, + 0x1fa68, + // 60 + 0x14df0, + 0x1a6fc, + 0x1fa64, + 0x14cf8, + 0x1a67e, + 0x1fa62, + 0x14c7c, + 0x14c3e, + 0x1f4e8, + 0x1fa76, + // 70 + 0x14efc, + 0x1f4e4, + 0x14e7e, + 0x1f4e2, + 0x1e9e8, + 0x1f4f6, + 0x1e9e4, + 0x1e9e2, + 0x1d3e8, + 0x1e9f6, + // 80 + 0x1d3e4, + 0x1d3e2, + 0x1a7e8, + 0x1d3f6, + 0x1a7e4, + 0x1a7e2, + 0x145e0, + 0x1a2f8, + 0x1d17e, + 0x144f0, + // 90 + 0x1a27c, + 0x14478, + 0x1a23e, + 0x1443c, + 0x1441e, + 0x1fa34, + 0x146f8, + 0x1a37e, + 0x1fa32, + 0x1467c, + // 100 + 0x1463e, + 0x1f474, + 0x1477e, + 0x1f472, + 0x1e8f4, + 0x1e8f2, + 0x1d1f4, + 0x1d1f2, + 0x1a3f4, + 0x1a3f2, + // 110 + 0x142f0, + 0x1a17c, + 0x14278, + 0x1a13e, + 0x1423c, + 0x1421e, + 0x1fa1a, + 0x1437c, + 0x1433e, + 0x1f43a, + // 120 + 0x1e87a, + 0x1d0fa, + 0x14178, + 0x1a0be, + 0x1413c, + 0x1411e, + 0x141be, + 0x140bc, + 0x1409e, + 0x12bc0, + // 130 + 0x195f0, + 0x1cafc, + 0x129e0, + 0x194f8, + 0x1ca7e, + 0x128f0, + 0x1947c, + 0x12878, + 0x1943e, + 0x1283c, + // 140 + 0x1f968, + 0x12df0, + 0x196fc, + 0x1f964, + 0x12cf8, + 0x1967e, + 0x1f962, + 0x12c7c, + 0x12c3e, + 0x1f2e8, + // 150 + 0x1f976, + 0x12efc, + 0x1f2e4, + 0x12e7e, + 0x1f2e2, + 0x1e5e8, + 0x1f2f6, + 0x1e5e4, + 0x1e5e2, + 0x1cbe8, + // 160 + 0x1e5f6, + 0x1cbe4, + 0x1cbe2, + 0x197e8, + 0x1cbf6, + 0x197e4, + 0x197e2, + 0x1b5e0, + 0x1daf8, + 0x1ed7e, + // 170 + 0x169c0, + 0x1b4f0, + 0x1da7c, + 0x168e0, + 0x1b478, + 0x1da3e, + 0x16870, + 0x1b43c, + 0x16838, + 0x1b41e, + // 180 + 0x1681c, + 0x125e0, + 0x192f8, + 0x1c97e, + 0x16de0, + 0x124f0, + 0x1927c, + 0x16cf0, + 0x1b67c, + 0x1923e, + // 190 + 0x16c78, + 0x1243c, + 0x16c3c, + 0x1241e, + 0x16c1e, + 0x1f934, + 0x126f8, + 0x1937e, + 0x1fb74, + 0x1f932, + // 200 + 0x16ef8, + 0x1267c, + 0x1fb72, + 0x16e7c, + 0x1263e, + 0x16e3e, + 0x1f274, + 0x1277e, + 0x1f6f4, + 0x1f272, + // 210 + 0x16f7e, + 0x1f6f2, + 0x1e4f4, + 0x1edf4, + 0x1e4f2, + 0x1edf2, + 0x1c9f4, + 0x1dbf4, + 0x1c9f2, + 0x1dbf2, + // 220 + 0x193f4, + 0x193f2, + 0x165c0, + 0x1b2f0, + 0x1d97c, + 0x164e0, + 0x1b278, + 0x1d93e, + 0x16470, + 0x1b23c, + // 230 + 0x16438, + 0x1b21e, + 0x1641c, + 0x1640e, + 0x122f0, + 0x1917c, + 0x166f0, + 0x12278, + 0x1913e, + 0x16678, + // 240 + 0x1b33e, + 0x1663c, + 0x1221e, + 0x1661e, + 0x1f91a, + 0x1237c, + 0x1fb3a, + 0x1677c, + 0x1233e, + 0x1673e, + // 250 + 0x1f23a, + 0x1f67a, + 0x1e47a, + 0x1ecfa, + 0x1c8fa, + 0x1d9fa, + 0x191fa, + 0x162e0, + 0x1b178, + 0x1d8be, + // 260 + 0x16270, + 0x1b13c, + 0x16238, + 0x1b11e, + 0x1621c, + 0x1620e, + 0x12178, + 0x190be, + 0x16378, + 0x1213c, + // 270 + 0x1633c, + 0x1211e, + 0x1631e, + 0x121be, + 0x163be, + 0x16170, + 0x1b0bc, + 0x16138, + 0x1b09e, + 0x1611c, + // 280 + 0x1610e, + 0x120bc, + 0x161bc, + 0x1209e, + 0x1619e, + 0x160b8, + 0x1b05e, + 0x1609c, + 0x1608e, + 0x1205e, + // 290 + 0x160de, + 0x1605c, + 0x1604e, + 0x115e0, + 0x18af8, + 0x1c57e, + 0x114f0, + 0x18a7c, + 0x11478, + 0x18a3e, + // 300 + 0x1143c, + 0x1141e, + 0x1f8b4, + 0x116f8, + 0x18b7e, + 0x1f8b2, + 0x1167c, + 0x1163e, + 0x1f174, + 0x1177e, + // 310 + 0x1f172, + 0x1e2f4, + 0x1e2f2, + 0x1c5f4, + 0x1c5f2, + 0x18bf4, + 0x18bf2, + 0x135c0, + 0x19af0, + 0x1cd7c, + // 320 + 0x134e0, + 0x19a78, + 0x1cd3e, + 0x13470, + 0x19a3c, + 0x13438, + 0x19a1e, + 0x1341c, + 0x1340e, + 0x112f0, + // 330 + 0x1897c, + 0x136f0, + 0x11278, + 0x1893e, + 0x13678, + 0x19b3e, + 0x1363c, + 0x1121e, + 0x1361e, + 0x1f89a, + // 340 + 0x1137c, + 0x1f9ba, + 0x1377c, + 0x1133e, + 0x1373e, + 0x1f13a, + 0x1f37a, + 0x1e27a, + 0x1e6fa, + 0x1c4fa, + // 350 + 0x1cdfa, + 0x189fa, + 0x1bae0, + 0x1dd78, + 0x1eebe, + 0x174c0, + 0x1ba70, + 0x1dd3c, + 0x17460, + 0x1ba38, + // 360 + 0x1dd1e, + 0x17430, + 0x1ba1c, + 0x17418, + 0x1ba0e, + 0x1740c, + 0x132e0, + 0x19978, + 0x1ccbe, + 0x176e0, + // 370 + 0x13270, + 0x1993c, + 0x17670, + 0x1bb3c, + 0x1991e, + 0x17638, + 0x1321c, + 0x1761c, + 0x1320e, + 0x1760e, + // 380 + 0x11178, + 0x188be, + 0x13378, + 0x1113c, + 0x17778, + 0x1333c, + 0x1111e, + 0x1773c, + 0x1331e, + 0x1771e, + // 390 + 0x111be, + 0x133be, + 0x177be, + 0x172c0, + 0x1b970, + 0x1dcbc, + 0x17260, + 0x1b938, + 0x1dc9e, + 0x17230, + // 400 + 0x1b91c, + 0x17218, + 0x1b90e, + 0x1720c, + 0x17206, + 0x13170, + 0x198bc, + 0x17370, + 0x13138, + 0x1989e, + // 410 + 0x17338, + 0x1b99e, + 0x1731c, + 0x1310e, + 0x1730e, + 0x110bc, + 0x131bc, + 0x1109e, + 0x173bc, + 0x1319e, + // 420 + 0x1739e, + 0x17160, + 0x1b8b8, + 0x1dc5e, + 0x17130, + 0x1b89c, + 0x17118, + 0x1b88e, + 0x1710c, + 0x17106, + // 430 + 0x130b8, + 0x1985e, + 0x171b8, + 0x1309c, + 0x1719c, + 0x1308e, + 0x1718e, + 0x1105e, + 0x130de, + 0x171de, + // 440 + 0x170b0, + 0x1b85c, + 0x17098, + 0x1b84e, + 0x1708c, + 0x17086, + 0x1305c, + 0x170dc, + 0x1304e, + 0x170ce, + // 450 + 0x17058, + 0x1b82e, + 0x1704c, + 0x17046, + 0x1302e, + 0x1706e, + 0x1702c, + 0x17026, + 0x10af0, + 0x1857c, + // 460 + 0x10a78, + 0x1853e, + 0x10a3c, + 0x10a1e, + 0x10b7c, + 0x10b3e, + 0x1f0ba, + 0x1e17a, + 0x1c2fa, + 0x185fa, + // 470 + 0x11ae0, + 0x18d78, + 0x1c6be, + 0x11a70, + 0x18d3c, + 0x11a38, + 0x18d1e, + 0x11a1c, + 0x11a0e, + 0x10978, + // 480 + 0x184be, + 0x11b78, + 0x1093c, + 0x11b3c, + 0x1091e, + 0x11b1e, + 0x109be, + 0x11bbe, + 0x13ac0, + 0x19d70, + // 490 + 0x1cebc, + 0x13a60, + 0x19d38, + 0x1ce9e, + 0x13a30, + 0x19d1c, + 0x13a18, + 0x19d0e, + 0x13a0c, + 0x13a06, + // 500 + 0x11970, + 0x18cbc, + 0x13b70, + 0x11938, + 0x18c9e, + 0x13b38, + 0x1191c, + 0x13b1c, + 0x1190e, + 0x13b0e, + // 510 + 0x108bc, + 0x119bc, + 0x1089e, + 0x13bbc, + 0x1199e, + 0x13b9e, + 0x1bd60, + 0x1deb8, + 0x1ef5e, + 0x17a40, + // 520 + 0x1bd30, + 0x1de9c, + 0x17a20, + 0x1bd18, + 0x1de8e, + 0x17a10, + 0x1bd0c, + 0x17a08, + 0x1bd06, + 0x17a04, + // 530 + 0x13960, + 0x19cb8, + 0x1ce5e, + 0x17b60, + 0x13930, + 0x19c9c, + 0x17b30, + 0x1bd9c, + 0x19c8e, + 0x17b18, + // 540 + 0x1390c, + 0x17b0c, + 0x13906, + 0x17b06, + 0x118b8, + 0x18c5e, + 0x139b8, + 0x1189c, + 0x17bb8, + 0x1399c, + // 550 + 0x1188e, + 0x17b9c, + 0x1398e, + 0x17b8e, + 0x1085e, + 0x118de, + 0x139de, + 0x17bde, + 0x17940, + 0x1bcb0, + // 560 + 0x1de5c, + 0x17920, + 0x1bc98, + 0x1de4e, + 0x17910, + 0x1bc8c, + 0x17908, + 0x1bc86, + 0x17904, + 0x17902, + // 570 + 0x138b0, + 0x19c5c, + 0x179b0, + 0x13898, + 0x19c4e, + 0x17998, + 0x1bcce, + 0x1798c, + 0x13886, + 0x17986, + // 580 + 0x1185c, + 0x138dc, + 0x1184e, + 0x179dc, + 0x138ce, + 0x179ce, + 0x178a0, + 0x1bc58, + 0x1de2e, + 0x17890, + // 590 + 0x1bc4c, + 0x17888, + 0x1bc46, + 0x17884, + 0x17882, + 0x13858, + 0x19c2e, + 0x178d8, + 0x1384c, + 0x178cc, + // 600 + 0x13846, + 0x178c6, + 0x1182e, + 0x1386e, + 0x178ee, + 0x17850, + 0x1bc2c, + 0x17848, + 0x1bc26, + 0x17844, + // 610 + 0x17842, + 0x1382c, + 0x1786c, + 0x13826, + 0x17866, + 0x17828, + 0x1bc16, + 0x17824, + 0x17822, + 0x13816, + // 620 + 0x17836, + 0x10578, + 0x182be, + 0x1053c, + 0x1051e, + 0x105be, + 0x10d70, + 0x186bc, + 0x10d38, + 0x1869e, + // 630 + 0x10d1c, + 0x10d0e, + 0x104bc, + 0x10dbc, + 0x1049e, + 0x10d9e, + 0x11d60, + 0x18eb8, + 0x1c75e, + 0x11d30, + // 640 + 0x18e9c, + 0x11d18, + 0x18e8e, + 0x11d0c, + 0x11d06, + 0x10cb8, + 0x1865e, + 0x11db8, + 0x10c9c, + 0x11d9c, + // 650 + 0x10c8e, + 0x11d8e, + 0x1045e, + 0x10cde, + 0x11dde, + 0x13d40, + 0x19eb0, + 0x1cf5c, + 0x13d20, + 0x19e98, + // 660 + 0x1cf4e, + 0x13d10, + 0x19e8c, + 0x13d08, + 0x19e86, + 0x13d04, + 0x13d02, + 0x11cb0, + 0x18e5c, + 0x13db0, + // 670 + 0x11c98, + 0x18e4e, + 0x13d98, + 0x19ece, + 0x13d8c, + 0x11c86, + 0x13d86, + 0x10c5c, + 0x11cdc, + 0x10c4e, + // 680 + 0x13ddc, + 0x11cce, + 0x13dce, + 0x1bea0, + 0x1df58, + 0x1efae, + 0x1be90, + 0x1df4c, + 0x1be88, + 0x1df46, + // 690 + 0x1be84, + 0x1be82, + 0x13ca0, + 0x19e58, + 0x1cf2e, + 0x17da0, + 0x13c90, + 0x19e4c, + 0x17d90, + 0x1becc, + // 700 + 0x19e46, + 0x17d88, + 0x13c84, + 0x17d84, + 0x13c82, + 0x17d82, + 0x11c58, + 0x18e2e, + 0x13cd8, + 0x11c4c, + // 710 + 0x17dd8, + 0x13ccc, + 0x11c46, + 0x17dcc, + 0x13cc6, + 0x17dc6, + 0x10c2e, + 0x11c6e, + 0x13cee, + 0x17dee, + // 720 + 0x1be50, + 0x1df2c, + 0x1be48, + 0x1df26, + 0x1be44, + 0x1be42, + 0x13c50, + 0x19e2c, + 0x17cd0, + 0x13c48, + // 730 + 0x19e26, + 0x17cc8, + 0x1be66, + 0x17cc4, + 0x13c42, + 0x17cc2, + 0x11c2c, + 0x13c6c, + 0x11c26, + 0x17cec, + // 740 + 0x13c66, + 0x17ce6, + 0x1be28, + 0x1df16, + 0x1be24, + 0x1be22, + 0x13c28, + 0x19e16, + 0x17c68, + 0x13c24, + // 750 + 0x17c64, + 0x13c22, + 0x17c62, + 0x11c16, + 0x13c36, + 0x17c76, + 0x1be14, + 0x1be12, + 0x13c14, + 0x17c34, + // 760 + 0x13c12, + 0x17c32, + 0x102bc, + 0x1029e, + 0x106b8, + 0x1835e, + 0x1069c, + 0x1068e, + 0x1025e, + 0x106de, + // 770 + 0x10eb0, + 0x1875c, + 0x10e98, + 0x1874e, + 0x10e8c, + 0x10e86, + 0x1065c, + 0x10edc, + 0x1064e, + 0x10ece, + // 780 + 0x11ea0, + 0x18f58, + 0x1c7ae, + 0x11e90, + 0x18f4c, + 0x11e88, + 0x18f46, + 0x11e84, + 0x11e82, + 0x10e58, + // 790 + 0x1872e, + 0x11ed8, + 0x18f6e, + 0x11ecc, + 0x10e46, + 0x11ec6, + 0x1062e, + 0x10e6e, + 0x11eee, + 0x19f50, + // 800 + 0x1cfac, + 0x19f48, + 0x1cfa6, + 0x19f44, + 0x19f42, + 0x11e50, + 0x18f2c, + 0x13ed0, + 0x19f6c, + 0x18f26, + // 810 + 0x13ec8, + 0x11e44, + 0x13ec4, + 0x11e42, + 0x13ec2, + 0x10e2c, + 0x11e6c, + 0x10e26, + 0x13eec, + 0x11e66, + // 820 + 0x13ee6, + 0x1dfa8, + 0x1efd6, + 0x1dfa4, + 0x1dfa2, + 0x19f28, + 0x1cf96, + 0x1bf68, + 0x19f24, + 0x1bf64, + // 830 + 0x19f22, + 0x1bf62, + 0x11e28, + 0x18f16, + 0x13e68, + 0x11e24, + 0x17ee8, + 0x13e64, + 0x11e22, + 0x17ee4, + // 840 + 0x13e62, + 0x17ee2, + 0x10e16, + 0x11e36, + 0x13e76, + 0x17ef6, + 0x1df94, + 0x1df92, + 0x19f14, + 0x1bf34, + // 850 + 0x19f12, + 0x1bf32, + 0x11e14, + 0x13e34, + 0x11e12, + 0x17e74, + 0x13e32, + 0x17e72, + 0x1df8a, + 0x19f0a, + // 860 + 0x1bf1a, + 0x11e0a, + 0x13e1a, + 0x17e3a, + 0x1035c, + 0x1034e, + 0x10758, + 0x183ae, + 0x1074c, + 0x10746, + // 870 + 0x1032e, + 0x1076e, + 0x10f50, + 0x187ac, + 0x10f48, + 0x187a6, + 0x10f44, + 0x10f42, + 0x1072c, + 0x10f6c, + // 880 + 0x10726, + 0x10f66, + 0x18fa8, + 0x1c7d6, + 0x18fa4, + 0x18fa2, + 0x10f28, + 0x18796, + 0x11f68, + 0x18fb6, + // 890 + 0x11f64, + 0x10f22, + 0x11f62, + 0x10716, + 0x10f36, + 0x11f76, + 0x1cfd4, + 0x1cfd2, + 0x18f94, + 0x19fb4, + // 900 + 0x18f92, + 0x19fb2, + 0x10f14, + 0x11f34, + 0x10f12, + 0x13f74, + 0x11f32, + 0x13f72, + 0x1cfca, + 0x18f8a, + // 910 + 0x19f9a, + 0x10f0a, + 0x11f1a, + 0x13f3a, + 0x103ac, + 0x103a6, + 0x107a8, + 0x183d6, + 0x107a4, + 0x107a2, + // 920 + 0x10396, + 0x107b6, + 0x187d4, + 0x187d2, + 0x10794, + 0x10fb4, + 0x10792, + 0x10fb2, + 0x1c7ea, + ]]; /** * Array of factors of the Reed-Solomon polynomial equations used for error correction; * One sub array for each correction level (0-8). */ - const RS_FACTORS = array( - array( // ECL 0 (2 factors) ------------------------------------------------------------------------------- - 0x01b,0x395 // 2 - ), - array( // ECL 1 (4 factors) ------------------------------------------------------------------------------- - 0x20a,0x238,0x2d3,0x329 // 4 - ), - array( // ECL 2 (8 factors) ------------------------------------------------------------------------------- - 0x0ed,0x134,0x1b4,0x11c,0x286,0x28d,0x1ac,0x17b // 8 - ), - array( // ECL 3 (16 factors) ------------------------------------------------------------------------------ - 0x112,0x232,0x0e8,0x2f3,0x257,0x20c,0x321,0x084,0x127,0x074,0x1ba,0x1ac,0x127,0x02a,0x0b0,0x041 // 16 - ), - array( // ECL 4 (32 factors) ------------------------------------------------------------------------------ - 0x169,0x23f,0x39a,0x20d,0x0b0,0x24a,0x280,0x141,0x218,0x2e6,0x2a5,0x2e6,0x2af,0x11c,0x0c1,0x205, // 16 - 0x111,0x1ee,0x107,0x093,0x251,0x320,0x23b,0x140,0x323,0x085,0x0e7,0x186,0x2ad,0x14a,0x03f,0x19a // 32 - ), - array( // ECL 5 (64 factors) ------------------------------------------------------------------------------ - 0x21b,0x1a6,0x006,0x05d,0x35e,0x303,0x1c5,0x06a,0x262,0x11f,0x06b,0x1f9,0x2dd,0x36d,0x17d,0x264, // 16 - 0x2d3,0x1dc,0x1ce,0x0ac,0x1ae,0x261,0x35a,0x336,0x21f,0x178,0x1ff,0x190,0x2a0,0x2fa,0x11b,0x0b8, // 32 - 0x1b8,0x023,0x207,0x01f,0x1cc,0x252,0x0e1,0x217,0x205,0x160,0x25d,0x09e,0x28b,0x0c9,0x1e8,0x1f6, // 48 - 0x288,0x2dd,0x2cd,0x053,0x194,0x061,0x118,0x303,0x348,0x275,0x004,0x17d,0x34b,0x26f,0x108,0x21f // 64 - ), - array( // ECL 6 (128 factors) ----------------------------------------------------------------------------- - 0x209,0x136,0x360,0x223,0x35a,0x244,0x128,0x17b,0x035,0x30b,0x381,0x1bc,0x190,0x39d,0x2ed,0x19f, // 16 - 0x336,0x05d,0x0d9,0x0d0,0x3a0,0x0f4,0x247,0x26c,0x0f6,0x094,0x1bf,0x277,0x124,0x38c,0x1ea,0x2c0, // 32 - 0x204,0x102,0x1c9,0x38b,0x252,0x2d3,0x2a2,0x124,0x110,0x060,0x2ac,0x1b0,0x2ae,0x25e,0x35c,0x239, // 48 - 0x0c1,0x0db,0x081,0x0ba,0x0ec,0x11f,0x0c0,0x307,0x116,0x0ad,0x028,0x17b,0x2c8,0x1cf,0x286,0x308, // 64 - 0x0ab,0x1eb,0x129,0x2fb,0x09c,0x2dc,0x05f,0x10e,0x1bf,0x05a,0x1fb,0x030,0x0e4,0x335,0x328,0x382, // 80 - 0x310,0x297,0x273,0x17a,0x17e,0x106,0x17c,0x25a,0x2f2,0x150,0x059,0x266,0x057,0x1b0,0x29e,0x268, // 96 - 0x09d,0x176,0x0f2,0x2d6,0x258,0x10d,0x177,0x382,0x34d,0x1c6,0x162,0x082,0x32e,0x24b,0x324,0x022, // 112 - 0x0d3,0x14a,0x21b,0x129,0x33b,0x361,0x025,0x205,0x342,0x13b,0x226,0x056,0x321,0x004,0x06c,0x21b // 128 - ), - array( // ECL 7 (256 factors) ----------------------------------------------------------------------------- - 0x20c,0x37e,0x04b,0x2fe,0x372,0x359,0x04a,0x0cc,0x052,0x24a,0x2c4,0x0fa,0x389,0x312,0x08a,0x2d0, // 16 - 0x35a,0x0c2,0x137,0x391,0x113,0x0be,0x177,0x352,0x1b6,0x2dd,0x0c2,0x118,0x0c9,0x118,0x33c,0x2f5, // 32 - 0x2c6,0x32e,0x397,0x059,0x044,0x239,0x00b,0x0cc,0x31c,0x25d,0x21c,0x391,0x321,0x2bc,0x31f,0x089, // 48 - 0x1b7,0x1a2,0x250,0x29c,0x161,0x35b,0x172,0x2b6,0x145,0x0f0,0x0d8,0x101,0x11c,0x225,0x0d1,0x374, // 64 - 0x13b,0x046,0x149,0x319,0x1ea,0x112,0x36d,0x0a2,0x2ed,0x32c,0x2ac,0x1cd,0x14e,0x178,0x351,0x209, // 80 - 0x133,0x123,0x323,0x2c8,0x013,0x166,0x18f,0x38c,0x067,0x1ff,0x033,0x008,0x205,0x0e1,0x121,0x1d6, // 96 - 0x27d,0x2db,0x042,0x0ff,0x395,0x10d,0x1cf,0x33e,0x2da,0x1b1,0x350,0x249,0x088,0x21a,0x38a,0x05a, // 112 - 0x002,0x122,0x2e7,0x0c7,0x28f,0x387,0x149,0x031,0x322,0x244,0x163,0x24c,0x0bc,0x1ce,0x00a,0x086, // 128 - 0x274,0x140,0x1df,0x082,0x2e3,0x047,0x107,0x13e,0x176,0x259,0x0c0,0x25d,0x08e,0x2a1,0x2af,0x0ea, // 144 - 0x2d2,0x180,0x0b1,0x2f0,0x25f,0x280,0x1c7,0x0c1,0x2b1,0x2c3,0x325,0x281,0x030,0x03c,0x2dc,0x26d, // 160 - 0x37f,0x220,0x105,0x354,0x28f,0x135,0x2b9,0x2f3,0x2f4,0x03c,0x0e7,0x305,0x1b2,0x1a5,0x2d6,0x210, // 176 - 0x1f7,0x076,0x031,0x31b,0x020,0x090,0x1f4,0x0ee,0x344,0x18a,0x118,0x236,0x13f,0x009,0x287,0x226, // 192 - 0x049,0x392,0x156,0x07e,0x020,0x2a9,0x14b,0x318,0x26c,0x03c,0x261,0x1b9,0x0b4,0x317,0x37d,0x2f2, // 208 - 0x25d,0x17f,0x0e4,0x2ed,0x2f8,0x0d5,0x036,0x129,0x086,0x036,0x342,0x12b,0x39a,0x0bf,0x38e,0x214, // 224 - 0x261,0x33d,0x0bd,0x014,0x0a7,0x01d,0x368,0x1c1,0x053,0x192,0x029,0x290,0x1f9,0x243,0x1e1,0x0ad, // 240 - 0x194,0x0fb,0x2b0,0x05f,0x1f1,0x22b,0x282,0x21f,0x133,0x09f,0x39c,0x22e,0x288,0x037,0x1f1,0x00a // 256 - ), - array( // ECL 8 (512 factors) ----------------------------------------------------------------------------- - 0x160,0x04d,0x175,0x1f8,0x023,0x257,0x1ac,0x0cf,0x199,0x23e,0x076,0x1f2,0x11d,0x17c,0x15e,0x1ec, // 16 - 0x0c5,0x109,0x398,0x09b,0x392,0x12b,0x0e5,0x283,0x126,0x367,0x132,0x058,0x057,0x0c1,0x160,0x30d, // 32 - 0x34e,0x04b,0x147,0x208,0x1b3,0x21f,0x0cb,0x29a,0x0f9,0x15a,0x30d,0x26d,0x280,0x10c,0x31a,0x216, // 48 - 0x21b,0x30d,0x198,0x186,0x284,0x066,0x1dc,0x1f3,0x122,0x278,0x221,0x025,0x35a,0x394,0x228,0x029, // 64 - 0x21e,0x121,0x07a,0x110,0x17f,0x320,0x1e5,0x062,0x2f0,0x1d8,0x2f9,0x06b,0x310,0x35c,0x292,0x2e5, // 80 - 0x122,0x0cc,0x2a9,0x197,0x357,0x055,0x063,0x03e,0x1e2,0x0b4,0x014,0x129,0x1c3,0x251,0x391,0x08e, // 96 - 0x328,0x2ac,0x11f,0x218,0x231,0x04c,0x28d,0x383,0x2d9,0x237,0x2e8,0x186,0x201,0x0c0,0x204,0x102, // 112 - 0x0f0,0x206,0x31a,0x18b,0x300,0x350,0x033,0x262,0x180,0x0a8,0x0be,0x33a,0x148,0x254,0x312,0x12f, // 128 - 0x23a,0x17d,0x19f,0x281,0x09c,0x0ed,0x097,0x1ad,0x213,0x0cf,0x2a4,0x2c6,0x059,0x0a8,0x130,0x192, // 144 - 0x028,0x2c4,0x23f,0x0a2,0x360,0x0e5,0x041,0x35d,0x349,0x200,0x0a4,0x1dd,0x0dd,0x05c,0x166,0x311, // 160 - 0x120,0x165,0x352,0x344,0x33b,0x2e0,0x2c3,0x05e,0x008,0x1ee,0x072,0x209,0x002,0x1f3,0x353,0x21f, // 176 - 0x098,0x2d9,0x303,0x05f,0x0f8,0x169,0x242,0x143,0x358,0x31d,0x121,0x033,0x2ac,0x1d2,0x215,0x334, // 192 - 0x29d,0x02d,0x386,0x1c4,0x0a7,0x156,0x0f4,0x0ad,0x023,0x1cf,0x28b,0x033,0x2bb,0x24f,0x1c4,0x242, // 208 - 0x025,0x07c,0x12a,0x14c,0x228,0x02b,0x1ab,0x077,0x296,0x309,0x1db,0x352,0x2fc,0x16c,0x242,0x38f, // 224 - 0x11b,0x2c7,0x1d8,0x1a4,0x0f5,0x120,0x252,0x18a,0x1ff,0x147,0x24d,0x309,0x2bb,0x2b0,0x02b,0x198, // 240 - 0x34a,0x17f,0x2d1,0x209,0x230,0x284,0x2ca,0x22f,0x03e,0x091,0x369,0x297,0x2c9,0x09f,0x2a0,0x2d9, // 256 - 0x270,0x03b,0x0c1,0x1a1,0x09e,0x0d1,0x233,0x234,0x157,0x2b5,0x06d,0x260,0x233,0x16d,0x0b5,0x304, // 272 - 0x2a5,0x136,0x0f8,0x161,0x2c4,0x19a,0x243,0x366,0x269,0x349,0x278,0x35c,0x121,0x218,0x023,0x309, // 288 - 0x26a,0x24a,0x1a8,0x341,0x04d,0x255,0x15a,0x10d,0x2f5,0x278,0x2b7,0x2ef,0x14b,0x0f7,0x0b8,0x02d, // 304 - 0x313,0x2a8,0x012,0x042,0x197,0x171,0x036,0x1ec,0x0e4,0x265,0x33e,0x39a,0x1b5,0x207,0x284,0x389, // 320 - 0x315,0x1a4,0x131,0x1b9,0x0cf,0x12c,0x37c,0x33b,0x08d,0x219,0x17d,0x296,0x201,0x038,0x0fc,0x155, // 336 - 0x0f2,0x31d,0x346,0x345,0x2d0,0x0e0,0x133,0x277,0x03d,0x057,0x230,0x136,0x2f4,0x299,0x18d,0x328, // 352 - 0x353,0x135,0x1d9,0x31b,0x17a,0x01f,0x287,0x393,0x1cb,0x326,0x24e,0x2db,0x1a9,0x0d8,0x224,0x0f9, // 368 - 0x141,0x371,0x2bb,0x217,0x2a1,0x30e,0x0d2,0x32f,0x389,0x12f,0x34b,0x39a,0x119,0x049,0x1d5,0x317, // 384 - 0x294,0x0a2,0x1f2,0x134,0x09b,0x1a6,0x38b,0x331,0x0bb,0x03e,0x010,0x1a9,0x217,0x150,0x11e,0x1b5, // 400 - 0x177,0x111,0x262,0x128,0x0b7,0x39b,0x074,0x29b,0x2ef,0x161,0x03e,0x16e,0x2b3,0x17b,0x2af,0x34a, // 416 - 0x025,0x165,0x2d0,0x2e6,0x14a,0x005,0x027,0x39b,0x137,0x1a8,0x0f2,0x2ed,0x141,0x036,0x29d,0x13c, // 432 - 0x156,0x12b,0x216,0x069,0x29b,0x1e8,0x280,0x2a0,0x240,0x21c,0x13c,0x1e6,0x2d1,0x262,0x02e,0x290, // 448 - 0x1bf,0x0ab,0x268,0x1d0,0x0be,0x213,0x129,0x141,0x2fa,0x2f0,0x215,0x0af,0x086,0x00e,0x17d,0x1b1, // 464 - 0x2cd,0x02d,0x06f,0x014,0x254,0x11c,0x2e0,0x08a,0x286,0x19b,0x36d,0x29d,0x08d,0x397,0x02d,0x30c, // 480 - 0x197,0x0a4,0x14c,0x383,0x0a5,0x2d6,0x258,0x145,0x1f2,0x28f,0x165,0x2f0,0x300,0x0df,0x351,0x287, // 496 - 0x03f,0x136,0x35f,0x0fb,0x16e,0x130,0x11a,0x2e2,0x2a3,0x19a,0x185,0x0f4,0x01f,0x079,0x12f,0x107 // 512 - ) - ); + public const RS_FACTORS = [[ + // ECL 0 (2 factors) ------------------------------------------------------------------------------- + 0x01b, + 0x395, + ], [ + // ECL 1 (4 factors) ------------------------------------------------------------------------------- + 0x20a, + 0x238, + 0x2d3, + 0x329, + ], [ + // ECL 2 (8 factors) ------------------------------------------------------------------------------- + 0x0ed, + 0x134, + 0x1b4, + 0x11c, + 0x286, + 0x28d, + 0x1ac, + 0x17b, + ], [ + // ECL 3 (16 factors) ------------------------------------------------------------------------------ + 0x112, + 0x232, + 0x0e8, + 0x2f3, + 0x257, + 0x20c, + 0x321, + 0x084, + 0x127, + 0x074, + 0x1ba, + 0x1ac, + 0x127, + 0x02a, + 0x0b0, + 0x041, + ], [ + // ECL 4 (32 factors) ------------------------------------------------------------------------------ + 0x169, + 0x23f, + 0x39a, + 0x20d, + 0x0b0, + 0x24a, + 0x280, + 0x141, + 0x218, + 0x2e6, + 0x2a5, + 0x2e6, + 0x2af, + 0x11c, + 0x0c1, + 0x205, + // 16 + 0x111, + 0x1ee, + 0x107, + 0x093, + 0x251, + 0x320, + 0x23b, + 0x140, + 0x323, + 0x085, + 0x0e7, + 0x186, + 0x2ad, + 0x14a, + 0x03f, + 0x19a, + ], [ + // ECL 5 (64 factors) ------------------------------------------------------------------------------ + 0x21b, + 0x1a6, + 0x006, + 0x05d, + 0x35e, + 0x303, + 0x1c5, + 0x06a, + 0x262, + 0x11f, + 0x06b, + 0x1f9, + 0x2dd, + 0x36d, + 0x17d, + 0x264, + // 16 + 0x2d3, + 0x1dc, + 0x1ce, + 0x0ac, + 0x1ae, + 0x261, + 0x35a, + 0x336, + 0x21f, + 0x178, + 0x1ff, + 0x190, + 0x2a0, + 0x2fa, + 0x11b, + 0x0b8, + // 32 + 0x1b8, + 0x023, + 0x207, + 0x01f, + 0x1cc, + 0x252, + 0x0e1, + 0x217, + 0x205, + 0x160, + 0x25d, + 0x09e, + 0x28b, + 0x0c9, + 0x1e8, + 0x1f6, + // 48 + 0x288, + 0x2dd, + 0x2cd, + 0x053, + 0x194, + 0x061, + 0x118, + 0x303, + 0x348, + 0x275, + 0x004, + 0x17d, + 0x34b, + 0x26f, + 0x108, + 0x21f, + ], [ + // ECL 6 (128 factors) ----------------------------------------------------------------------------- + 0x209, + 0x136, + 0x360, + 0x223, + 0x35a, + 0x244, + 0x128, + 0x17b, + 0x035, + 0x30b, + 0x381, + 0x1bc, + 0x190, + 0x39d, + 0x2ed, + 0x19f, + // 16 + 0x336, + 0x05d, + 0x0d9, + 0x0d0, + 0x3a0, + 0x0f4, + 0x247, + 0x26c, + 0x0f6, + 0x094, + 0x1bf, + 0x277, + 0x124, + 0x38c, + 0x1ea, + 0x2c0, + // 32 + 0x204, + 0x102, + 0x1c9, + 0x38b, + 0x252, + 0x2d3, + 0x2a2, + 0x124, + 0x110, + 0x060, + 0x2ac, + 0x1b0, + 0x2ae, + 0x25e, + 0x35c, + 0x239, + // 48 + 0x0c1, + 0x0db, + 0x081, + 0x0ba, + 0x0ec, + 0x11f, + 0x0c0, + 0x307, + 0x116, + 0x0ad, + 0x028, + 0x17b, + 0x2c8, + 0x1cf, + 0x286, + 0x308, + // 64 + 0x0ab, + 0x1eb, + 0x129, + 0x2fb, + 0x09c, + 0x2dc, + 0x05f, + 0x10e, + 0x1bf, + 0x05a, + 0x1fb, + 0x030, + 0x0e4, + 0x335, + 0x328, + 0x382, + // 80 + 0x310, + 0x297, + 0x273, + 0x17a, + 0x17e, + 0x106, + 0x17c, + 0x25a, + 0x2f2, + 0x150, + 0x059, + 0x266, + 0x057, + 0x1b0, + 0x29e, + 0x268, + // 96 + 0x09d, + 0x176, + 0x0f2, + 0x2d6, + 0x258, + 0x10d, + 0x177, + 0x382, + 0x34d, + 0x1c6, + 0x162, + 0x082, + 0x32e, + 0x24b, + 0x324, + 0x022, + // 112 + 0x0d3, + 0x14a, + 0x21b, + 0x129, + 0x33b, + 0x361, + 0x025, + 0x205, + 0x342, + 0x13b, + 0x226, + 0x056, + 0x321, + 0x004, + 0x06c, + 0x21b, + ], [ + // ECL 7 (256 factors) ----------------------------------------------------------------------------- + 0x20c, + 0x37e, + 0x04b, + 0x2fe, + 0x372, + 0x359, + 0x04a, + 0x0cc, + 0x052, + 0x24a, + 0x2c4, + 0x0fa, + 0x389, + 0x312, + 0x08a, + 0x2d0, + // 16 + 0x35a, + 0x0c2, + 0x137, + 0x391, + 0x113, + 0x0be, + 0x177, + 0x352, + 0x1b6, + 0x2dd, + 0x0c2, + 0x118, + 0x0c9, + 0x118, + 0x33c, + 0x2f5, + // 32 + 0x2c6, + 0x32e, + 0x397, + 0x059, + 0x044, + 0x239, + 0x00b, + 0x0cc, + 0x31c, + 0x25d, + 0x21c, + 0x391, + 0x321, + 0x2bc, + 0x31f, + 0x089, + // 48 + 0x1b7, + 0x1a2, + 0x250, + 0x29c, + 0x161, + 0x35b, + 0x172, + 0x2b6, + 0x145, + 0x0f0, + 0x0d8, + 0x101, + 0x11c, + 0x225, + 0x0d1, + 0x374, + // 64 + 0x13b, + 0x046, + 0x149, + 0x319, + 0x1ea, + 0x112, + 0x36d, + 0x0a2, + 0x2ed, + 0x32c, + 0x2ac, + 0x1cd, + 0x14e, + 0x178, + 0x351, + 0x209, + // 80 + 0x133, + 0x123, + 0x323, + 0x2c8, + 0x013, + 0x166, + 0x18f, + 0x38c, + 0x067, + 0x1ff, + 0x033, + 0x008, + 0x205, + 0x0e1, + 0x121, + 0x1d6, + // 96 + 0x27d, + 0x2db, + 0x042, + 0x0ff, + 0x395, + 0x10d, + 0x1cf, + 0x33e, + 0x2da, + 0x1b1, + 0x350, + 0x249, + 0x088, + 0x21a, + 0x38a, + 0x05a, + // 112 + 0x002, + 0x122, + 0x2e7, + 0x0c7, + 0x28f, + 0x387, + 0x149, + 0x031, + 0x322, + 0x244, + 0x163, + 0x24c, + 0x0bc, + 0x1ce, + 0x00a, + 0x086, + // 128 + 0x274, + 0x140, + 0x1df, + 0x082, + 0x2e3, + 0x047, + 0x107, + 0x13e, + 0x176, + 0x259, + 0x0c0, + 0x25d, + 0x08e, + 0x2a1, + 0x2af, + 0x0ea, + // 144 + 0x2d2, + 0x180, + 0x0b1, + 0x2f0, + 0x25f, + 0x280, + 0x1c7, + 0x0c1, + 0x2b1, + 0x2c3, + 0x325, + 0x281, + 0x030, + 0x03c, + 0x2dc, + 0x26d, + // 160 + 0x37f, + 0x220, + 0x105, + 0x354, + 0x28f, + 0x135, + 0x2b9, + 0x2f3, + 0x2f4, + 0x03c, + 0x0e7, + 0x305, + 0x1b2, + 0x1a5, + 0x2d6, + 0x210, + // 176 + 0x1f7, + 0x076, + 0x031, + 0x31b, + 0x020, + 0x090, + 0x1f4, + 0x0ee, + 0x344, + 0x18a, + 0x118, + 0x236, + 0x13f, + 0x009, + 0x287, + 0x226, + // 192 + 0x049, + 0x392, + 0x156, + 0x07e, + 0x020, + 0x2a9, + 0x14b, + 0x318, + 0x26c, + 0x03c, + 0x261, + 0x1b9, + 0x0b4, + 0x317, + 0x37d, + 0x2f2, + // 208 + 0x25d, + 0x17f, + 0x0e4, + 0x2ed, + 0x2f8, + 0x0d5, + 0x036, + 0x129, + 0x086, + 0x036, + 0x342, + 0x12b, + 0x39a, + 0x0bf, + 0x38e, + 0x214, + // 224 + 0x261, + 0x33d, + 0x0bd, + 0x014, + 0x0a7, + 0x01d, + 0x368, + 0x1c1, + 0x053, + 0x192, + 0x029, + 0x290, + 0x1f9, + 0x243, + 0x1e1, + 0x0ad, + // 240 + 0x194, + 0x0fb, + 0x2b0, + 0x05f, + 0x1f1, + 0x22b, + 0x282, + 0x21f, + 0x133, + 0x09f, + 0x39c, + 0x22e, + 0x288, + 0x037, + 0x1f1, + 0x00a, + ], [ + // ECL 8 (512 factors) ----------------------------------------------------------------------------- + 0x160, + 0x04d, + 0x175, + 0x1f8, + 0x023, + 0x257, + 0x1ac, + 0x0cf, + 0x199, + 0x23e, + 0x076, + 0x1f2, + 0x11d, + 0x17c, + 0x15e, + 0x1ec, + // 16 + 0x0c5, + 0x109, + 0x398, + 0x09b, + 0x392, + 0x12b, + 0x0e5, + 0x283, + 0x126, + 0x367, + 0x132, + 0x058, + 0x057, + 0x0c1, + 0x160, + 0x30d, + // 32 + 0x34e, + 0x04b, + 0x147, + 0x208, + 0x1b3, + 0x21f, + 0x0cb, + 0x29a, + 0x0f9, + 0x15a, + 0x30d, + 0x26d, + 0x280, + 0x10c, + 0x31a, + 0x216, + // 48 + 0x21b, + 0x30d, + 0x198, + 0x186, + 0x284, + 0x066, + 0x1dc, + 0x1f3, + 0x122, + 0x278, + 0x221, + 0x025, + 0x35a, + 0x394, + 0x228, + 0x029, + // 64 + 0x21e, + 0x121, + 0x07a, + 0x110, + 0x17f, + 0x320, + 0x1e5, + 0x062, + 0x2f0, + 0x1d8, + 0x2f9, + 0x06b, + 0x310, + 0x35c, + 0x292, + 0x2e5, + // 80 + 0x122, + 0x0cc, + 0x2a9, + 0x197, + 0x357, + 0x055, + 0x063, + 0x03e, + 0x1e2, + 0x0b4, + 0x014, + 0x129, + 0x1c3, + 0x251, + 0x391, + 0x08e, + // 96 + 0x328, + 0x2ac, + 0x11f, + 0x218, + 0x231, + 0x04c, + 0x28d, + 0x383, + 0x2d9, + 0x237, + 0x2e8, + 0x186, + 0x201, + 0x0c0, + 0x204, + 0x102, + // 112 + 0x0f0, + 0x206, + 0x31a, + 0x18b, + 0x300, + 0x350, + 0x033, + 0x262, + 0x180, + 0x0a8, + 0x0be, + 0x33a, + 0x148, + 0x254, + 0x312, + 0x12f, + // 128 + 0x23a, + 0x17d, + 0x19f, + 0x281, + 0x09c, + 0x0ed, + 0x097, + 0x1ad, + 0x213, + 0x0cf, + 0x2a4, + 0x2c6, + 0x059, + 0x0a8, + 0x130, + 0x192, + // 144 + 0x028, + 0x2c4, + 0x23f, + 0x0a2, + 0x360, + 0x0e5, + 0x041, + 0x35d, + 0x349, + 0x200, + 0x0a4, + 0x1dd, + 0x0dd, + 0x05c, + 0x166, + 0x311, + // 160 + 0x120, + 0x165, + 0x352, + 0x344, + 0x33b, + 0x2e0, + 0x2c3, + 0x05e, + 0x008, + 0x1ee, + 0x072, + 0x209, + 0x002, + 0x1f3, + 0x353, + 0x21f, + // 176 + 0x098, + 0x2d9, + 0x303, + 0x05f, + 0x0f8, + 0x169, + 0x242, + 0x143, + 0x358, + 0x31d, + 0x121, + 0x033, + 0x2ac, + 0x1d2, + 0x215, + 0x334, + // 192 + 0x29d, + 0x02d, + 0x386, + 0x1c4, + 0x0a7, + 0x156, + 0x0f4, + 0x0ad, + 0x023, + 0x1cf, + 0x28b, + 0x033, + 0x2bb, + 0x24f, + 0x1c4, + 0x242, + // 208 + 0x025, + 0x07c, + 0x12a, + 0x14c, + 0x228, + 0x02b, + 0x1ab, + 0x077, + 0x296, + 0x309, + 0x1db, + 0x352, + 0x2fc, + 0x16c, + 0x242, + 0x38f, + // 224 + 0x11b, + 0x2c7, + 0x1d8, + 0x1a4, + 0x0f5, + 0x120, + 0x252, + 0x18a, + 0x1ff, + 0x147, + 0x24d, + 0x309, + 0x2bb, + 0x2b0, + 0x02b, + 0x198, + // 240 + 0x34a, + 0x17f, + 0x2d1, + 0x209, + 0x230, + 0x284, + 0x2ca, + 0x22f, + 0x03e, + 0x091, + 0x369, + 0x297, + 0x2c9, + 0x09f, + 0x2a0, + 0x2d9, + // 256 + 0x270, + 0x03b, + 0x0c1, + 0x1a1, + 0x09e, + 0x0d1, + 0x233, + 0x234, + 0x157, + 0x2b5, + 0x06d, + 0x260, + 0x233, + 0x16d, + 0x0b5, + 0x304, + // 272 + 0x2a5, + 0x136, + 0x0f8, + 0x161, + 0x2c4, + 0x19a, + 0x243, + 0x366, + 0x269, + 0x349, + 0x278, + 0x35c, + 0x121, + 0x218, + 0x023, + 0x309, + // 288 + 0x26a, + 0x24a, + 0x1a8, + 0x341, + 0x04d, + 0x255, + 0x15a, + 0x10d, + 0x2f5, + 0x278, + 0x2b7, + 0x2ef, + 0x14b, + 0x0f7, + 0x0b8, + 0x02d, + // 304 + 0x313, + 0x2a8, + 0x012, + 0x042, + 0x197, + 0x171, + 0x036, + 0x1ec, + 0x0e4, + 0x265, + 0x33e, + 0x39a, + 0x1b5, + 0x207, + 0x284, + 0x389, + // 320 + 0x315, + 0x1a4, + 0x131, + 0x1b9, + 0x0cf, + 0x12c, + 0x37c, + 0x33b, + 0x08d, + 0x219, + 0x17d, + 0x296, + 0x201, + 0x038, + 0x0fc, + 0x155, + // 336 + 0x0f2, + 0x31d, + 0x346, + 0x345, + 0x2d0, + 0x0e0, + 0x133, + 0x277, + 0x03d, + 0x057, + 0x230, + 0x136, + 0x2f4, + 0x299, + 0x18d, + 0x328, + // 352 + 0x353, + 0x135, + 0x1d9, + 0x31b, + 0x17a, + 0x01f, + 0x287, + 0x393, + 0x1cb, + 0x326, + 0x24e, + 0x2db, + 0x1a9, + 0x0d8, + 0x224, + 0x0f9, + // 368 + 0x141, + 0x371, + 0x2bb, + 0x217, + 0x2a1, + 0x30e, + 0x0d2, + 0x32f, + 0x389, + 0x12f, + 0x34b, + 0x39a, + 0x119, + 0x049, + 0x1d5, + 0x317, + // 384 + 0x294, + 0x0a2, + 0x1f2, + 0x134, + 0x09b, + 0x1a6, + 0x38b, + 0x331, + 0x0bb, + 0x03e, + 0x010, + 0x1a9, + 0x217, + 0x150, + 0x11e, + 0x1b5, + // 400 + 0x177, + 0x111, + 0x262, + 0x128, + 0x0b7, + 0x39b, + 0x074, + 0x29b, + 0x2ef, + 0x161, + 0x03e, + 0x16e, + 0x2b3, + 0x17b, + 0x2af, + 0x34a, + // 416 + 0x025, + 0x165, + 0x2d0, + 0x2e6, + 0x14a, + 0x005, + 0x027, + 0x39b, + 0x137, + 0x1a8, + 0x0f2, + 0x2ed, + 0x141, + 0x036, + 0x29d, + 0x13c, + // 432 + 0x156, + 0x12b, + 0x216, + 0x069, + 0x29b, + 0x1e8, + 0x280, + 0x2a0, + 0x240, + 0x21c, + 0x13c, + 0x1e6, + 0x2d1, + 0x262, + 0x02e, + 0x290, + // 448 + 0x1bf, + 0x0ab, + 0x268, + 0x1d0, + 0x0be, + 0x213, + 0x129, + 0x141, + 0x2fa, + 0x2f0, + 0x215, + 0x0af, + 0x086, + 0x00e, + 0x17d, + 0x1b1, + // 464 + 0x2cd, + 0x02d, + 0x06f, + 0x014, + 0x254, + 0x11c, + 0x2e0, + 0x08a, + 0x286, + 0x19b, + 0x36d, + 0x29d, + 0x08d, + 0x397, + 0x02d, + 0x30c, + // 480 + 0x197, + 0x0a4, + 0x14c, + 0x383, + 0x0a5, + 0x2d6, + 0x258, + 0x145, + 0x1f2, + 0x28f, + 0x165, + 0x2f0, + 0x300, + 0x0df, + 0x351, + 0x287, + // 496 + 0x03f, + 0x136, + 0x35f, + 0x0fb, + 0x16e, + 0x130, + 0x11a, + 0x2e2, + 0x2a3, + 0x19a, + 0x185, + 0x0f4, + 0x01f, + 0x079, + 0x12f, + 0x107, + ]]; } diff --git a/src/Type/Square/PdfFourOneSeven/Sequence.php b/src/Type/Square/PdfFourOneSeven/Sequence.php index f82183ef..7fa55d0a 100644 --- a/src/Type/Square/PdfFourOneSeven/Sequence.php +++ b/src/Type/Square/PdfFourOneSeven/Sequence.php @@ -49,6 +49,7 @@ protected function getErrorCorrectionLevel(int $ecl, int $numcw): int while (($maxecl > 0) && ($maxerrsize < (2 << $maxecl))) { --$maxecl; } + if (($ecl < 0) || ($ecl > 8)) { if ($numcw < 41) { $ecl = 2; @@ -62,6 +63,7 @@ protected function getErrorCorrectionLevel(int $ecl, int $numcw): int $ecl = $maxecl; } } + return min($maxecl, $ecl); } @@ -84,22 +86,25 @@ protected function getErrorCorrection(array $codewords, int $ecl): array // initialize array of error correction codewords $ecw = array_fill(0, $eclsize, 0); // for each data codeword - foreach ($codewords as $cdw) { - $tk1 = ($cdw + $ecw[$eclmaxid]) % 929; + foreach ($codewords as $codeword) { + $tk1 = ($codeword + $ecw[$eclmaxid]) % 929; for ($idx = $eclmaxid; $idx > 0; --$idx) { $tk2 = ($tk1 * $ecc[$idx]) % 929; $tk3 = 929 - $tk2; $ecw[$idx] = ($ecw[($idx - 1)] + $tk3) % 929; } + $tk2 = ($tk1 * $ecc[0]) % 929; $tk3 = 929 - $tk2; $ecw[0] = $tk3 % 929; } + foreach ($ecw as $idx => $err) { if ($err != 0) { $ecw[$idx] = 929 - $err; } } + return array_reverse($ecw); } @@ -115,10 +120,10 @@ protected function processSequence(array &$sequence_array, string $code, int $se { // extract text sequence before the number sequence $prevseq = substr($code, $offset, ($seq - $offset)); - $textseq = array(); + $textseq = []; // get text sequences preg_match_all('/([\x09\x0a\x0d\x20-\x7e]{5,})/', $prevseq, $textseq, PREG_OFFSET_CAPTURE); - $textseq[1][] = array('', strlen($prevseq)); + $textseq[1][] = ['', strlen($prevseq)]; $txtoffset = 0; foreach ($textseq[1] as $txtseq) { $txtseqlen = strlen($txtseq[0]); @@ -129,21 +134,23 @@ protected function processSequence(array &$sequence_array, string $code, int $se // add BYTE sequence if ( (strlen($prevtxtseq) == 1) - && ((count($sequence_array) > 0) + && (($sequence_array !== []) && ($sequence_array[(count($sequence_array) - 1)][0] == 900)) ) { - $sequence_array[] = array(913, $prevtxtseq); + $sequence_array[] = [913, $prevtxtseq]; } elseif ((strlen($prevtxtseq) % 6) == 0) { - $sequence_array[] = array(924, $prevtxtseq); + $sequence_array[] = [924, $prevtxtseq]; } else { - $sequence_array[] = array(901, $prevtxtseq); + $sequence_array[] = [901, $prevtxtseq]; } } } + if ($txtseqlen > 0) { // add numeric sequence - $sequence_array[] = array(900, $txtseq[0]); + $sequence_array[] = [900, $txtseq[0]]; } + $txtoffset = ($txtseq[1] + $txtseqlen); } } @@ -152,28 +159,29 @@ protected function processSequence(array &$sequence_array, string $code, int $se * Get an array of sequences from input * * @param string $code Data to process - * - * @return array */ protected function getInputSequences(string $code): array { - $sequence_array = array(); // array to be returned - $numseq = array(); + $sequence_array = []; // array to be returned + $numseq = []; // get numeric sequences - preg_match_all('/([0-9]{13,})/', $code, $numseq, PREG_OFFSET_CAPTURE); - $numseq[1][] = array('', strlen($code)); + preg_match_all('/(\d{13,})/', $code, $numseq, PREG_OFFSET_CAPTURE); + $numseq[1][] = ['', strlen($code)]; $offset = 0; foreach ($numseq[1] as $seq) { $seqlen = strlen($seq[0]); if ($seq[1] > 0) { $this->processSequence($sequence_array, $code, $seq[1], $offset); } + if ($seqlen > 0) { // add numeric sequence - $sequence_array[] = array(902, $seq[0]); + $sequence_array[] = [902, $seq[0]]; } + $offset = ($seq[1] + $seqlen); } + return $sequence_array; } } diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 9afbe6fc..8adea37e 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -49,59 +49,43 @@ class QrCode extends \Com\Tecnick\Barcode\Type\Square * The Size of QRcode is defined as version. Version is an integer value from 1 to 40. * Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. * So version 40 is 177*177 matrix. - * - * @var int */ protected int $version = 0; /** * Error correction level - * - * @var int */ protected int $level = 0; /** * Encoding mode - * - * @var int */ protected int $hint = 2; /** * Boolean flag, if false the input string will be converted to uppercase. - * - * @var bool */ protected bool $case_sensitive = true; /** * If false, checks all masks available, * otherwise the value indicates the number of masks to be checked, mask id are random - * - * @var int|bool */ protected int|bool $random_mask = false; /** * If true, estimates best mask (spec. default, but extremally slow; * set to false to significant performance boost but (propably) worst quality code - * - * @var bool */ protected bool $best_mask = true; /** * Default mask used when $this->best_mask === false - * - * @var int */ protected int $default_mask = 2; /** * ByteStream class object - * - * @var ByteStream */ protected ByteStream $bsObj; @@ -126,42 +110,48 @@ protected function setParameters(): void if (!isset($this->params[0]) || !array_key_exists($this->params[0], Data::ECC_LEVELS)) { $this->params[0] = 'L'; } + $this->level = Data::ECC_LEVELS[$this->params[0]]; // hint if (!isset($this->params[1]) || !array_key_exists($this->params[1], Data::ENC_MODES)) { $this->params[1] = '8B'; } + $this->hint = Data::ENC_MODES[$this->params[1]]; // version if (!isset($this->params[2]) || ($this->params[2] < 0) || ($this->params[2] > Data::QRSPEC_VERSION_MAX)) { $this->params[2] = 0; } - $this->version = intval($this->params[2]); + + $this->version = (int) $this->params[2]; // case sensitive if (!isset($this->params[3])) { $this->params[3] = 1; } + $this->case_sensitive = (bool)$this->params[3]; // random mask mode - number of masks to be checked if (!empty($this->params[4])) { - $this->random_mask = intval($this->params[4]); + $this->random_mask = (int) $this->params[4]; } // find best mask if (!isset($this->params[5])) { $this->params[5] = 1; } + $this->best_mask = (bool)$this->params[5]; // default mask if (!isset($this->params[6])) { $this->params[6] = 2; } - $this->default_mask = intval($this->params[6]); + + $this->default_mask = (int) $this->params[6]; } /** @@ -174,6 +164,7 @@ protected function setBars(): void if (strlen((string)$this->code) == 0) { throw new BarcodeException('Empty input'); } + $this->bsObj = new ByteStream($this->hint, $this->version, $this->level); // generate the qrcode $this->processBinarySequence( @@ -196,9 +187,10 @@ protected function binarize(array $frame): array // the frame is square (width = height) foreach ($frame as &$frameLine) { for ($idx = 0; $idx < $len; ++$idx) { - $frameLine[$idx] = (ord($frameLine[$idx]) & 1) ? '1' : '0'; + $frameLine[$idx] = ((ord($frameLine[$idx]) & 1) !== 0) ? '1' : '0'; } } + return $frame; } @@ -212,25 +204,24 @@ protected function encodeString(string $data): array if (!$this->case_sensitive) { $data = $this->toUpper($data); } + $split = new Split($this->bsObj, $this->hint, $this->version); $datacode = $this->bsObj->getByteStream($split->getSplittedString($data)); $this->version = $this->bsObj->version; - $enc = new Encoder( + $encoder = new Encoder( $this->version, $this->level, $this->random_mask, $this->best_mask, $this->default_mask ); - return $enc->encodeMask(-1, $datacode); + return $encoder->encodeMask(-1, $datacode); } /** * Convert input string into upper case mode * * @param string $data Data - * - * @return string */ protected function toUpper(string $data): string { @@ -245,9 +236,11 @@ protected function toUpper(string $data): string if ((ord($data[$pos]) >= ord('a')) && (ord($data[$pos]) <= ord('z'))) { $data[$pos] = chr(ord($data[$pos]) - 32); } - $pos++; + + ++$pos; } } + return $data; } } diff --git a/src/Type/Square/QrCode/ByteStream.php b/src/Type/Square/QrCode/ByteStream.php index 153c5bbe..5c987448 100644 --- a/src/Type/Square/QrCode/ByteStream.php +++ b/src/Type/Square/QrCode/ByteStream.php @@ -75,29 +75,34 @@ protected function bitstreamToByte(array $bstream): array { $size = count($bstream); if ($size == 0) { - return array(); + return []; } + $data = array_fill(0, (int)(($size + 7) / 8), 0); $bytes = (int)($size / 8); $pos = 0; for ($idx = 0; $idx < $bytes; ++$idx) { $val = 0; for ($jdx = 0; $jdx < 8; ++$jdx) { - $val = $val << 1; + $val <<= 1; $val |= $bstream[$pos]; - $pos++; + ++$pos; } + $data[$idx] = $val; } - if ($size & 7) { + + if (($size & 7) !== 0) { $val = 0; for ($jdx = 0; $jdx < ($size & 7); ++$jdx) { - $val = $val << 1; + $val <<= 1; $val |= $bstream[$pos]; - $pos++; + ++$pos; } + $data[$bytes] = $val; } + return $data; } @@ -111,10 +116,11 @@ protected function bitstreamToByte(array $bstream): array protected function mergeBitStream(array $items): array { $items = $this->convertData($items); - $bstream = array(); + $bstream = []; foreach ($items as $item) { $bstream = $this->appendBitstream($bstream, $item['bstream']); } + return $bstream; } @@ -131,6 +137,7 @@ protected function convertData(array $items): array if ($ver > $this->version) { $this->version = $ver; } + while (true) { $cbs = $this->createBitStream($items); $items = $cbs[0]; @@ -138,6 +145,7 @@ protected function convertData(array $items): array if ($bits < 0) { throw new BarcodeException('Negative Bits value'); } + $ver = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level); if ($ver > $this->version) { $this->version = $ver; @@ -145,13 +153,13 @@ protected function convertData(array $items): array break; } } + return $items; } /** * Create BitStream * - * @param array $items * * @return array of items and total bits */ @@ -163,22 +171,21 @@ protected function createBitStream(array $items): array $bits = count($items[$key]['bstream']); $total += $bits; } - return array($items, $total); + + return [$items, $total]; } /** * Encode BitStream * - * @param array $inputitem - * @param int $version * * @return array input item */ public function encodeBitStream(array $inputitem, int $version): array { - $inputitem['bstream'] = array(); - $specObj = new Spec(); - $words = $specObj->maximumWords($inputitem['mode'], $version); + $inputitem['bstream'] = []; + $spec = new Spec(); + $words = $spec->maximumWords($inputitem['mode'], $version); if ($inputitem['size'] > $words) { $st1 = $this->newInputItem($inputitem['mode'], $words, $inputitem['data']); $st2 = $this->newInputItem( @@ -188,7 +195,7 @@ public function encodeBitStream(array $inputitem, int $version): array ); $st1 = $this->encodeBitStream($st1, $version); $st2 = $this->encodeBitStream($st2, $version); - $inputitem['bstream'] = array(); + $inputitem['bstream'] = []; $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st1['bstream']); $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']); } else { @@ -210,6 +217,7 @@ public function encodeBitStream(array $inputitem, int $version): array break; } } + return $inputitem; } @@ -223,30 +231,36 @@ public function encodeBitStream(array $inputitem, int $version): array protected function appendPaddingBit(array $bstream): array { if (is_null($bstream)) { - return array(); + return []; } + $bits = count($bstream); - $specObj = new Spec(); - $maxwords = $specObj->getDataLength($this->version, $this->level); + $spec = new Spec(); + $maxwords = $spec->getDataLength($this->version, $this->level); $maxbits = $maxwords * 8; if ($maxbits == $bits) { return $bstream; } + if ($maxbits - $bits < 5) { return $this->appendNum($bstream, $maxbits - $bits, 0); } + $bits += 4; $words = (int)(($bits + 7) / 8); - $padding = array(); + $padding = []; $padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0); + $padlen = $maxwords - $words; if ($padlen > 0) { - $padbuf = array(); + $padbuf = []; for ($idx = 0; $idx < $padlen; ++$idx) { - $padbuf[$idx] = (($idx & 1) ? 0x11 : 0xec); + $padbuf[$idx] = ((($idx & 1) !== 0) ? 0x11 : 0xec); } + $padding = $this->appendBytes($padding, $padlen, $padbuf); } + return $this->appendBitstream($bstream, $padding); } } diff --git a/src/Type/Square/QrCode/Data.php b/src/Type/Square/QrCode/Data.php index 841ccf63..41b4c782 100644 --- a/src/Type/Square/QrCode/Data.php +++ b/src/Type/Square/QrCode/Data.php @@ -114,7 +114,7 @@ class Data * KJ : Encoding mode KANJI. A KANJI character (multibyte character) is encoded to 13bit length. * ST : Encoding mode STRUCTURED */ - public const ENC_MODES = array('NL' => -1, 'NM' => 0, 'AN' => 1, '8B' => 2, 'KJ' => 3, 'ST' => 4); + public const ENC_MODES = ['NL' => -1, 'NM' => 0, 'AN' => 1, '8B' => 2, 'KJ' => 3, 'ST' => 4]; /** * Array of valid error correction levels @@ -125,127 +125,329 @@ class Data * Q : About 25% or less errors can be corrected. * H : About 30% or less errors can be corrected. */ - public const ECC_LEVELS = array('L' => 0, 'M' => 1, 'Q' => 2, 'H' => 3); + public const ECC_LEVELS = ['L' => 0, 'M' => 1, 'Q' => 2, 'H' => 3]; /** * Alphabet-numeric conversion table. */ - public const AN_TABLE = array( - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // - 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, // - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, // - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, // - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // - ); + public const AN_TABLE = [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + // + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + // + 36, + -1, + -1, + -1, + 37, + 38, + -1, + -1, + -1, + -1, + 39, + 40, + -1, + 41, + 42, + 43, + // + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 44, + -1, + -1, + -1, + -1, + -1, + // + -1, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + // + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + -1, + -1, + -1, + -1, + -1, + // + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + // + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + ]; /** * Array Table of the capacity of symbols. * See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004. */ - public const CAPACITY = array( - array( 0, 0, 0, array( 0, 0, 0, 0)), // - array( 21, 26, 0, array( 7, 10, 13, 17)), // 1 - array( 25, 44, 7, array( 10, 16, 22, 28)), // - array( 29, 70, 7, array( 15, 26, 36, 44)), // - array( 33, 100, 7, array( 20, 36, 52, 64)), // - array( 37, 134, 7, array( 26, 48, 72, 88)), // 5 - array( 41, 172, 7, array( 36, 64, 96, 112)), // - array( 45, 196, 0, array( 40, 72, 108, 130)), // - array( 49, 242, 0, array( 48, 88, 132, 156)), // - array( 53, 292, 0, array( 60, 110, 160, 192)), // - array( 57, 346, 0, array( 72, 130, 192, 224)), // 10 - array( 61, 404, 0, array( 80, 150, 224, 264)), // - array( 65, 466, 0, array( 96, 176, 260, 308)), // - array( 69, 532, 0, array( 104, 198, 288, 352)), // - array( 73, 581, 3, array( 120, 216, 320, 384)), // - array( 77, 655, 3, array( 132, 240, 360, 432)), // 15 - array( 81, 733, 3, array( 144, 280, 408, 480)), // - array( 85, 815, 3, array( 168, 308, 448, 532)), // - array( 89, 901, 3, array( 180, 338, 504, 588)), // - array( 93, 991, 3, array( 196, 364, 546, 650)), // - array( 97, 1085, 3, array( 224, 416, 600, 700)), // 20 - array(101, 1156, 4, array( 224, 442, 644, 750)), // - array(105, 1258, 4, array( 252, 476, 690, 816)), // - array(109, 1364, 4, array( 270, 504, 750, 900)), // - array(113, 1474, 4, array( 300, 560, 810, 960)), // - array(117, 1588, 4, array( 312, 588, 870, 1050)), // 25 - array(121, 1706, 4, array( 336, 644, 952, 1110)), // - array(125, 1828, 4, array( 360, 700, 1020, 1200)), // - array(129, 1921, 3, array( 390, 728, 1050, 1260)), // - array(133, 2051, 3, array( 420, 784, 1140, 1350)), // - array(137, 2185, 3, array( 450, 812, 1200, 1440)), // 30 - array(141, 2323, 3, array( 480, 868, 1290, 1530)), // - array(145, 2465, 3, array( 510, 924, 1350, 1620)), // - array(149, 2611, 3, array( 540, 980, 1440, 1710)), // - array(153, 2761, 3, array( 570, 1036, 1530, 1800)), // - array(157, 2876, 0, array( 570, 1064, 1590, 1890)), // 35 - array(161, 3034, 0, array( 600, 1120, 1680, 1980)), // - array(165, 3196, 0, array( 630, 1204, 1770, 2100)), // - array(169, 3362, 0, array( 660, 1260, 1860, 2220)), // - array(173, 3532, 0, array( 720, 1316, 1950, 2310)), // - array(177, 3706, 0, array( 750, 1372, 2040, 2430)) // 40 - ); + public const CAPACITY = [ + [0, 0, 0, [0, 0, 0, 0]], + // + [21, 26, 0, [7, 10, 13, 17]], + // 1 + [25, 44, 7, [10, 16, 22, 28]], + // + [29, 70, 7, [15, 26, 36, 44]], + // + [33, 100, 7, [20, 36, 52, 64]], + // + [37, 134, 7, [26, 48, 72, 88]], + // 5 + [41, 172, 7, [36, 64, 96, 112]], + // + [45, 196, 0, [40, 72, 108, 130]], + // + [49, 242, 0, [48, 88, 132, 156]], + // + [53, 292, 0, [60, 110, 160, 192]], + // + [57, 346, 0, [72, 130, 192, 224]], + // 10 + [61, 404, 0, [80, 150, 224, 264]], + // + [65, 466, 0, [96, 176, 260, 308]], + // + [69, 532, 0, [104, 198, 288, 352]], + // + [73, 581, 3, [120, 216, 320, 384]], + // + [77, 655, 3, [132, 240, 360, 432]], + // 15 + [81, 733, 3, [144, 280, 408, 480]], + // + [85, 815, 3, [168, 308, 448, 532]], + // + [89, 901, 3, [180, 338, 504, 588]], + // + [93, 991, 3, [196, 364, 546, 650]], + // + [97, 1085, 3, [224, 416, 600, 700]], + // 20 + [101, 1156, 4, [224, 442, 644, 750]], + // + [105, 1258, 4, [252, 476, 690, 816]], + // + [109, 1364, 4, [270, 504, 750, 900]], + // + [113, 1474, 4, [300, 560, 810, 960]], + // + [117, 1588, 4, [312, 588, 870, 1050]], + // 25 + [121, 1706, 4, [336, 644, 952, 1110]], + // + [125, 1828, 4, [360, 700, 1020, 1200]], + // + [129, 1921, 3, [390, 728, 1050, 1260]], + // + [133, 2051, 3, [420, 784, 1140, 1350]], + // + [137, 2185, 3, [450, 812, 1200, 1440]], + // 30 + [141, 2323, 3, [480, 868, 1290, 1530]], + // + [145, 2465, 3, [510, 924, 1350, 1620]], + // + [149, 2611, 3, [540, 980, 1440, 1710]], + // + [153, 2761, 3, [570, 1036, 1530, 1800]], + // + [157, 2876, 0, [570, 1064, 1590, 1890]], + // 35 + [161, 3034, 0, [600, 1120, 1680, 1980]], + // + [165, 3196, 0, [630, 1204, 1770, 2100]], + // + [169, 3362, 0, [660, 1260, 1860, 2220]], + // + [173, 3532, 0, [720, 1316, 1950, 2310]], + // + [177, 3706, 0, [750, 1372, 2040, 2430]], + ]; /** * Array Length indicator. */ - public const LEN_TABLE_BITS = array( - array(10, 12, 14), - array( 9, 11, 13), - array( 8, 16, 16), - array( 8, 10, 12) - ); + public const LEN_TABLE_BITS = [[10, 12, 14], [9, 11, 13], [8, 16, 16], [8, 10, 12]]; /** * Array Table of the error correction code (Reed-Solomon block). * See Table 12-16 (pp.30-36), JIS X0510:2004. */ - public const ECC_TABLE = array( - array(array( 0, 0), array( 0, 0), array( 0, 0), array( 0, 0)), // - array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // 1 - array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // - array(array( 1, 0), array( 1, 0), array( 2, 0), array( 2, 0)), // - array(array( 1, 0), array( 2, 0), array( 2, 0), array( 4, 0)), // - array(array( 1, 0), array( 2, 0), array( 2, 2), array( 2, 2)), // 5 - array(array( 2, 0), array( 4, 0), array( 4, 0), array( 4, 0)), // - array(array( 2, 0), array( 4, 0), array( 2, 4), array( 4, 1)), // - array(array( 2, 0), array( 2, 2), array( 4, 2), array( 4, 2)), // - array(array( 2, 0), array( 3, 2), array( 4, 4), array( 4, 4)), // - array(array( 2, 2), array( 4, 1), array( 6, 2), array( 6, 2)), // 10 - array(array( 4, 0), array( 1, 4), array( 4, 4), array( 3, 8)), // - array(array( 2, 2), array( 6, 2), array( 4, 6), array( 7, 4)), // - array(array( 4, 0), array( 8, 1), array( 8, 4), array(12, 4)), // - array(array( 3, 1), array( 4, 5), array(11, 5), array(11, 5)), // - array(array( 5, 1), array( 5, 5), array( 5, 7), array(11, 7)), // 15 - array(array( 5, 1), array( 7, 3), array(15, 2), array( 3, 13)), // - array(array( 1, 5), array(10, 1), array( 1, 15), array( 2, 17)), // - array(array( 5, 1), array( 9, 4), array(17, 1), array( 2, 19)), // - array(array( 3, 4), array( 3, 11), array(17, 4), array( 9, 16)), // - array(array( 3, 5), array( 3, 13), array(15, 5), array(15, 10)), // 20 - array(array( 4, 4), array(17, 0), array(17, 6), array(19, 6)), // - array(array( 2, 7), array(17, 0), array( 7, 16), array(34, 0)), // - array(array( 4, 5), array( 4, 14), array(11, 14), array(16, 14)), // - array(array( 6, 4), array( 6, 14), array(11, 16), array(30, 2)), // - array(array( 8, 4), array( 8, 13), array( 7, 22), array(22, 13)), // 25 - array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), // - array(array( 8, 4), array(22, 3), array( 8, 26), array(12, 28)), // - array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)), // - array(array( 7, 7), array(21, 7), array( 1, 37), array(19, 26)), // - array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30 - array(array(13, 3), array( 2, 29), array(42, 1), array(23, 28)), // - array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), // - array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), // - array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), // - array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35 - array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)), // - array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), // - array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)), // - array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), // - array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)) // 40 - ); + public const ECC_TABLE = [ + [[0, 0], [0, 0], [0, 0], [0, 0]], + // + [[1, 0], [1, 0], [1, 0], [1, 0]], + // 1 + [[1, 0], [1, 0], [1, 0], [1, 0]], + // + [[1, 0], [1, 0], [2, 0], [2, 0]], + // + [[1, 0], [2, 0], [2, 0], [4, 0]], + // + [[1, 0], [2, 0], [2, 2], [2, 2]], + // 5 + [[2, 0], [4, 0], [4, 0], [4, 0]], + // + [[2, 0], [4, 0], [2, 4], [4, 1]], + // + [[2, 0], [2, 2], [4, 2], [4, 2]], + // + [[2, 0], [3, 2], [4, 4], [4, 4]], + // + [[2, 2], [4, 1], [6, 2], [6, 2]], + // 10 + [[4, 0], [1, 4], [4, 4], [3, 8]], + // + [[2, 2], [6, 2], [4, 6], [7, 4]], + // + [[4, 0], [8, 1], [8, 4], [12, 4]], + // + [[3, 1], [4, 5], [11, 5], [11, 5]], + // + [[5, 1], [5, 5], [5, 7], [11, 7]], + // 15 + [[5, 1], [7, 3], [15, 2], [3, 13]], + // + [[1, 5], [10, 1], [1, 15], [2, 17]], + // + [[5, 1], [9, 4], [17, 1], [2, 19]], + // + [[3, 4], [3, 11], [17, 4], [9, 16]], + // + [[3, 5], [3, 13], [15, 5], [15, 10]], + // 20 + [[4, 4], [17, 0], [17, 6], [19, 6]], + // + [[2, 7], [17, 0], [7, 16], [34, 0]], + // + [[4, 5], [4, 14], [11, 14], [16, 14]], + // + [[6, 4], [6, 14], [11, 16], [30, 2]], + // + [[8, 4], [8, 13], [7, 22], [22, 13]], + // 25 + [[10, 2], [19, 4], [28, 6], [33, 4]], + // + [[8, 4], [22, 3], [8, 26], [12, 28]], + // + [[3, 10], [3, 23], [4, 31], [11, 31]], + // + [[7, 7], [21, 7], [1, 37], [19, 26]], + // + [[5, 10], [19, 10], [15, 25], [23, 25]], + // 30 + [[13, 3], [2, 29], [42, 1], [23, 28]], + // + [[17, 0], [10, 23], [10, 35], [19, 35]], + // + [[17, 1], [14, 21], [29, 19], [11, 46]], + // + [[13, 6], [14, 23], [44, 7], [59, 1]], + // + [[12, 7], [12, 26], [39, 14], [22, 41]], + // 35 + [[6, 14], [6, 34], [46, 10], [2, 64]], + // + [[17, 4], [29, 14], [49, 10], [24, 46]], + // + [[4, 18], [13, 32], [48, 14], [42, 32]], + // + [[20, 4], [40, 7], [43, 22], [10, 67]], + // + [[19, 6], [18, 31], [34, 34], [20, 61]], + ]; /** * Array Positions of alignment patterns. @@ -253,38 +455,113 @@ class Data * Rest of them can be calculated from the distance between them. * See Table 1 in Appendix E (pp.71) of JIS X0510:2004. */ - public const ALIGN_PATTERN = array( - array( 0, 0), - array( 0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5 - array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10 - array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), // 11-15 - array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), // 16-20 - array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), // 21-25 - array(30, 58), array(34, 62), array(26, 50), array(30, 54), array(26, 52), // 26-30 - array(30, 56), array(34, 60), array(30, 58), array(34, 62), array(30, 54), // 31-35 - array(24, 50), array(28, 54), array(32, 58), array(26, 54), array(30, 58) // 35-40 - ); + public const ALIGN_PATTERN = [ + [0, 0], + [0, 0], + [18, 0], + [22, 0], + [26, 0], + [30, 0], + // 1- 5 + [34, 0], + [22, 38], + [24, 42], + [26, 46], + [28, 50], + // 6-10 + [30, 54], + [32, 58], + [34, 62], + [26, 46], + [26, 48], + // 11-15 + [26, 50], + [30, 54], + [30, 56], + [30, 58], + [34, 62], + // 16-20 + [28, 50], + [26, 50], + [30, 54], + [28, 54], + [32, 58], + // 21-25 + [30, 58], + [34, 62], + [26, 50], + [30, 54], + [26, 52], + // 26-30 + [30, 56], + [34, 60], + [30, 58], + [34, 62], + [30, 54], + // 31-35 + [24, 50], + [28, 54], + [32, 58], + [26, 54], + [30, 58], + ]; /** * Array Version information pattern (BCH coded). * See Table 1 in Appendix D (pp.68) of JIS X0510:2004. * size: [QRSPEC_VERSION_MAX - 6] */ - public const VERSION_PATTERN = array( - 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, // - 0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, // - 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, // - 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64, // - 0x27541, 0x28c69 - ); + public const VERSION_PATTERN = [ + 0x07c94, + 0x085bc, + 0x09a99, + 0x0a4d3, + 0x0bbf6, + 0x0c762, + 0x0d847, + 0x0e60d, + // + 0x0f928, + 0x10b78, + 0x1145d, + 0x12a17, + 0x13532, + 0x149a6, + 0x15683, + 0x168c9, + // + 0x177ec, + 0x18ec4, + 0x191e1, + 0x1afab, + 0x1b08e, + 0x1cc1a, + 0x1d33f, + 0x1ed75, + // + 0x1f250, + 0x209d5, + 0x216f0, + 0x228ba, + 0x2379f, + 0x24b0b, + 0x2542e, + 0x26a64, + // + 0x27541, + 0x28c69, + ]; /** * Array Format information */ - public const FORMAT_INFO = array( - array(0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976), // - array(0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0), // - array(0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed), // - array(0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b) // - ); + public const FORMAT_INFO = [ + [0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976], + // + [0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0], + // + [0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed], + // + [0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b], + ]; } diff --git a/src/Type/Square/QrCode/Encode.php b/src/Type/Square/QrCode/Encode.php index 2fe1fa7c..e146fdde 100644 --- a/src/Type/Square/QrCode/Encode.php +++ b/src/Type/Square/QrCode/Encode.php @@ -35,15 +35,13 @@ abstract class Encode extends \Com\Tecnick\Barcode\Type\Square\QrCode\EncodingMo /** * encode Mode Num * - * @param array $inputitem - * @param int $version * * @return array input item */ protected function encodeModeNum(array $inputitem, int $version): array { $words = (int)($inputitem['size'] / 3); - $inputitem['bstream'] = array(); + $inputitem['bstream'] = []; $val = 0x1; $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); $inputitem['bstream'] = $this->appendNum( @@ -57,6 +55,7 @@ protected function encodeModeNum(array $inputitem, int $version): array $val += (ord($inputitem['data'][$i * 3 + 2]) - ord('0')); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val); } + if ($inputitem['size'] - $words * 3 == 1) { $val = ord($inputitem['data'][$words * 3]) - ord('0'); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); @@ -65,21 +64,20 @@ protected function encodeModeNum(array $inputitem, int $version): array $val += (ord($inputitem['data'][$words * 3 + 1]) - ord('0')); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val); } + return $inputitem; } /** * encode Mode An * - * @param array $inputitem - * @param int $version * * @return array input item */ protected function encodeModeAn(array $inputitem, int $version): array { $words = (int)($inputitem['size'] / 2); - $inputitem['bstream'] = array(); + $inputitem['bstream'] = []; $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02); $inputitem['bstream'] = $this->appendNum( $inputitem['bstream'], @@ -87,28 +85,28 @@ protected function encodeModeAn(array $inputitem, int $version): array $inputitem['size'] ); for ($idx = 0; $idx < $words; ++$idx) { - $val = (int)($this->lookAnTable(ord($inputitem['data'][($idx * 2)])) * 45); - $val += (int)($this->lookAnTable(ord($inputitem['data'][($idx * 2) + 1]))); + $val = $this->lookAnTable(ord($inputitem['data'][($idx * 2)])) * 45; + $val += $this->lookAnTable(ord($inputitem['data'][($idx * 2) + 1])); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val); } - if ($inputitem['size'] & 1) { + + if (($inputitem['size'] & 1) !== 0) { $val = $this->lookAnTable(ord($inputitem['data'][($words * 2)])); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 6, $val); } + return $inputitem; } /** * encode Mode 8 * - * @param array $inputitem - * @param int $version * * @return array input item */ protected function encodeMode8(array $inputitem, int $version): array { - $inputitem['bstream'] = array(); + $inputitem['bstream'] = []; $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4); $inputitem['bstream'] = $this->appendNum( $inputitem['bstream'], @@ -118,20 +116,19 @@ protected function encodeMode8(array $inputitem, int $version): array for ($idx = 0; $idx < $inputitem['size']; ++$idx) { $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][$idx])); } + return $inputitem; } /** * encode Mode Kanji * - * @param array $inputitem - * @param int $version * * @return array input item */ protected function encodeModeKanji(array $inputitem, int $version): array { - $inputitem['bstream'] = array(); + $inputitem['bstream'] = []; $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8); $inputitem['bstream'] = $this->appendNum( $inputitem['bstream'], @@ -145,22 +142,23 @@ protected function encodeModeKanji(array $inputitem, int $version): array } else { $val -= 0xc140; } + $val = ($val & 0xff) + (($val >> 8) * 0xc0); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 13, $val); } + return $inputitem; } /** * encode Mode Structure * - * @param array $inputitem * * @return array input item */ protected function encodeModeStructure(array $inputitem): array { - $inputitem['bstream'] = array(); + $inputitem['bstream'] = []; $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x03); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, ord($inputitem['data'][1]) - 1); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, ord($inputitem['data'][0]) - 1); diff --git a/src/Type/Square/QrCode/Encoder.php b/src/Type/Square/QrCode/Encoder.php index e0188aae..a3ed9633 100644 --- a/src/Type/Square/QrCode/Encoder.php +++ b/src/Type/Square/QrCode/Encoder.php @@ -45,7 +45,7 @@ public function encodeMask(int $maskNo, array $datacode): array { // initialize values $this->datacode = $datacode; - $spec = $this->spc->getEccSpec($this->version, $this->level, array(0, 0, 0, 0, 0)); + $spec = $this->spc->getEccSpec($this->version, $this->level, [0, 0, 0, 0, 0]); $this->bv1 = $this->spc->rsBlockNum1($spec); $this->dataLength = $this->spc->rsDataLength($spec); $this->eccLength = $this->spc->rsEccLength($spec); @@ -61,19 +61,19 @@ public function encodeMask(int $maskNo, array $datacode): array $this->bit = -1; // interleaved data and ecc codes - for ($idx = 0; $idx < ($this->dataLength + $this->eccLength); $idx++) { + for ($idx = 0; $idx < ($this->dataLength + $this->eccLength); ++$idx) { $code = $this->getCode(); $bit = 0x80; - for ($jdx = 0; $jdx < 8; $jdx++) { + for ($jdx = 0; $jdx < 8; ++$jdx) { $addr = $this->getNextPosition(); $this->setFrameAt($addr, 0x02 | (($bit & $code) != 0)); - $bit = $bit >> 1; + $bit >>= 1; } } // remainder bits $rbits = $this->spc->getRemainder($this->version); - for ($idx = 0; $idx < $rbits; $idx++) { + for ($idx = 0; $idx < $rbits; ++$idx) { $addr = $this->getNextPosition(); $this->setFrameAt($addr, 0x02); } @@ -84,14 +84,16 @@ public function encodeMask(int $maskNo, array $datacode): array if ($this->qr_find_best_mask) { $mask = $this->mask($this->width, $this->frame, $this->level); } else { - $mask = $this->makeMask($this->width, $this->frame, (intval($this->qr_default_mask) % 8), $this->level); + $mask = $this->makeMask($this->width, $this->frame, ($this->qr_default_mask % 8), $this->level); } } else { $mask = $this->makeMask($this->width, $this->frame, $maskNo, $this->level); } + if ($mask == null) { throw new BarcodeException('Null Mask'); } + return $mask; } @@ -108,6 +110,7 @@ protected function getCode(): int if ($col >= $this->rsblocks[0]['dataLength']) { $row += $this->bv1; } + $ret = $this->rsblocks[$row]['data'][$col]; } elseif ($this->count < ($this->dataLength + $this->eccLength)) { $row = (($this->count - $this->dataLength) % $this->blocks); @@ -116,6 +119,7 @@ protected function getCode(): int } else { return 0; } + ++$this->count; return $ret; } @@ -141,8 +145,9 @@ protected function getNextPosition(): array do { if ($this->bit == -1) { $this->bit = 0; - return array('x' => $this->xpos, 'y' => $this->ypos); + return ['x' => $this->xpos, 'y' => $this->ypos]; } + $xpos = $this->xpos; $ypos = $this->ypos; $wdt = $this->width; @@ -150,19 +155,16 @@ protected function getNextPosition(): array if (($xpos < 0) || ($ypos < 0)) { throw new BarcodeException('Error getting next position'); } + $this->xpos = $xpos; $this->ypos = $ypos; } while (ord($this->frame[$ypos][$xpos]) & 0x80); - return array('x' => $xpos, 'y' => $ypos); + return ['x' => $xpos, 'y' => $ypos]; } /** * Internal cycle for getNextPosition - * - * @param int $xpos - * @param int $ypos - * @param int $wdt */ protected function getNextPositionB(int &$xpos, int &$ypos, int $wdt): void { @@ -174,6 +176,7 @@ protected function getNextPositionB(int &$xpos, int &$ypos, int $wdt): void $ypos += $this->dir; --$this->bit; } + if ($this->dir < 0) { if ($ypos < 0) { $ypos = 0; @@ -184,15 +187,13 @@ protected function getNextPositionB(int &$xpos, int &$ypos, int $wdt): void $ypos = 9; } } - } else { - if ($ypos == $wdt) { - $ypos = $wdt - 1; - $xpos -= 2; - $this->dir = -1; - if ($xpos == 6) { - --$xpos; - $ypos -= 8; - } + } elseif ($ypos === $wdt) { + $ypos = $wdt - 1; + $xpos -= 2; + $this->dir = -1; + if ($xpos == 6) { + --$xpos; + $ypos -= 8; } } } diff --git a/src/Type/Square/QrCode/EncodingMode.php b/src/Type/Square/QrCode/EncodingMode.php index 2b124d4d..fc72b946 100644 --- a/src/Type/Square/QrCode/EncodingMode.php +++ b/src/Type/Square/QrCode/EncodingMode.php @@ -45,12 +45,15 @@ public function getEncodingMode(string $data, int $pos): int if (!isset($data[$pos])) { return Data::ENC_MODES['NL']; } + if ($this->isDigitAt($data, $pos)) { return Data::ENC_MODES['NM']; } + if ($this->isAlphanumericAt($data, $pos)) { return Data::ENC_MODES['AN']; } + return $this->getEncodingModeKj($data, $pos); } @@ -70,6 +73,7 @@ protected function getEncodingModeKj(string $data, int $pos): int return Data::ENC_MODES['KJ']; } } + return Data::ENC_MODES['8B']; } @@ -78,14 +82,13 @@ protected function getEncodingModeKj(string $data, int $pos): int * * @param string $str Data * @param int $pos Character position - * - * @return bool */ public function isDigitAt(string $str, int $pos): bool { if (!isset($str[$pos])) { return false; } + return ((ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9'))); } @@ -94,14 +97,13 @@ public function isDigitAt(string $str, int $pos): bool * * @param string $str Data * @param int $pos Character position - * - * @return bool */ public function isAlphanumericAt(string $str, int $pos): bool { if (!isset($str[$pos])) { return false; } + return ($this->lookAnTable(ord($str[$pos])) >= 0); } @@ -118,9 +120,11 @@ protected function appendBitstream(array $bitstream, array $append): array if ((!is_array($append)) || (count($append) == 0)) { return $bitstream; } + if (count($bitstream) == 0) { return $append; } + return array_values(array_merge($bitstream, $append)); } @@ -136,8 +140,9 @@ protected function appendBitstream(array $bitstream, array $append): array protected function appendNum(array $bitstream, int $bits, int $num): array { if ($bits == 0) { - return array(); + return []; } + return $this->appendBitstream($bitstream, $this->newFromNum($bits, $num)); } @@ -153,8 +158,9 @@ protected function appendNum(array $bitstream, int $bits, int $num): array protected function appendBytes(array $bitstream, int $size, array $data): array { if ($size == 0) { - return array(); + return []; } + return $this->appendBitstream($bitstream, $this->newFromBytes($size, $data)); } @@ -171,13 +177,11 @@ protected function newFromNum(int $bits, int $num): array $bstream = $this->allocate($bits); $mask = 1 << ($bits - 1); for ($idx = 0; $idx < $bits; ++$idx) { - if ($num & $mask) { - $bstream[$idx] = 1; - } else { - $bstream[$idx] = 0; - } - $mask = $mask >> 1; + $bstream[$idx] = ($num & $mask) !== 0 ? 1 : 0; + + $mask >>= 1; } + return $bstream; } @@ -196,15 +200,13 @@ protected function newFromBytes(int $size, array $data): array for ($idx = 0; $idx < $size; ++$idx) { $mask = 0x80; for ($jdx = 0; $jdx < 8; ++$jdx) { - if ($data[$idx] & $mask) { - $bstream[$pval] = 1; - } else { - $bstream[$pval] = 0; - } - $pval++; - $mask = $mask >> 1; + $bstream[$pval] = ($data[$idx] & $mask) !== 0 ? 1 : 0; + + ++$pval; + $mask >>= 1; } } + return $bstream; } @@ -212,8 +214,6 @@ protected function newFromBytes(int $size, array $data): array * Return an array with zeros * * @param int $setLength Array size - * - * @return array */ protected function allocate(int $setLength): array { diff --git a/src/Type/Square/QrCode/Estimate.php b/src/Type/Square/QrCode/Estimate.php index db6b127d..494580ea 100644 --- a/src/Type/Square/QrCode/Estimate.php +++ b/src/Type/Square/QrCode/Estimate.php @@ -34,8 +34,6 @@ abstract class Estimate { /** * Encoding mode - * - * @var int */ protected int $hint = 2; @@ -44,15 +42,11 @@ abstract class Estimate * The Size of QRcode is defined as version. Version is an integer value from 1 to 40. * Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. * So version 40 is 177*177 matrix. - * - * @var int */ public int $version = 0; /** * Error correction level - * - * @var int */ protected int $level = 0; @@ -70,6 +64,7 @@ public function getLengthIndicator(int $mode, int $version): int if ($mode == Data::ENC_MODES['ST']) { return 0; } + if ($version <= 9) { $len = 0; } elseif ($version <= 26) { @@ -77,13 +72,13 @@ public function getLengthIndicator(int $mode, int $version): int } else { $len = 2; } + return Data::LEN_TABLE_BITS[$mode][$len]; } /** * estimateBitsModeNum * - * @param int $size * * @return int number of bits */ @@ -91,49 +86,44 @@ public function estimateBitsModeNum(int $size): int { $wdt = (int)($size / 3); $bits = ($wdt * 10); - switch ($size - ($wdt * 3)) { - case 1: - $bits += 4; - break; - case 2: - $bits += 7; - break; - } + match ($size - ($wdt * 3)) { + 1 => $bits += 4, + 2 => $bits += 7, + default => $bits, + }; return $bits; } /** * estimateBitsModeAn * - * @param int $size * * @return int number of bits */ public function estimateBitsModeAn(int $size): int { $bits = (int)($size * 5.5); // (size / 2 ) * 11 - if ($size & 1) { + if (($size & 1) !== 0) { $bits += 6; } + return $bits; } /** * estimateBitsMode8 * - * @param int $size * * @return int number of bits */ public function estimateBitsMode8(int $size): int { - return (int)($size * 8); + return $size * 8; } /** * estimateBitsModeKanji * - * @param int $size * * @return int number of bits */ @@ -145,8 +135,6 @@ public function estimateBitsModeKanji(int $size): int /** * Estimate version * - * @param array $items - * @param int $level * * @return int version */ @@ -162,6 +150,7 @@ public function estimateVersion(array $items, int $level): int return -1; } } while ($version > $prev); + return $version; } @@ -183,6 +172,7 @@ protected function getMinimumVersion(int $size, int $level): int return $idx; } } + throw new BarcodeException( 'The size of input data is greater than Data::QR capacity, try to lower the error correction mode' ); @@ -191,8 +181,6 @@ protected function getMinimumVersion(int $size, int $level): int /** * estimateBitStreamSize * - * @param array $items - * @param int $version * * @return int bits */ @@ -202,6 +190,7 @@ protected function estimateBitStreamSize(array $items, int $version): int if ($version == 0) { $version = 1; } + foreach ($items as $item) { switch ($item['mode']) { case Data::ENC_MODES['NM']: @@ -221,11 +210,13 @@ protected function estimateBitStreamSize(array $items, int $version): int default: return 0; } + $len = $this->getLengthIndicator($item['mode'], $version); $mod = 1 << $len; $num = (int)(($item['size'] + $mod - 1) / $mod); $bits += $num * (4 + $len); } + return $bits; } } diff --git a/src/Type/Square/QrCode/Init.php b/src/Type/Square/QrCode/Init.php index 516fc11c..d4b6c842 100644 --- a/src/Type/Square/QrCode/Init.php +++ b/src/Type/Square/QrCode/Init.php @@ -35,99 +35,70 @@ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask { /** * Data code - * - * @var array */ - protected array $datacode = array(); + protected array $datacode = []; /** * Error correction code - * - * @var array */ - protected array $ecccode = array(); + protected array $ecccode = []; /** * Blocks - * - * @var int */ protected int $blocks; /** * Reed-Solomon blocks - * - * @var array */ - protected array $rsblocks = array(); //of RSblock - + protected array $rsblocks = []; //of RSblock /** * Counter - * - * @var int */ protected int $count; /** * Data length - * - * @var int */ protected int $dataLength; /** * Error correction length - * - * @var int */ protected int $eccLength; /** * Value bv1 - * - * @var int */ protected int $bv1; /** * Width. - * - * @var int */ protected int $width; /** * Frame - * - * @var array */ - protected array $frame; + protected array $frame = []; /** * Horizontal bit position - * - * @var int */ protected int $xpos; /** * Vertical bit position - * - * @var int */ protected int $ypos; /** * Direction - * - * @var int */ protected int $dir; /** * Single bit value - * - * @var int */ protected int $bit; @@ -136,7 +107,7 @@ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask * * @va array */ - protected array $rsitems = array(); + protected array $rsitems = []; /** * Initialize code @@ -157,27 +128,20 @@ protected function init(array $spec): void if ($this->spc->rsBlockNum2($spec) == 0) { return; } + $dlv = $this->spc->rsDataCodes2($spec); $elv = $this->spc->rsEccCodes2($spec); $rsv = $this->initRs(8, 0x11d, 0, 1, $elv, 255 - $dlv - $elv); if ($rsv == null) { throw new BarcodeException('Empty RS'); } + $endfor = $this->spc->rsBlockNum2($spec); $this->initLoop($endfor, $dlv, $elv, $rsv, $eccPos, $blockNo, $dataPos, $ecc); } /** * Internal loop for init - * - * @param int $endfor - * @param int $dlv - * @param int $elv - * @param array $rsv - * @param int $eccPos - * @param int $blockNo - * @param int $dataPos - * @param array $ecc */ protected function initLoop( int $endfor, @@ -192,7 +156,7 @@ protected function initLoop( { for ($idx = 0; $idx < $endfor; ++$idx) { $ecc = array_slice($this->ecccode, $eccPos); - $this->rsblocks[$blockNo] = array(); + $this->rsblocks[$blockNo] = []; $this->rsblocks[$blockNo]['dataLength'] = $dlv; $this->rsblocks[$blockNo]['data'] = array_slice($this->datacode, $dataPos); $this->rsblocks[$blockNo]['eccLength'] = $elv; @@ -201,7 +165,7 @@ protected function initLoop( $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc); $dataPos += $dlv; $eccPos += $elv; - $blockNo++; + ++$blockNo; } } @@ -239,18 +203,33 @@ protected function initRs( ): array { foreach ($this->rsitems as $rsv) { - if ( - ($rsv['pad'] != $pad) - || ($rsv['nroots'] != $nroots) - || ($rsv['mm'] != $symsize) - || ($rsv['gfpoly'] != $gfpoly) - || ($rsv['fcr'] != $fcr) - || ($rsv['prim'] != $prim) - ) { + if ($rsv['pad'] != $pad) { + continue; + } + + if ($rsv['nroots'] != $nroots) { + continue; + } + + if ($rsv['mm'] != $symsize) { continue; } + + if ($rsv['gfpoly'] != $gfpoly) { + continue; + } + + if ($rsv['fcr'] != $fcr) { + continue; + } + + if ($rsv['prim'] != $prim) { + continue; + } + return $rsv; } + $rsv = $this->initRsChar($symsize, $gfpoly, $fcr, $prim, $nroots, $pad); array_unshift($this->rsitems, $rsv); return $rsv; @@ -270,6 +249,7 @@ protected function modnn(array $rsv, int $xpos): int $xpos -= $rsv['nn']; $xpos = (($xpos >> $rsv['mm']) + ($xpos & $rsv['nn'])); } + return $xpos; } @@ -354,7 +334,7 @@ protected function initRsChar( { $this->checkRsCharParamsA($symsize, $fcr, $prim); $this->checkRsCharParamsB($symsize, $nroots, $pad); - $rsv = array(); + $rsv = []; $rsv['mm'] = $symsize; $rsv['nn'] = ((1 << $symsize) - 1); $rsv['pad'] = $pad; @@ -371,14 +351,17 @@ protected function initRsChar( $rsv['index_of'][$srv] = $idx; $rsv['alpha_to'][$idx] = $srv; $srv <<= 1; - if ($srv & (1 << $symsize)) { + if (($srv & (1 << $symsize)) !== 0) { $srv ^= $gfpoly; } + $srv &= $rsv['nn']; } + if ($srv != 1) { throw new BarcodeException('field generator polynomial is not primitive!'); } + // form RS code generator polynomial from its roots $rsv['genpoly'] = array_fill(0, ($nroots + 1), 0); $rsv['fcr'] = $fcr; @@ -386,9 +369,10 @@ protected function initRsChar( $rsv['nroots'] = $nroots; $rsv['gfpoly'] = $gfpoly; // find prim-th root of 1, used in decoding - for ($iprim = 1; ($iprim % $prim) != 0; $iprim += $rsv['nn']) { + for ($iprim = 1; $iprim % $prim != 0; $iprim += $rsv['nn']) { ; // intentional empty-body loop! } + $rsv['iprim'] = (int)($iprim / $prim); $rsv['genpoly'][0] = 1; for ($idx = 0, $root = ($fcr * $prim); $idx < $nroots; ++$idx, $root += $prim) { @@ -402,13 +386,16 @@ protected function initRsChar( $rsv['genpoly'][$jdx] = $rsv['genpoly'][($jdx - 1)]; } } + // rs->genpoly[0] can never be zero $rsv['genpoly'][0] = $rsv['alpha_to'][$this->modnn($rsv, $rsv['index_of'][$rsv['genpoly'][0]] + $root)]; } + // convert rs->genpoly[] to index form for quicker encoding for ($idx = 0; $idx <= $nroots; ++$idx) { $rsv['genpoly'][$idx] = $rsv['index_of'][$rsv['genpoly'][$idx]]; } + return $rsv; } @@ -455,14 +442,12 @@ protected function encodeRsChar( $parity[$jdx] ^= $alphato[$this->modnn($rsv, $feedback + $genpoly[($nroots - $jdx)])]; } } + // Shift array_shift($parity); - if ($feedback != $azv) { - array_push($parity, $alphato[$this->modnn($rsv, $feedback + $genpoly[0])]); - } else { - array_push($parity, 0); - } + $parity[] = $feedback != $azv ? $alphato[$this->modnn($rsv, $feedback + $genpoly[0])] : 0; } + return $parity; } } diff --git a/src/Type/Square/QrCode/InputItem.php b/src/Type/Square/QrCode/InputItem.php index 1c1df225..6501b6f2 100644 --- a/src/Type/Square/QrCode/InputItem.php +++ b/src/Type/Square/QrCode/InputItem.php @@ -36,8 +36,6 @@ abstract class InputItem extends \Com\Tecnick\Barcode\Type\Square\QrCode\Estimat * Look up the alphabet-numeric conversion table (see JIS X0510:2004, pp.19) * * @param int $chr Character value - * - * @return int */ public function lookAnTable(int $chr): int { @@ -63,9 +61,10 @@ public function appendNewInputItem( ): array { $newitem = $this->newInputItem($mode, $size, $data); - if (!empty($newitem)) { + if ($newitem !== []) { $items[] = $newitem; } + return $items; } @@ -90,15 +89,12 @@ protected function newInputItem( if (count($setData) < $size) { $setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0)); } + if (!$this->check($mode, $size, $setData)) { throw new BarcodeException('Invalid input item'); } - return array( - 'mode' => $mode, - 'size' => $size, - 'data' => $setData, - 'bstream' => $bstream, - ); + + return ['mode' => $mode, 'size' => $size, 'data' => $setData, 'bstream' => $bstream]; } /** @@ -119,26 +115,20 @@ protected function check( if ($size <= 0) { return false; } - switch ($mode) { - case Data::ENC_MODES['NM']: - return $this->checkModeNum($size, $data); - case Data::ENC_MODES['AN']: - return $this->checkModeAn($size, $data); - case Data::ENC_MODES['KJ']: - return $this->checkModeKanji($size, $data); - case Data::ENC_MODES['8B']: - return true; - case Data::ENC_MODES['ST']: - return true; - } - return false; + + return match ($mode) { + Data::ENC_MODES['NM'] => $this->checkModeNum($size, $data), + Data::ENC_MODES['AN'] => $this->checkModeAn($size, $data), + Data::ENC_MODES['KJ'] => $this->checkModeKanji($size, $data), + Data::ENC_MODES['8B'] => true, + Data::ENC_MODES['ST'] => true, + default => false, + }; } /** * checkModeNum * - * @param int $size - * @param array $data * * @return bool true or false */ @@ -149,14 +139,13 @@ protected function checkModeNum(int $size, array $data): bool return false; } } + return true; } /** * checkModeAn * - * @param int $size - * @param array $data * * @return bool true or false */ @@ -167,28 +156,29 @@ protected function checkModeAn(int $size, array $data): bool return false; } } + return true; } /** * checkModeKanji * - * @param int $size - * @param array $data * * @return bool true or false */ protected function checkModeKanji(int $size, array $data): bool { - if ($size & 1) { + if (($size & 1) !== 0) { return false; } + for ($idx = 0; $idx < $size; $idx += 2) { $val = (ord($data[$idx]) << 8) | ord($data[($idx + 1)]); if (($val < 0x8140) || (($val > 0x9ffc) && ($val < 0xe040)) || ($val > 0xebbf)) { return false; } } + return true; } } diff --git a/src/Type/Square/QrCode/Mask.php b/src/Type/Square/QrCode/Mask.php index 0f37dfbb..fc65d864 100644 --- a/src/Type/Square/QrCode/Mask.php +++ b/src/Type/Square/QrCode/Mask.php @@ -33,57 +33,13 @@ */ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum { - /** - * If false, checks all masks available, - * otherwise the value indicates the number of masks to be checked, mask id are random - * - * @var bool - */ - protected bool $qr_find_from_random = false; - - /** - * If true, estimates best mask (spec. default, but extremally slow; - * set to false to significant performance boost but (propably) worst quality code - * - * @var bool - */ - protected bool $qr_find_best_mask = true; - - /** - * Default mask used when $this->qr_find_best_mask === false - * - * @var int - */ - protected int $qr_default_mask = 2; - /** * Run length - * - * @var array - */ - protected array $runLength = array(); - - /** - * QR code version. - * The Size of QRcode is defined as version. Version is an integer value from 1 to 40. - * Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. - * So version 40 is 177*177 matrix. - * - * @var int */ - public int $version = 0; - - /** - * Error correction level - * - * @var int - */ - protected int $level = 0; + protected array $runLength = []; /** * Spec class object - * - * @var Spec */ protected Spec $spc; @@ -92,24 +48,28 @@ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum * * @param int $version Code version * @param int $level Error Correction Level - * @param bool $random_mask If false, checks all masks available, + * @param bool $qr_find_from_random If false, checks all masks available, * otherwise the value indicates the number of masks to be checked, mask id are random - * @param bool $best_mask If true, estimates best mask (slow) - * @param int $default_mask Default mask used when $fbm is false + * @param bool $qr_find_best_mask If true, estimates best mask (slow) + * @param int $qr_default_mask Default mask used when $fbm is false */ public function __construct( - int $version, - int $level, - bool $random_mask = false, - bool $best_mask = true, - int $default_mask = 2 + /** + * QR code version. + * The Size of QRcode is defined as version. Version is an integer value from 1 to 40. + * Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. + * So version 40 is 177*177 matrix. + */ + public int $version, + /** + * Error correction level + */ + protected int $level, + protected bool $qr_find_from_random = false, + protected bool $qr_find_best_mask = true, + protected int $qr_default_mask = 2 ) { - $this->version = $version; - $this->level = $level; - $this->qr_find_from_random = (bool)$random_mask; - $this->qr_find_best_mask = (bool)$best_mask; - $this->qr_default_mask = intval($default_mask); $this->spc = new Spec(); } @@ -129,31 +89,32 @@ protected function mask( ): array { $minDemerit = PHP_INT_MAX; - $bestMask = array(); - $checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7); - if ($this->qr_find_from_random !== false) { + $bestMask = []; + $checked_masks = [0, 1, 2, 3, 4, 5, 6, 7]; + if ($this->qr_find_from_random) { $howManuOut = (8 - ($this->qr_find_from_random % 9)); for ($idx = 0; $idx < $howManuOut; ++$idx) { - $remPos = rand(0, (count($checked_masks) - 1)); + $remPos = random_int(0, (count($checked_masks) - 1)); unset($checked_masks[$remPos]); $checked_masks = array_values($checked_masks); } } + $bestMask = $frame; - foreach ($checked_masks as $idx) { + foreach ($checked_masks as $checked_mask) { $mask = array_fill(0, $width, str_repeat("\0", $width)); $demerit = 0; - $blacks = 0; - $blacks = $this->makeMaskNo($idx, $width, $frame, $mask); - $blacks += $this->writeFormatInformation($width, $mask, $idx, $level); + $blacks = $this->makeMaskNo($checked_mask, $width, $frame, $mask); + $blacks += $this->writeFormatInformation($width, $mask, $checked_mask, $level); $blacks = (int)(100 * $blacks / ($width * $width)); - $demerit = (int)((int)(abs($blacks - 50) / 5) * Data::N4); + $demerit = (int)(abs($blacks - 50) / 5) * Data::N4; $demerit += $this->evaluateSymbol($width, $mask); if ($demerit < $minDemerit) { $minDemerit = $demerit; $bestMask = $mask; } } + return $bestMask; } @@ -200,35 +161,41 @@ protected function writeFormatInformation( $spec = new Spec(); $format = $spec->getFormatInfo($maskNo, $level); for ($idx = 0; $idx < 8; ++$idx) { - if ($format & 1) { + if (($format & 1) !== 0) { $blacks += 2; $val = 0x85; } else { $val = 0x84; } + $frame[8][($width - 1 - $idx)] = chr($val); if ($idx < 6) { $frame[$idx][8] = chr($val); } else { $frame[($idx + 1)][8] = chr($val); } - $format = $format >> 1; + + $format >>= 1; } + for ($idx = 0; $idx < 7; ++$idx) { - if ($format & 1) { + if (($format & 1) !== 0) { $blacks += 2; $val = 0x85; } else { $val = 0x84; } + $frame[($width - 7 + $idx)][8] = chr($val); if ($idx == 0) { $frame[8][7] = chr($val); } else { $frame[8][(6 - $idx)] = chr($val); } - $format = $format >> 1; + + $format >>= 1; } + return $blacks; } @@ -237,20 +204,16 @@ protected function writeFormatInformation( * * @param int $width Width * @param array $frame Frame - * - * @return int */ protected function evaluateSymbol(int $width, array $frame): int { - $frameY = $frameYM = $frame[0]; + $frameY = $frame[0]; + $frameYM = $frame[0]; for ($ypos = 0; $ypos < $width; ++$ypos) { $frameY = $frame[$ypos]; - if ($ypos > 0) { - $frameYM = $frame[($ypos - 1)]; - } else { - $frameYM = $frameY; - } + $frameYM = $ypos > 0 ? $frame[($ypos - 1)] : $frameY; } + $demerit = $this->evaluateSymbolB($ypos, $width, $frameY, $frameYM); for ($xpos = 0; $xpos < $width; ++$xpos) { $head = 0; @@ -261,16 +224,18 @@ protected function evaluateSymbol(int $width, array $frame): int $head = 1; $this->runLength[$head] = 1; } elseif ($ypos > 0) { - if ((ord($frame[$ypos][$xpos]) ^ ord($frame[($ypos - 1)][$xpos])) & 1) { - $head++; + if (((ord($frame[$ypos][$xpos]) ^ ord($frame[($ypos - 1)][$xpos])) & 1) !== 0) { + ++$head; $this->runLength[$head] = 1; } else { - $this->runLength[$head]++; + ++$this->runLength[$head]; } } } + $demerit += $this->calcN1N3($head + 1); } + return $demerit; } @@ -279,8 +244,6 @@ protected function evaluateSymbol(int $width, array $frame): int * * @param int $ypos Y position * @param int $width Width - * @param string $frameY - * @param string $frameYM * * @return int demerit */ @@ -304,30 +267,31 @@ protected function evaluateSymbolB( | ord($frameY[($xpos - 1)]) | ord($frameYM[$xpos]) | ord($frameYM[($xpos - 1)]); - if (($b22 | ($w22 ^ 1)) & 1) { + if ((($b22 | ($w22 ^ 1)) & 1) !== 0) { $demerit += Data::N2; } } + if (($xpos == 0) && (ord($frameY[$xpos]) & 1)) { $this->runLength[0] = -1; $head = 1; $this->runLength[$head] = 1; } elseif ($xpos > 0) { - if ((ord($frameY[$xpos]) ^ ord($frameY[($xpos - 1)])) & 1) { - $head++; + if (((ord($frameY[$xpos]) ^ ord($frameY[($xpos - 1)])) & 1) !== 0) { + ++$head; $this->runLength[$head] = 1; } else { ++$this->runLength[$head]; } } } + return ($demerit + $this->calcN1N3($head + 1)); } /** * Calc N1 N3 * - * @param int $length * * @return int demerit */ @@ -338,18 +302,18 @@ protected function calcN1N3(int $length): int if ($this->runLength[$idx] >= 5) { $demerit += (Data::N1 + ($this->runLength[$idx] - 5)); } + if (($idx & 1) && ($idx >= 3) && ($idx < ($length - 2)) && ($this->runLength[$idx] % 3 == 0)) { $demerit += $this->calcN1N3delta($length, $idx); } } + return $demerit; } /** * Calc N1 N3 delta * - * @param int $length - * @param int $idx * * @return int demerit delta */ @@ -364,10 +328,13 @@ protected function calcN1N3delta(int $length, int $idx): int ) { if (($this->runLength[($idx - 3)] < 0) || ($this->runLength[($idx - 3)] >= (4 * $fact))) { return Data::N3; - } elseif ((($idx + 3) >= $length) || ($this->runLength[($idx + 3)] >= (4 * $fact))) { + } + + if ((($idx + 3) >= $length) || ($this->runLength[($idx + 3)] >= (4 * $fact))) { return Data::N3; } } + return 0; } } diff --git a/src/Type/Square/QrCode/MaskNum.php b/src/Type/Square/QrCode/MaskNum.php index 9ab4f47d..b623536f 100644 --- a/src/Type/Square/QrCode/MaskNum.php +++ b/src/Type/Square/QrCode/MaskNum.php @@ -57,9 +57,11 @@ protected function makeMaskNo( if ($bitMask[$ypos][$xpos] == 1) { $mask[$ypos][$xpos] = chr(ord($frame[$ypos][$xpos]) ^ ((int)($bitMask[$ypos][$xpos]))); } - $bnum += (int)(ord($mask[$ypos][$xpos]) & 1); + + $bnum += ord($mask[$ypos][$xpos]) & 1; } } + return $bnum; } @@ -81,14 +83,15 @@ protected function generateMaskNo( $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); for ($ypos = 0; $ypos < $width; ++$ypos) { for ($xpos = 0; $xpos < $width; ++$xpos) { - if (ord($frame[$ypos][$xpos]) & 0x80) { + if ((ord($frame[$ypos][$xpos]) & 0x80) !== 0) { $bitMask[$ypos][$xpos] = 0; } else { - $maskFunc = call_user_func(array($this, 'mask' . $maskNo), $xpos, $ypos); + $maskFunc = call_user_func([$this, 'mask' . $maskNo], $xpos, $ypos); $bitMask[$ypos][$xpos] = (($maskFunc == 0) ? 1 : 0); } } } + return $bitMask; } @@ -115,7 +118,6 @@ protected function mask0(int $xpos, int $ypos): int */ protected function mask1(int $xpos, int $ypos): int { - $xpos = null; return ($ypos & 1); } @@ -129,7 +131,6 @@ protected function mask1(int $xpos, int $ypos): int */ protected function mask2(int $xpos, int $ypos): int { - $ypos = null; return ($xpos % 3); } diff --git a/src/Type/Square/QrCode/Spec.php b/src/Type/Square/QrCode/Spec.php index 4ce026df..1214c880 100644 --- a/src/Type/Square/QrCode/Spec.php +++ b/src/Type/Square/QrCode/Spec.php @@ -95,6 +95,7 @@ public function maximumWords(int $mode, int $version): int if ($mode == Data::ENC_MODES['ST']) { return 3; } + if ($version <= 9) { $lval = 0; } elseif ($version <= 26) { @@ -102,11 +103,13 @@ public function maximumWords(int $mode, int $version): int } else { $lval = 2; } + $bits = Data::LEN_TABLE_BITS[$mode][$lval]; $words = (1 << $bits) - 1; if ($mode == Data::ENC_MODES['KJ']) { $words *= 2; // the number of bytes is required } + return $words; } @@ -123,8 +126,9 @@ public function maximumWords(int $mode, int $version): int public function getEccSpec(int $version, int $level, array $spec): array { if (count($spec) < 5) { - $spec = array(0, 0, 0, 0, 0); + $spec = [0, 0, 0, 0, 0]; } + $bv1 = Data::ECC_TABLE[$version][$level][0]; $bv2 = Data::ECC_TABLE[$version][$level][1]; $data = $this->getDataLength($version, $level); @@ -142,6 +146,7 @@ public function getEccSpec(int $version, int $level, array $spec): array $spec[3] = $bv2; $spec[4] = $spec[1] + 1; } + return $spec; } @@ -150,8 +155,6 @@ public function getEccSpec(int $version, int $level, array $spec): array * * @param int $maskNo Mask number * @param int $level Error correction level - * - * @return int */ public function getFormatInfo(int $maskNo, int $level): int { @@ -163,6 +166,7 @@ public function getFormatInfo(int $maskNo, int $level): int ) { return 0; } + return Data::FORMAT_INFO[$level][$maskNo]; } } diff --git a/src/Type/Square/QrCode/SpecRs.php b/src/Type/Square/QrCode/SpecRs.php index 237a849b..d3b0e141 100644 --- a/src/Type/Square/QrCode/SpecRs.php +++ b/src/Type/Square/QrCode/SpecRs.php @@ -37,7 +37,6 @@ abstract class SpecRs /** * Return block number 0 * - * @param array $spec * * @return int value */ @@ -49,7 +48,6 @@ public function rsBlockNum(array $spec): int /** * Return block number 1 * - * @param array $spec * * @return int value */ @@ -61,7 +59,6 @@ public function rsBlockNum1(array $spec): int /** * Return data codes 1 * - * @param array $spec * * @return int value */ @@ -73,7 +70,6 @@ public function rsDataCodes1(array $spec): int /** * Return ecc codes 1 * - * @param array $spec * * @return int value */ @@ -85,7 +81,6 @@ public function rsEccCodes1(array $spec): int /** * Return block number 2 * - * @param array $spec * * @return int value */ @@ -97,7 +92,6 @@ public function rsBlockNum2(array $spec): int /** * Return data codes 2 * - * @param array $spec * * @return int value */ @@ -109,7 +103,6 @@ public function rsDataCodes2(array $spec): int /** * Return ecc codes 2 * - * @param array $spec * * @return int value */ @@ -121,7 +114,6 @@ public function rsEccCodes2(array $spec): int /** * Return data length * - * @param array $spec * * @return int value */ @@ -133,7 +125,6 @@ public function rsDataLength(array $spec): int /** * Return ecc length * - * @param array $spec * * @return int value */ @@ -166,6 +157,7 @@ public function createFrame(int $version): array $frame[$yOffset][7] = "\xc0"; ++$yOffset; } + $setPattern = str_repeat("\xc0", 8); $frame = $this->qrstrset($frame, 0, 7, $setPattern); $frame = $this->qrstrset($frame, $width - 8, 7, $setPattern); @@ -174,17 +166,20 @@ public function createFrame(int $version): array $setPattern = str_repeat("\x84", 9); $frame = $this->qrstrset($frame, 0, 8, $setPattern); $frame = $this->qrstrset($frame, $width - 8, 8, $setPattern, 8); + $yOffset = $width - 8; for ($ypos = 0; $ypos < 8; ++$ypos, ++$yOffset) { $frame[$ypos][8] = "\x84"; $frame[$yOffset][8] = "\x84"; } + // Timing pattern $wdo = $width - 15; for ($idx = 1; $idx < $wdo; ++$idx) { $frame[6][(7 + $idx)] = chr(0x90 | ($idx & 1)); $frame[(7 + $idx)][6] = chr(0x90 | ($idx & 1)); } + // Alignment pattern $frame = $this->putAlignmentPattern($version, $frame, $width); // Version information @@ -194,17 +189,19 @@ public function createFrame(int $version): array for ($xpos = 0; $xpos < 6; ++$xpos) { for ($ypos = 0; $ypos < 3; ++$ypos) { $frame[(($width - 11) + $ypos)][$xpos] = chr(0x88 | ($val & 1)); - $val = $val >> 1; + $val >>= 1; } } + $val = $vinf; for ($ypos = 0; $ypos < 6; ++$ypos) { for ($xpos = 0; $xpos < 3; ++$xpos) { $frame[$ypos][($xpos + ($width - 11))] = chr(0x88 | ($val & 1)); - $val = $val >> 1; + $val >>= 1; } } } + // and a little bit... $frame[$width - 8][8] = "\x81"; return $frame; @@ -213,12 +210,10 @@ public function createFrame(int $version): array /** * Replace a value on the array at the specified position * - * @param array $srctab * @param int $xpos X position * @param int $ypos Y position * @param string $repl Value to replace * @param int $replLen Length of the repl string - * * @return array srctab */ public function qrstrset( @@ -233,7 +228,7 @@ public function qrstrset( $srctab[$ypos], ($replLen !== null) ? substr($repl, 0, $replLen) : $repl, $xpos, - ($replLen !== null) ? $replLen : strlen($repl) + $replLen ?? strlen($repl) ); return $srctab; } @@ -253,18 +248,13 @@ public function putAlignmentMarker( int $poy ): array { - $finder = array( - "\xa1\xa1\xa1\xa1\xa1", - "\xa1\xa0\xa0\xa0\xa1", - "\xa1\xa0\xa1\xa0\xa1", - "\xa1\xa0\xa0\xa0\xa1", - "\xa1\xa1\xa1\xa1\xa1" - ); + $finder = ["\xa1\xa1\xa1\xa1\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa0\xa1\xa0\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa1\xa1\xa1\xa1"]; $yStart = $poy - 2; $xStart = $pox - 2; for ($ydx = 0; $ydx < 5; ++$ydx) { $frame = $this->qrstrset($frame, $xStart, ($yStart + $ydx), $finder[$ydx]); } + return $frame; } @@ -283,18 +273,11 @@ public function putFinderPattern( int $poy ): array { - $finder = array( - "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", - "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", - "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", - "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", - "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", - "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", - "\xc1\xc1\xc1\xc1\xc1\xc1\xc1" - ); + $finder = ["\xc1\xc1\xc1\xc1\xc1\xc1\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc1\xc1\xc1\xc1\xc1\xc1"]; for ($ypos = 0; $ypos < 7; ++$ypos) { $frame = $this->qrstrset($frame, $pox, ($poy + $ypos), $finder[$ypos]); } + return $frame; } @@ -303,14 +286,13 @@ public function putFinderPattern( * Use lower 18 bits. * * @param int $version Version - * - * @return int */ public function getVersionPattern(int $version): int { if (($version < 7) || ($version > Data::QRSPEC_VERSION_MAX)) { return 0; } + return Data::VERSION_PATTERN[($version - 7)]; } @@ -332,18 +314,20 @@ public function putAlignmentPattern( if ($version < 2) { return $frame; } + $dval = Data::ALIGN_PATTERN[$version][1] - Data::ALIGN_PATTERN[$version][0]; if ($dval < 0) { $wdt = 2; } else { $wdt = (int)(($width - Data::ALIGN_PATTERN[$version][0]) / $dval + 2); } + if ($wdt * $wdt - 3 == 1) { $psx = Data::ALIGN_PATTERN[$version][0]; $psy = Data::ALIGN_PATTERN[$version][0]; - $frame = $this->putAlignmentMarker($frame, $psx, $psy); - return $frame; + return $this->putAlignmentMarker($frame, $psx, $psy); } + $cpx = Data::ALIGN_PATTERN[$version][0]; $wdo = $wdt - 1; for ($xpos = 1; $xpos < $wdo; ++$xpos) { @@ -351,6 +335,7 @@ public function putAlignmentPattern( $frame = $this->putAlignmentMarker($frame, $cpx, 6); $cpx += $dval; } + $cpy = Data::ALIGN_PATTERN[$version][0]; for ($y = 0; $y < $wdo; ++$y) { $cpx = Data::ALIGN_PATTERN[$version][0]; @@ -358,8 +343,10 @@ public function putAlignmentPattern( $frame = $this->putAlignmentMarker($frame, $cpx, $cpy); $cpx += $dval; } + $cpy += $dval; } + return $frame; } } diff --git a/src/Type/Square/QrCode/Split.php b/src/Type/Square/QrCode/Split.php index cce1c040..732834fb 100644 --- a/src/Type/Square/QrCode/Split.php +++ b/src/Type/Square/QrCode/Split.php @@ -34,54 +34,36 @@ */ class Split { - /** - * EncodingMode class object - * - * @var EncodingMode - */ - protected EncodingMode $bsObj; - /** * Input items - * - * @var array */ - protected array $items = array(); - - /** - * QR code version. - * The Size of QRcode is defined as version. Version is an integer value from 1 to 40. - * Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. - * So version 40 is 177*177 matrix. - * - * @var int - */ - protected int $version = 0; - - /** - * Encoding mode - * - * @var int - */ - protected int $hint = 2; + protected array $items = []; /** * Initialize * - * @param ByteStream $bsObj ByteStream Class object + * @param ByteStream $encodingMode ByteStream Class object * @param int $hint Encoding mode * @param int $version Code version */ public function __construct( - ByteStream $bsObj, - int $hint, - int $version + /** + * EncodingMode class object + */ + protected EncodingMode $encodingMode, + /** + * Encoding mode + */ + protected int $hint, + /** + * QR code version. + * The Size of QRcode is defined as version. Version is an integer value from 1 to 40. + * Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. + * So version 40 is 177*177 matrix. + */ + protected int $version ) { - $this->bsObj = $bsObj; - $this->items = array(); - $this->hint = $hint; - $this->version = $version; } /** @@ -94,7 +76,7 @@ public function __construct( public function getSplittedString(string $data): array { while (strlen($data) > 0) { - $mode = $this->bsObj->getEncodingMode($data, 0); + $mode = $this->encodingMode->getEncodingMode($data, 0); switch ($mode) { case Data::ENC_MODES['NM']: $length = $this->eatNum($data); @@ -108,19 +90,24 @@ public function getSplittedString(string $data): array } else { $length = $this->eat8($data); } + break; default: $length = $this->eat8($data); break; } + if ($length == 0) { break; } + if ($length < 0) { throw new BarcodeException('Error while splitting the input data'); } + $data = substr($data, $length); } + return $this->items; } @@ -133,29 +120,32 @@ public function getSplittedString(string $data): array */ protected function eatNum(string $data): int { - $lng = $this->bsObj->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); + $lng = $this->encodingMode->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); $pos = 0; - while ($this->bsObj->isDigitAt($data, $pos)) { - $pos++; + while ($this->encodingMode->isDigitAt($data, $pos)) { + ++$pos; } - $mode = $this->bsObj->getEncodingMode($data, $pos); + + $mode = $this->encodingMode->getEncodingMode($data, $pos); if ($mode == Data::ENC_MODES['8B']) { - $dif = $this->bsObj->estimateBitsModeNum($pos) + 4 + $lng - + $this->bsObj->estimateBitsMode8(1) // + 4 + l8 - - $this->bsObj->estimateBitsMode8($pos + 1); // - 4 - l8 + $dif = $this->encodingMode->estimateBitsModeNum($pos) + 4 + $lng + + $this->encodingMode->estimateBitsMode8(1) // + 4 + l8 + - $this->encodingMode->estimateBitsMode8($pos + 1); // - 4 - l8 if ($dif > 0) { return $this->eat8($data); } } + if ($mode == Data::ENC_MODES['AN']) { - $dif = $this->bsObj->estimateBitsModeNum($pos) + 4 + $lng - + $this->bsObj->estimateBitsModeAn(1) // + 4 + la - - $this->bsObj->estimateBitsModeAn($pos + 1);// - 4 - la + $dif = $this->encodingMode->estimateBitsModeNum($pos) + 4 + $lng + + $this->encodingMode->estimateBitsModeAn(1) // + 4 + la + - $this->encodingMode->estimateBitsModeAn($pos + 1);// - 4 - la if ($dif > 0) { return $this->eatAn($data); } } - $this->items = $this->bsObj->appendNewInputItem( + + $this->items = $this->encodingMode->appendNewInputItem( $this->items, Data::ENC_MODES['NM'], $pos, @@ -173,36 +163,39 @@ protected function eatNum(string $data): int */ protected function eatAn(string $data): int { - $lag = $this->bsObj->getLengthIndicator(Data::ENC_MODES['AN'], $this->version); - $lng = $this->bsObj->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); + $lag = $this->encodingMode->getLengthIndicator(Data::ENC_MODES['AN'], $this->version); + $lng = $this->encodingMode->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); $pos = 1 ; - while ($this->bsObj->isAlphanumericAt($data, $pos)) { - if ($this->bsObj->isDigitAt($data, $pos)) { + while ($this->encodingMode->isAlphanumericAt($data, $pos)) { + if ($this->encodingMode->isDigitAt($data, $pos)) { $qix = $pos; - while ($this->bsObj->isDigitAt($data, $qix)) { - $qix++; + while ($this->encodingMode->isDigitAt($data, $qix)) { + ++$qix; } - $dif = $this->bsObj->estimateBitsModeAn($pos) // + 4 + lag - + $this->bsObj->estimateBitsModeNum($qix - $pos) + 4 + $lng - - $this->bsObj->estimateBitsModeAn($qix); // - 4 - la + + $dif = $this->encodingMode->estimateBitsModeAn($pos) // + 4 + lag + + $this->encodingMode->estimateBitsModeNum($qix - $pos) + 4 + $lng + - $this->encodingMode->estimateBitsModeAn($qix); // - 4 - la if ($dif < 0) { break; } else { $pos = $qix; } } else { - $pos++; + ++$pos; } } - if (!$this->bsObj->isAlphanumericAt($data, $pos)) { - $dif = $this->bsObj->estimateBitsModeAn($pos) + 4 + $lag - + $this->bsObj->estimateBitsMode8(1) // + 4 + l8 - - $this->bsObj->estimateBitsMode8($pos + 1); // - 4 - l8 + + if (!$this->encodingMode->isAlphanumericAt($data, $pos)) { + $dif = $this->encodingMode->estimateBitsModeAn($pos) + 4 + $lag + + $this->encodingMode->estimateBitsMode8(1) // + 4 + l8 + - $this->encodingMode->estimateBitsMode8($pos + 1); // - 4 - l8 if ($dif > 0) { return $this->eat8($data); } } - $this->items = $this->bsObj->appendNewInputItem( + + $this->items = $this->encodingMode->appendNewInputItem( $this->items, Data::ENC_MODES['AN'], $pos, @@ -221,10 +214,11 @@ protected function eatAn(string $data): int protected function eatKanji(string $data): int { $pos = 0; - while ($this->bsObj->getEncodingMode($data, $pos) == Data::ENC_MODES['KJ']) { + while ($this->encodingMode->getEncodingMode($data, $pos) == Data::ENC_MODES['KJ']) { $pos += 2; } - $this->items = $this->bsObj->appendNewInputItem( + + $this->items = $this->encodingMode->appendNewInputItem( $this->items, Data::ENC_MODES['KJ'], $pos, @@ -242,23 +236,25 @@ protected function eatKanji(string $data): int */ protected function eat8(string $data): int { - $lag = $this->bsObj->getLengthIndicator(Data::ENC_MODES['AN'], $this->version); - $lng = $this->bsObj->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); + $lag = $this->encodingMode->getLengthIndicator(Data::ENC_MODES['AN'], $this->version); + $lng = $this->encodingMode->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); $pos = 1; $dataStrLen = strlen($data); while ($pos < $dataStrLen) { - $mode = $this->bsObj->getEncodingMode($data, $pos); + $mode = $this->encodingMode->getEncodingMode($data, $pos); if ($mode == Data::ENC_MODES['KJ']) { break; } + if ($mode == Data::ENC_MODES['NM']) { $qix = $pos; - while ($this->bsObj->isDigitAt($data, $qix)) { - $qix++; + while ($this->encodingMode->isDigitAt($data, $qix)) { + ++$qix; } - $dif = $this->bsObj->estimateBitsMode8($pos) // + 4 + l8 - + $this->bsObj->estimateBitsModeNum($qix - $pos) + 4 + $lng - - $this->bsObj->estimateBitsMode8($qix); // - 4 - l8 + + $dif = $this->encodingMode->estimateBitsMode8($pos) // + 4 + l8 + + $this->encodingMode->estimateBitsModeNum($qix - $pos) + 4 + $lng + - $this->encodingMode->estimateBitsMode8($qix); // - 4 - l8 if ($dif < 0) { break; } else { @@ -266,22 +262,24 @@ protected function eat8(string $data): int } } elseif ($mode == Data::ENC_MODES['AN']) { $qix = $pos; - while ($this->bsObj->isAlphanumericAt($data, $qix)) { - $qix++; + while ($this->encodingMode->isAlphanumericAt($data, $qix)) { + ++$qix; } - $dif = $this->bsObj->estimateBitsMode8($pos) // + 4 + l8 - + $this->bsObj->estimateBitsModeAn($qix - $pos) + 4 + $lag - - $this->bsObj->estimateBitsMode8($qix); // - 4 - l8 + + $dif = $this->encodingMode->estimateBitsMode8($pos) // + 4 + l8 + + $this->encodingMode->estimateBitsModeAn($qix - $pos) + 4 + $lag + - $this->encodingMode->estimateBitsMode8($qix); // - 4 - l8 if ($dif < 0) { break; } else { $pos = $qix; } } else { - $pos++; + ++$pos; } } - $this->items = $this->bsObj->appendNewInputItem( + + $this->items = $this->encodingMode->appendNewInputItem( $this->items, Data::ENC_MODES['8B'], $pos, diff --git a/test/BarcodeTest.php b/test/BarcodeTest.php index 6124573f..2d4209b8 100644 --- a/test/BarcodeTest.php +++ b/test/BarcodeTest.php @@ -31,16 +31,16 @@ */ class BarcodeTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetBarcodeObjException() + public function testGetBarcodeObjException(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj( + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj( 'ERROR', '01001100011100001111,10110011100011110000', -2, @@ -49,97 +49,97 @@ public function testGetBarcodeObjException() ); } - public function testSetPaddingException() + public function testSetPaddingException(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj( + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj( 'LRAW,AB,12,E3F', '01001100011100001111,10110011100011110000', -2, -2, 'purple', - array(10) + [10] ); } - public function testEmptyColumns() + public function testEmptyColumns(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('LRAW', ''); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('LRAW', ''); } - public function testEmptyInput() + public function testEmptyInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('LRAW', array()); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('LRAW', []); } - public function testSpotColor() + public function testSpotColor(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'LRAW', '01001100011100001111,10110011100011110000', -2, -2, 'all', - array(-2, 3, 0, 1) + [-2, 3, 0, 1] ); - $bobjarr = $bobj->getArray(); + $bobjarr = $type->getArray(); $this->assertEquals('#000000ff', $bobjarr['color_obj']->getRgbaHexColor()); $this->assertNUll($bobjarr['bg_color_obj']); } - public function testBackgroundColor() + public function testBackgroundColor(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'LRAW', '01001100011100001111,10110011100011110000', -2, -2, 'all', - array(-2, 3, 0, 1) + [-2, 3, 0, 1] )->setBackgroundColor('mediumaquamarine'); - $bobjarr = $bobj->getArray(); + $bobjarr = $type->getArray(); $this->assertEquals('#66cdaaff', $bobjarr['bg_color_obj']->getRgbaHexColor()); } - public function testNoColorException() + public function testNoColorException(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj( + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj( 'LRAW', '01001100011100001111,10110011100011110000', -2, -2, '', - array(-2, 3, 0, 1) + [-2, 3, 0, 1] ); } - public function testExportMethods() + public function testExportMethods(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'LRAW,AB,12,E3F', '01001100011100001111,10110011100011110000', -2, -2, 'purple', - array(-2, 3, 0, 1) + [-2, 3, 0, 1] ); - $this->assertEquals('01001100011100001111,10110011100011110000', $bobj->getExtendedCode()); + $this->assertEquals('01001100011100001111,10110011100011110000', $type->getExtendedCode()); - $barr = $bobj->getArray(); + $barr = $type->getArray(); $this->assertEquals('linear', $barr['type']); $this->assertEquals('LRAW', $barr['format']); - $this->assertEquals(array('AB', '12', 'E3F'), $barr['params']); + $this->assertEquals(['AB', '12', 'E3F'], $barr['params']); $this->assertEquals('01001100011100001111,10110011100011110000', $barr['code']); $this->assertEquals('01001100011100001111,10110011100011110000', $barr['extcode']); $this->assertEquals(20, $barr['ncols']); @@ -148,28 +148,19 @@ public function testExportMethods() $this->assertEquals(4, $barr['height']); $this->assertEquals(2, $barr['width_ratio']); $this->assertEquals(2, $barr['height_ratio']); - $this->assertEquals(array('T' => 4, 'R' => 3, 'B' => 0, 'L' => 1), $barr['padding']); + $this->assertEquals(['T' => 4, 'R' => 3, 'B' => 0, 'L' => 1], $barr['padding']); $this->assertEquals(44, $barr['full_width']); $this->assertEquals(8, $barr['full_height']); - $expected = array( - array(1,0,1,1), - array(4,0,2,1), - array(9,0,3,1), - array(16,0,4,1), - array(0,1,1,1), - array(2,1,2,1), - array(6,1,3,1), - array(12,1,4,1), - ); + $expected = [[1, 0, 1, 1], [4, 0, 2, 1], [9, 0, 3, 1], [16, 0, 4, 1], [0, 1, 1, 1], [2, 1, 2, 1], [6, 1, 3, 1], [12, 1, 4, 1]]; $this->assertEquals($expected, $barr['bars']); $this->assertEquals('#800080ff', $barr['color_obj']->getRgbaHexColor()); - $grid = $bobj->getGrid('A', 'B'); + $grid = $type->getGrid('A', 'B'); $expected = "ABAABBAAABBBAAAABBBB\nBABBAABBBAAABBBBAAAA\n"; $this->assertEquals($expected, $grid); - $svg = $bobj->setBackgroundColor('yellow')->getSvgCode(); + $svg = $type->setBackgroundColor('yellow')->getSvgCode(); $expected = ' assertEquals($expected, $svg); - $hdiv = $bobj->setBackgroundColor('lightcoral')->getHtmlDiv(); + $hdiv = $type->setBackgroundColor('lightcoral')->getHtmlDiv(); $expected = '
    assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('CODABAR', chr(218)); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('CODABAR', chr(218)); } } diff --git a/test/Linear/CodeNineThreeTest.php b/test/Linear/CodeNineThreeTest.php index bd32b7f6..eaa9a02b 100644 --- a/test/Linear/CodeNineThreeTest.php +++ b/test/Linear/CodeNineThreeTest.php @@ -32,22 +32,22 @@ */ class CodeNineThreeTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C93', '0123456789'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('C93', '0123456789'); $grid = $bobj->getGrid(); $expected = "101011110100010100101001000101000100101000010100101000100" . "1001001001000101010100001000100101000010101001011001001100101010111101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C93', '012345678901234567890123456789'); + $bobj = $barcode->getBarcodeObj('C93', '012345678901234567890123456789'); $grid = $bobj->getGrid(); $expected = "10101111010001010010100100010100010010100001010010100010010010010010001010101" . "000010001001010000101010001010010100100010100010010100001010010100010010010010010001" @@ -56,10 +56,10 @@ public function testGetGrid() $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('C93', chr(255)); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('C93', chr(255)); } } diff --git a/test/Linear/CodeOneOneTest.php b/test/Linear/CodeOneOneTest.php index e75e0570..a877d992 100644 --- a/test/Linear/CodeOneOneTest.php +++ b/test/Linear/CodeOneOneTest.php @@ -32,36 +32,36 @@ */ class CodeOneOneTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('CODE11', '0123456789'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('CODE11', '0123456789'); $grid = $bobj->getGrid(); $expected = "10110010101011011010110100101101100101010110110110" . "11010100110101010011011010010110101010101101011001\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('CODE11', '123-456-789'); + $bobj = $barcode->getBarcodeObj('CODE11', '123-456-789'); $grid = $bobj->getGrid(); $expected = "10110010110101101001011011001010101101010110110110110" . "10100110101011010101001101101001011010101101101011010101011001\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('CODE11', '-'); + $bobj = $barcode->getBarcodeObj('CODE11', '-'); $grid = $bobj->getGrid(); $expected = "10110010101101010110101011001\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('CODE11', chr(255)); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('CODE11', chr(255)); } } diff --git a/test/Linear/CodeOneTwoEight/CodeOneTwoEightATest.php b/test/Linear/CodeOneTwoEight/CodeOneTwoEightATest.php index 4e15a11e..ef43e904 100644 --- a/test/Linear/CodeOneTwoEight/CodeOneTwoEightATest.php +++ b/test/Linear/CodeOneTwoEight/CodeOneTwoEightATest.php @@ -32,37 +32,37 @@ */ class CodeOneTwoEightATest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C128A', 'ABCDEFG'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('C128A', 'ABCDEFG'); $grid = $bobj->getGrid(); $expected = "110100001001010001100010001011000100010001101011000100010001101000100011000101101" . "0001000100110010001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128A', '0123456789'); + $bobj = $barcode->getBarcodeObj('C128A', '0123456789'); $grid = $bobj->getGrid(); $expected = "110100001001001110110010011100110110011100101100101110011001001110110111001001100" . "1110100111011011101110100110011100101100111101110101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128A', chr(241) . '01234567891'); + $bobj = $barcode->getBarcodeObj('C128A', chr(241) . '01234567891'); $grid = $bobj->getGrid(); $expected = "110100001001111010111010011101100100111001101100111001011001011100110010011101101" . "11001001100111010011101101110111010011001110010110010011100110100001101001100011101011\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('C128A', chr(246) . '01234567891'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('C128A', chr(246) . '01234567891'); } } diff --git a/test/Linear/CodeOneTwoEight/CodeOneTwoEightBTest.php b/test/Linear/CodeOneTwoEight/CodeOneTwoEightBTest.php index 0ea8e293..6e56e66c 100644 --- a/test/Linear/CodeOneTwoEight/CodeOneTwoEightBTest.php +++ b/test/Linear/CodeOneTwoEight/CodeOneTwoEightBTest.php @@ -32,31 +32,31 @@ */ class CodeOneTwoEightBTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C128B', '0123456789'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('C128B', '0123456789'); $grid = $bobj->getGrid(); $expected = "11010010000100111011001001110011011001110010110010111001100100111011011100" . "10011001110100111011011101110100110011100101100110000101001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128B', chr(241) . '01234567891'); + $bobj = $barcode->getBarcodeObj('C128B', chr(241) . '01234567891'); $grid = $bobj->getGrid(); $expected = "11010010000111101011101001110110010011100110110011100101100101110011001001" . "110110111001001100111010011101101110111010011001110010110010011100110100001100101100011101011\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('C128B', chr(246) . '01234567891'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('C128B', chr(246) . '01234567891'); } } diff --git a/test/Linear/CodeOneTwoEight/CodeOneTwoEightCTest.php b/test/Linear/CodeOneTwoEight/CodeOneTwoEightCTest.php index 15212c67..098ba0e4 100644 --- a/test/Linear/CodeOneTwoEight/CodeOneTwoEightCTest.php +++ b/test/Linear/CodeOneTwoEight/CodeOneTwoEightCTest.php @@ -32,32 +32,32 @@ */ class CodeOneTwoEightCTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C128C', '0123456789'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('C128C', '0123456789'); $grid = $bobj->getGrid(); $expected = "110100111001100110110011101101110101110110001000010110011011011110100001101001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128C', chr(241) . '0123456789'); + $bobj = $barcode->getBarcodeObj('C128C', chr(241) . '0123456789'); $grid = $bobj->getGrid(); $expected = "11010011100111101011101100110110011101101110101110110001000010110011011011110111101101101100" . "011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128C', chr(241) . '00123456780000000001'); + $bobj = $barcode->getBarcodeObj('C128C', chr(241) . '00123456780000000001'); $grid = $bobj->getGrid(); $expected = "11010011100111101011101101100110010110011100100010110001110001011011000010100110110011001101" . "1001100110110011001101100110011001101100100010011001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128C', chr(241) . '42029651' . chr(241) . '9405510200864168997758'); + $bobj = $barcode->getBarcodeObj('C128C', chr(241) . '42029651' . chr(241) . '9405510200864168997758'); $grid = $bobj->getGrid(); $expected = "11010011100111101011101011011100011001100110101111000101101110100011110101110100010111101000" . "100110011011101000110011001101101100110011110100100110001000101000010011010111011110111101110101110" @@ -65,17 +65,17 @@ public function testGetGrid() $this->assertEquals($expected, $grid); } - public function testInvalidLength() + public function testInvalidLength(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('C128C', '12345678901'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('C128C', '12345678901'); } - public function testInvalidChar() + public function testInvalidChar(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('C128C', '1A2345678901'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('C128C', '1A2345678901'); } } diff --git a/test/Linear/CodeOneTwoEightTest.php b/test/Linear/CodeOneTwoEightTest.php index ec130aa7..6d655f6d 100644 --- a/test/Linear/CodeOneTwoEightTest.php +++ b/test/Linear/CodeOneTwoEightTest.php @@ -32,139 +32,139 @@ */ class CodeOneTwoEightTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C128', '0123456789'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('C128', '0123456789'); $grid = $bobj->getGrid(); $expected = "110100111001100110110011101101110101110110001000010110011011011110100001101001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', '1PBK500EI'); + $bobj = $barcode->getBarcodeObj('C128', '1PBK500EI'); $grid = $bobj->getGrid(); $expected = "110100100001001110011011101110110100010110001011000111011011100100100111011001001" . "11011001000110100011000100010111011001001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', 'SCB500J1C3Y'); + $bobj = $barcode->getBarcodeObj('C128', 'SCB500J1C3Y'); $grid = $bobj->getGrid(); $expected = "110100100001101110100010001000110100010110001101110010010011101100100111011001011" . "011100010011100110100010001101100101110011101101000110110111101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', '067023611120229212'); + $bobj = $barcode->getBarcodeObj('C128', '067023611120229212'); $grid = $bobj->getGrid(); $expected = "110100111001001100100010110000100111011011101100100001011000100100110010011101100111010010101111" . "00010110011100110110111101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', 'Data:28102003'); + $bobj = $barcode->getBarcodeObj('C128', 'Data:28102003'); $grid = $bobj->getGrid(); $expected = "110100100001011000100010010110000100111101001001011000011100100110101110111101110011010011001000" . "1001100100111010010011000100010001101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', '12345678901'); + $bobj = $barcode->getBarcodeObj('C128', '12345678901'); $grid = $bobj->getGrid(); $expected = "110100100001001110011010111011110111011011101011101100010000101100110110111101100110110011001100" . "1101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', '1234'); + $bobj = $barcode->getBarcodeObj('C128', '1234'); $grid = $bobj->getGrid(); $expected = "110100111001011001110010001011000100100111101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', 'hello'); + $bobj = $barcode->getBarcodeObj('C128', 'hello'); $grid = $bobj->getGrid(); $expected = "110100100001001100001010110010000110010100001100101000010001111010100010011001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', 'HI345678'); + $bobj = $barcode->getBarcodeObj('C128', 'HI345678'); $grid = $bobj->getGrid(); $expected = "110100100001100010100011000100010101110111101000101100011100010110110000101001000010011011000" . "11101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', 'HI34567A'); + $bobj = $barcode->getBarcodeObj('C128', 'HI34567A'); $grid = $bobj->getGrid(); $expected = "1101001000011000101000110001000101100101110010111011110101110110001000010110010111101110101000" . "11000100100011001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', 'Barcode 1'); + $bobj = $barcode->getBarcodeObj('C128', 'Barcode 1'); $grid = $bobj->getGrid(); $expected = "110100100001000101100010010110000100100111101000010110010001111010100001001101011001" . "00001101100110010011100110111011000101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', "C1\tC2\tC3"); + $bobj = $barcode->getBarcodeObj('C128', "C1\tC2\tC3"); $grid = $bobj->getGrid(); $expected = "11010000100100010001101001110011010000110100100010001101100111001010000110100100010001101100101" . "1100100110011101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', 'A1b2c3D4e5'); + $bobj = $barcode->getBarcodeObj('C128', 'A1b2c3D4e5'); $grid = $bobj->getGrid(); $expected = "1101001000010100011000100111001101001000011011001110010100001011001100101110010110001" . "000110010011101011001000011011100100100001101001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', chr(241) . '0000801234999999999'); + $bobj = $barcode->getBarcodeObj('C128', chr(241) . '0000801234999999999'); $grid = $bobj->getGrid(); $expected = "1101001000011110101110100111011001011101111011011001100100011001001100110110011101101" . "1101101000111010111011110101110111101011101111010111011110110100010001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', chr(241) . "000000\tABCDEF"); + $bobj = $barcode->getBarcodeObj('C128', chr(241) . "000000\tABCDEF"); $grid = $bobj->getGrid(); $expected = "1101001110011110101110111101011101101100110011011001100110110011001110101111010000110100101000" . "110001000101100010001000110101100010001000110100010001100010100001100101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', "\tABCD\tEFGH"); + $bobj = $barcode->getBarcodeObj('C128', "\tABCD\tEFGH"); $grid = $bobj->getGrid(); $expected = "1101000010010000110100101000110001000101100010001000110101100010001000011010010001101000100011" . "000101101000100011000101000100011101101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', "\tABCD\tabc\tABCdef"); + $bobj = $barcode->getBarcodeObj('C128', "\tABCD\tabc\tABCdef"); $grid = $bobj->getGrid(); $expected = "1101000010010000110100101000110001000101100010001000110101100010001000011010010111101110100101" . "10000100100001101000010110011101011110100001101001010001100010001011000100010001101011110111010000100" . "1101011001000010110000100100001100101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', "\tABCD\tabc\tdef"); + $bobj = $barcode->getBarcodeObj('C128', "\tABCD\tabc\tdef"); $grid = $bobj->getGrid(); $expected = "1101000010010000110100101000110001000101100010001000110101100010001000011010010111101110100101" . "10000100100001101000010110011110100010100001101001000010011010110010000101100001001111010100011000111" . "01011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', chr(241) . "\tABCD"); + $bobj = $barcode->getBarcodeObj('C128', chr(241) . "\tABCD"); $grid = $bobj->getGrid(); $expected = "1101000010011110101110111101011101000011010010100011000100010110001000100011010110001000110111" . "011101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', "\ta"); + $bobj = $barcode->getBarcodeObj('C128', "\ta"); $grid = $bobj->getGrid(); $expected = "11010000100100001101001111010001010010110000110111000101100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', chr(241) . '00123456780000000001'); + $bobj = $barcode->getBarcodeObj('C128', chr(241) . '00123456780000000001'); $grid = $bobj->getGrid(); $expected = "1101001110011110101110111101011101101100110010110011100100010110001110001011011000010100110110" . "0110011011001100110110011001101100110011001101100100101111001100011101011\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('C128', chr(241) . '42029651' . chr(241) . '9405510200864168997758'); + $bobj = $barcode->getBarcodeObj('C128', chr(241) . '42029651' . chr(241) . '9405510200864168997758'); $grid = $bobj->getGrid(); $expected = "11010011100111101011101111010111010110111000110011001101011110001011011101000101111011101111010" . "1110101110111101000101111010001001100110111010001100110011011011001100111101001001100010001010" diff --git a/test/Linear/CodeThreeNineCheckTest.php b/test/Linear/CodeThreeNineCheckTest.php index 2205c97c..f36938e9 100644 --- a/test/Linear/CodeThreeNineCheckTest.php +++ b/test/Linear/CodeThreeNineCheckTest.php @@ -32,16 +32,16 @@ */ class CodeThreeNineCheckTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C39+', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('C39+', '0123456789'); + $grid = $type->getGrid(); $expected = "10001011101110101010001110111010111010001010111010111000101011101110111000101010101000" . "111010111011101000111010101011100011101010101000101110111011101000101110101011100010111010101" . "1100010101110100010111011101\n"; diff --git a/test/Linear/CodeThreeNineExtCheckTest.php b/test/Linear/CodeThreeNineExtCheckTest.php index 9826410c..db1ef6a8 100644 --- a/test/Linear/CodeThreeNineExtCheckTest.php +++ b/test/Linear/CodeThreeNineExtCheckTest.php @@ -32,26 +32,26 @@ */ class CodeThreeNineExtCheckTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C39E+', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('C39E+', '0123456789'); + $grid = $type->getGrid(); $expected = "10001011101110101010001110111010111010001010111010111000101011101110111000101010101000" . "111010111011101000111010101011100011101010101000101110111011101000101110101011100010111010101" . "1100010101110100010111011101\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('C39E+', chr(218)); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('C39E+', chr(218)); } } diff --git a/test/Linear/CodeThreeNineExtTest.php b/test/Linear/CodeThreeNineExtTest.php index cbdd41ef..fab280eb 100644 --- a/test/Linear/CodeThreeNineExtTest.php +++ b/test/Linear/CodeThreeNineExtTest.php @@ -32,16 +32,16 @@ */ class CodeThreeNineExtTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C39E', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('C39E', '0123456789'); + $grid = $type->getGrid(); $expected = "10001011101110101010001110111010111010001010111010111000101011101110111000101010101000" . "111010111011101000111010101011100011101010101000101110111011101000101110101011100010111010100" . "010111011101\n"; diff --git a/test/Linear/CodeThreeNineTest.php b/test/Linear/CodeThreeNineTest.php index 4a436a1c..5bba68cb 100644 --- a/test/Linear/CodeThreeNineTest.php +++ b/test/Linear/CodeThreeNineTest.php @@ -32,26 +32,26 @@ */ class CodeThreeNineTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('C39', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('C39', '0123456789'); + $grid = $type->getGrid(); $expected = "10001011101110101010001110111010111010001010111010111000101011101110" . "111000101010101000111010111011101000111010101011100011101010101000101110111" . "011101000101110101011100010111010100010111011101\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('C39', chr(218)); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('C39', chr(218)); } } diff --git a/test/Linear/EanEightTest.php b/test/Linear/EanEightTest.php index fb00dc49..175431a6 100644 --- a/test/Linear/EanEightTest.php +++ b/test/Linear/EanEightTest.php @@ -32,19 +32,19 @@ */ class EanEightTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'EAN8', '1234567' ); - $grid = $bobj->getGrid(); + $grid = $type->getGrid(); $expected = "1010011001001001101111010100011010101001110101000010001001110010101\n"; $this->assertEquals($expected, $grid); } diff --git a/test/Linear/EanFiveTest.php b/test/Linear/EanFiveTest.php index a0909013..b4b06bce 100644 --- a/test/Linear/EanFiveTest.php +++ b/test/Linear/EanFiveTest.php @@ -32,19 +32,19 @@ */ class EanFiveTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'EAN5', '12345' ); - $grid = $bobj->getGrid(); + $grid = $type->getGrid(); $expected = "10110110011010010011010100001010100011010110001\n"; $this->assertEquals($expected, $grid); } diff --git a/test/Linear/EanOneThreeTest.php b/test/Linear/EanOneThreeTest.php index 8328abf1..59efa55e 100644 --- a/test/Linear/EanOneThreeTest.php +++ b/test/Linear/EanOneThreeTest.php @@ -32,33 +32,33 @@ */ class EanOneThreeTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('EAN13', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('EAN13', '0123456789'); + $grid = $type->getGrid(); $expected = "10100011010001101001100100100110111101010001101010100111010100001000100100100011101001001110101\n"; $this->assertEquals($expected, $grid); - $this->assertEquals('0001234567895', $bobj->getExtendedCode()); + $this->assertEquals('0001234567895', $type->getExtendedCode()); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('EAN13', '}{'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('EAN13', '}{'); } - public function testInvalidLength() + public function testInvalidLength(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('EAN13', '1111111111111'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('EAN13', '1111111111111'); } } diff --git a/test/Linear/EanTwoTest.php b/test/Linear/EanTwoTest.php index d32c5f24..b5007b76 100644 --- a/test/Linear/EanTwoTest.php +++ b/test/Linear/EanTwoTest.php @@ -32,19 +32,19 @@ */ class EanTwoTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'EAN2', '12' ); - $grid = $bobj->getGrid(); + $grid = $type->getGrid(); $expected = "10110011001010010011\n"; $this->assertEquals($expected, $grid); } diff --git a/test/Linear/ImbPreTest.php b/test/Linear/ImbPreTest.php index a473bcee..a2332b5f 100644 --- a/test/Linear/ImbPreTest.php +++ b/test/Linear/ImbPreTest.php @@ -32,19 +32,19 @@ */ class ImbPreTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'IMBPRE', 'fatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdf' ); - $grid = $bobj->getGrid(); + $grid = $type->getGrid(); $expected = "101000001010000010100000101000001010000010100000101000001010" . "000010100000101000001010000010100000101000001010000010100000101000001\n" . "1010101010101010101010101010101010101010101010101010101010101010101" @@ -54,10 +54,10 @@ public function testGetGrid() $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('IMBPRE', 'fatd'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('IMBPRE', 'fatd'); } } diff --git a/test/Linear/ImbTest.php b/test/Linear/ImbTest.php index 80efbf41..d68a47c1 100644 --- a/test/Linear/ImbTest.php +++ b/test/Linear/ImbTest.php @@ -32,15 +32,15 @@ */ class ImbTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('IMB', '00000-'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('IMB', '00000-'); $grid = $bobj->getGrid(); $expected = "100000101010001000101000101000000010000010100010001010100000" . "100010001000000010101000001010101000100000000000100010001000100000001\n" @@ -50,7 +50,7 @@ public function testGetGrid() . "01010001010001010000010101000101000101000000000001000001000100\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('IMB', '0123456789'); + $bobj = $barcode->getBarcodeObj('IMB', '0123456789'); $grid = $bobj->getGrid(); $expected = "001010100010101000100010001010101010001000001000101010001010" . "101010100000000000000010101000000010001010100010001000101010001000001\n" @@ -60,7 +60,7 @@ public function testGetGrid() . "00010100000100010001000001010101000001010000010101010100010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('IMB', '01234567094987654321-01234567891'); + $bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-01234567891'); $grid = $bobj->getGrid(); $expected = "10100000101000100000100000101000101000100000000010101000000000000000101010001" . "0000000001010100000000000100010101010001000001010001\n" @@ -70,7 +70,7 @@ public function testGetGrid() . "001010101010000000001010000000101000100000100\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('IMB', '01234567094987654321-012345678'); + $bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-012345678'); $grid = $bobj->getGrid(); $expected = "10001000001010000000000010100000100000101010001000100010000010101010000010001" . "0001000000000000000100000001000100010000000101000101\n" @@ -80,7 +80,7 @@ public function testGetGrid() . "101000100000001000100010101000100\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('IMB', '01234567094987654321-01234'); + $bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-01234'); $grid = $bobj->getGrid(); $expected = "00000010101000000000100000001000100000000010001000101010001010000000100010101" . "0100000001000101010100000100000001010000000000010100\n" @@ -90,7 +90,7 @@ public function testGetGrid() . "000010100000000010101000101000101010001010100\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('IMB', '01234567094987654321-'); + $bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-'); $grid = $bobj->getGrid(); $expected = "10000010100000000000100000101000000000000010000000101000001010001000100010101" . "0101000100010101010100000101000001010001000100000000\n" @@ -100,7 +100,7 @@ public function testGetGrid() . "000010000000000010101000100000101000101000100\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('IMB', '01234567094987654321-01234567891'); + $bobj = $barcode->getBarcodeObj('IMB', '01234567094987654321-01234567891'); $grid = $bobj->getGrid(); $expected = "10100000101000100000100000101000101000100000000010101000000000000000101010001" . "0000000001010100000000000100010101010001000001010001\n" @@ -111,10 +111,10 @@ public function testGetGrid() $this->assertEquals($expected, $grid); } - public function testInvalidRoutingCode() + public function testInvalidRoutingCode(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('IMB', '01234567094987654321-1'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('IMB', '01234567094987654321-1'); } } diff --git a/test/Linear/InterleavedTwoOfFiveCheckTest.php b/test/Linear/InterleavedTwoOfFiveCheckTest.php index faa66c53..c7f9d49d 100644 --- a/test/Linear/InterleavedTwoOfFiveCheckTest.php +++ b/test/Linear/InterleavedTwoOfFiveCheckTest.php @@ -32,27 +32,27 @@ */ class InterleavedTwoOfFiveCheckTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'I25+', '0123456789' ); - $grid = $bobj->getGrid(); + $grid = $type->getGrid(); $expected = "10101010110011001011010010101100110110100101001101001100101010010101100110100110100110101101\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('I25+', 'GHI'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('I25+', 'GHI'); } } diff --git a/test/Linear/InterleavedTwoOfFiveTest.php b/test/Linear/InterleavedTwoOfFiveTest.php index da9aca04..ddc2cb25 100644 --- a/test/Linear/InterleavedTwoOfFiveTest.php +++ b/test/Linear/InterleavedTwoOfFiveTest.php @@ -32,19 +32,19 @@ */ class InterleavedTwoOfFiveTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj( 'I25', '0123456789' ); - $grid = $bobj->getGrid(); + $grid = $type->getGrid(); $expected = "101010010110110100100110010101101001011001011010110110100100110100101100101101\n"; $this->assertEquals($expected, $grid); } diff --git a/test/Linear/KlantIndexTest.php b/test/Linear/KlantIndexTest.php index 6778f68d..c0285072 100644 --- a/test/Linear/KlantIndexTest.php +++ b/test/Linear/KlantIndexTest.php @@ -32,16 +32,16 @@ */ class KlantIndexTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('KIX', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('KIX', '0123456789'); + $grid = $type->getGrid(); $expected = "00001010000010100000101000001010000010100000101000100010001000100010001000100010\n" . "10101010101010101010101010101010101010101010101010101010101010101010101010101010\n" . "00001010001000100010100010000010100010001010000000001010001000100010100010000010\n"; diff --git a/test/Linear/MsiCheckTest.php b/test/Linear/MsiCheckTest.php index e2f60759..6b64b894 100644 --- a/test/Linear/MsiCheckTest.php +++ b/test/Linear/MsiCheckTest.php @@ -32,26 +32,26 @@ */ class MsiCheckTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('MSI+', '0123456789ABCDEF'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('MSI+', '0123456789ABCDEF'); + $grid = $type->getGrid(); $expected = "110100100100100100100100110100100110100100100110110100110100100100110100110100110110100" . "1001101101101101001001001101001001101101001101001101001101101101101001001101101001101101101101" . "001101101101101001001001101001\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('MSI+', 'GHI'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('MSI+', 'GHI'); } } diff --git a/test/Linear/MsiTest.php b/test/Linear/MsiTest.php index 7008198b..f623074b 100644 --- a/test/Linear/MsiTest.php +++ b/test/Linear/MsiTest.php @@ -32,16 +32,16 @@ */ class MsiTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('MSI', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('MSI', '0123456789'); + $grid = $type->getGrid(); $expected = "110100100100100100100100110100100110100100100110110100110100" . "1001001101001101001101101001001101101101101001001001101001001101001\n"; $this->assertEquals($expected, $grid); diff --git a/test/Linear/PharmaTest.php b/test/Linear/PharmaTest.php index 9e130f34..cb8ca433 100644 --- a/test/Linear/PharmaTest.php +++ b/test/Linear/PharmaTest.php @@ -32,16 +32,16 @@ */ class PharmaTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('PHARMA', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('PHARMA', '0123456789'); + $grid = $type->getGrid(); $expected = "111001110010011100100111001110010011100111001110011100100" . "1001110011100100111001001001001110010011100111001\n"; $this->assertEquals($expected, $grid); diff --git a/test/Linear/PharmaTwoTracksTest.php b/test/Linear/PharmaTwoTracksTest.php index 45b9c4cc..c0b16f7d 100644 --- a/test/Linear/PharmaTwoTracksTest.php +++ b/test/Linear/PharmaTwoTracksTest.php @@ -32,16 +32,16 @@ */ class PharmaTwoTracksTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('PHARMA2T', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('PHARMA2T', '0123456789'); + $grid = $type->getGrid(); $expected = "101000001010100010001010001000101\n000010101010001010101000100010001\n"; $this->assertEquals($expected, $grid); } diff --git a/test/Linear/PlanetTest.php b/test/Linear/PlanetTest.php index e2010b20..1d057a4c 100644 --- a/test/Linear/PlanetTest.php +++ b/test/Linear/PlanetTest.php @@ -32,16 +32,16 @@ */ class PlanetTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('PLANET', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('PLANET', '0123456789'); + $grid = $type->getGrid(); $expected = "100000101010101010000010100010001010000010100010100010" . "00100010100000101000101010000010100010001000101010001000101\n" . "1010101010101010101010101010101010101010101010101010101010101" diff --git a/test/Linear/PostnetTest.php b/test/Linear/PostnetTest.php index be1afb6f..cc2005ba 100644 --- a/test/Linear/PostnetTest.php +++ b/test/Linear/PostnetTest.php @@ -32,16 +32,16 @@ */ class PostnetTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('POSTNET', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('POSTNET', '0123456789'); + $grid = $type->getGrid(); $expected = "101010000000000000101000001000100000101000001000001000" . "10001000001010000010000000101000001000100010000000100010001\n" . "1010101010101010101010101010101010101010101010101010101010101" @@ -49,10 +49,10 @@ public function testGetGrid() $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('POSTNET', '}{'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('POSTNET', '}{'); } } diff --git a/test/Linear/RawTest.php b/test/Linear/RawTest.php index 5b59fca6..04597103 100644 --- a/test/Linear/RawTest.php +++ b/test/Linear/RawTest.php @@ -32,20 +32,21 @@ */ class RawTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { $testObj = $this->getTestObject(); $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj( + + $type = $testObj->getBarcodeObj( 'LRAW', '01001100011100001111,10110011100011110000' ); - $grid = $bobj->getGrid(); + $grid = $type->getGrid(); $expected = "01001100011100001111\n10110011100011110000\n"; $this->assertEquals($expected, $grid); } diff --git a/test/Linear/RoyalMailFourCcTest.php b/test/Linear/RoyalMailFourCcTest.php index c1e0808f..b30d3509 100644 --- a/test/Linear/RoyalMailFourCcTest.php +++ b/test/Linear/RoyalMailFourCcTest.php @@ -32,26 +32,26 @@ */ class RoyalMailFourCcTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('RMS4CC', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('RMS4CC', '0123456789'); + $grid = $type->getGrid(); $expected = "1000001010000010100000101000001010000010100000101000100010001000100010001000100010001000101\n" . "1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\n" . "0000001010001000100010100010000010100010001010000000001010001000100010100010000010000010101\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('RMS4CC', '}{'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('RMS4CC', '}{'); } } diff --git a/test/Linear/StandardTwoOfFiveCheckTest.php b/test/Linear/StandardTwoOfFiveCheckTest.php index 73faf4c3..26e27172 100644 --- a/test/Linear/StandardTwoOfFiveCheckTest.php +++ b/test/Linear/StandardTwoOfFiveCheckTest.php @@ -32,25 +32,25 @@ */ class StandardTwoOfFiveCheckTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('S25+', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('S25+', '0123456789'); + $grid = $type->getGrid(); $expected = '111011101010101110111010101011101110101110101010111010111010101110111011101010101010111010' . '1110111010111010101011101110101010101011101110111010101110101011101011101011101011101010111010111' . "\n"; $this->assertEquals($expected, $grid); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('S25+', '}{'); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('S25+', '}{'); } } diff --git a/test/Linear/StandardTwoOfFiveTest.php b/test/Linear/StandardTwoOfFiveTest.php index 14602d9e..4bde71ff 100644 --- a/test/Linear/StandardTwoOfFiveTest.php +++ b/test/Linear/StandardTwoOfFiveTest.php @@ -32,16 +32,16 @@ */ class StandardTwoOfFiveTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('S25', '0123456789'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('S25', '0123456789'); + $grid = $type->getGrid(); $expected = '111011101010101110111010111010101011101011101010111011101110101010101011101011101110101110101010' . '111011101010101010111011101110101011101010111010111010111010111' . "\n"; $this->assertEquals($expected, $grid); diff --git a/test/Linear/UpcATest.php b/test/Linear/UpcATest.php index baa89b5c..f212eda1 100644 --- a/test/Linear/UpcATest.php +++ b/test/Linear/UpcATest.php @@ -32,20 +32,20 @@ */ class UpcATest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('UPCA', '0123456789'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('UPCA', '0123456789'); $grid = $bobj->getGrid(); $expected = "10100011010001101001100100100110111101010001101010100111010100001000100100100011101001001110101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCA', '012345678912'); + $bobj = $barcode->getBarcodeObj('UPCA', '012345678912'); $grid = $bobj->getGrid(); $expected = "10100011010011001001001101111010100011011000101010101000010001001001000111010011001101101100101\n"; $this->assertEquals($expected, $grid); diff --git a/test/Linear/UpcETest.php b/test/Linear/UpcETest.php index a4732bcd..529b4c76 100644 --- a/test/Linear/UpcETest.php +++ b/test/Linear/UpcETest.php @@ -32,85 +32,85 @@ */ class UpcETest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('UPCE', '725270'); + $barcode = $this->getTestObject(); + $bobj = $barcode->getBarcodeObj('UPCE', '725270'); $grid = $bobj->getGrid(); $expected = "101001000100100110110001001101101110110100111010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725271'); + $bobj = $barcode->getBarcodeObj('UPCE', '725271'); $grid = $bobj->getGrid(); $expected = "101001000100100110111001001001101110110110011010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725272'); + $bobj = $barcode->getBarcodeObj('UPCE', '725272'); $grid = $bobj->getGrid(); $expected = "101001000100100110111001001001100100010010011010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725273'); + $bobj = $barcode->getBarcodeObj('UPCE', '725273'); $grid = $bobj->getGrid(); $expected = "101001000100100110110001001101101110110100001010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725274'); + $bobj = $barcode->getBarcodeObj('UPCE', '725274'); $grid = $bobj->getGrid(); $expected = "101001000100100110110001001101100100010100011010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725275'); + $bobj = $barcode->getBarcodeObj('UPCE', '725275'); $grid = $bobj->getGrid(); $expected = "101001000100100110111001001101101110110110001010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725276'); + $bobj = $barcode->getBarcodeObj('UPCE', '725276'); $grid = $bobj->getGrid(); $expected = "101001000100110110110001001101101110110101111010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725277'); + $bobj = $barcode->getBarcodeObj('UPCE', '725277'); $grid = $bobj->getGrid(); $expected = "101001000100100110111001001001101110110010001010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725278'); + $bobj = $barcode->getBarcodeObj('UPCE', '725278'); $grid = $bobj->getGrid(); $expected = "101001000100100110110001001101100100010110111010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '725279'); + $bobj = $barcode->getBarcodeObj('UPCE', '725279'); $grid = $bobj->getGrid(); $expected = "101001000100110110110001001001100100010001011010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '0123456789'); + $bobj = $barcode->getBarcodeObj('UPCE', '0123456789'); $grid = $bobj->getGrid(); $expected = "101010011100110010010011010000100111010001011010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '012345678912'); + $bobj = $barcode->getBarcodeObj('UPCE', '012345678912'); $grid = $bobj->getGrid(); $expected = "101011001100110110111101010001101110010011001010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '4210000526'); + $bobj = $barcode->getBarcodeObj('UPCE', '4210000526'); $grid = $bobj->getGrid(); $expected = "101001110100100110111001001101101011110011001010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '4240000526'); + $bobj = $barcode->getBarcodeObj('UPCE', '4240000526'); $grid = $bobj->getGrid(); $expected = "101001110100110110100011001101101011110111101010101\n"; $this->assertEquals($expected, $grid); - $bobj = $testObj->getBarcodeObj('UPCE', '4241000526'); + $bobj = $barcode->getBarcodeObj('UPCE', '4241000526'); $grid = $bobj->getGrid(); $expected = "101001110100100110011101001100101011110011101010101\n"; $this->assertEquals($expected, $grid); diff --git a/test/Square/AztecTest.php b/test/Square/AztecTest.php index c334a365..f1c76756 100644 --- a/test/Square/AztecTest.php +++ b/test/Square/AztecTest.php @@ -32,112 +32,87 @@ */ class AztecTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('AZTEC', ''); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('AZTEC', ''); } - public function testCapacityException() + public function testCapacityException(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); $code = str_pad('', 2000, '0123456789'); - $testObj->getBarcodeObj('AZTEC,100,B,F,3', $code); + $barcode->getBarcodeObj('AZTEC,100,B,F,3', $code); } /** * @dataProvider getGridDataProvider */ - public function testGetGrid($options, $code, $expected) + public function testGetGrid(string $options, string $code, mixed $expected): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('AZTEC' . $options, $code); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('AZTEC' . $options, $code); + $grid = $type->getGrid(); $this->assertEquals($expected, md5($grid)); } - public static function getGridDataProvider() + public static function getGridDataProvider(): array { - return array( - array(',100,A,A,0', 'A', 'c48da49052f674edc66fa02e52334b17'), - array('', ' ABCDEFGHIJKLMNOPQRSTUVWXYZ', '74f1e68830f0c635cd01167245743098'), - array('', ' abcdefghijklmnopqrstuvwxyz', '100ebf910c88922b0ccee88256ba0c81'), - array('', ' ,.0123456789', 'ee2a70b7c88a9e0956b1896983e93f91'), - array('', "\r" . '!"#$%&\'()*+,-./:;<=>?[]{}', '6965459e50f7c3029de42ef5dc5c1fdf'), - array('', chr(1) . chr(2) . chr(3) . chr(4) . chr(5) - . chr(6) . chr(7) . chr(8) . chr(9) . chr(10) - . chr(11) . chr(12) . chr(13) . chr(27) . chr(28) - . chr(29) . chr(30) . chr(31) . chr(64) . chr(92) - . chr(94) . chr(95) . chr(96) . chr(124) . chr(126) - . chr(127), 'b8961abf38519b529f7dc6a20e8f3e59'), - array('', 'AaB0C#D' . chr(126), '9b1f2af28b8d9d222de93dfe6a09a047'), - array('', 'aAb0c#d' . chr(126), 'f4c58cabbdb5d94fa0cc1c31d510936a'), - array('', '#A$a%0&' . chr(126), 'a17634a1db6372efbf8ea25a303c38f8'), - array('', chr(1) . 'A' . chr(1) . 'a' . chr(1) . '0' . chr(1) . '#', 'c1a585888c7a1eb424ff98bbf7b32d46'), - array('', 'PUNCT pairs , . : ' . "\r\n", '35281793cc5247b291abb8e3fe5ed853'), - array('', 'ABCDEabcdeABCDE012345ABCDE?[]{}ABCDE' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), '4ae19b80469a1afff8e490f5afaa8b73'), - array('', 'abcdeABCDEabcde012345abcde?[]{}abcde' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), 'b0158bfe19c6fe20042128d59e40ca3b'), - array('', '?[]{}ABCDE?[]{}abcde?[]{}012345?[]{}' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), '71ba0ed8c308c93af6af7cd23a76355a'), - array('', chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . 'ABCDE' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . 'abcde' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . '012345' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . '?[]{}', 'f31e14be0b2c1f903e77af11e6c901b0'), - array('', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit,' - . ' sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' - . ' Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris' - . ' nisi ut aliquip ex ea commodo consequat.' - . ' Duis aute irure dolor in reprehenderit in voluptate velit esse' - . ' cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat' - . ' cupidatat non proident,' . - ' sunt in culpa qui officia deserunt mollit anim id est laborum.', 'bb2b103d59e035a581fed0619090f89c'), - array('', chr(128) . chr(129) . chr(130) . chr(131) . chr(132), 'da92b009c1f4430e2f62c76c5f708121'), - array('', chr(128) . chr(129) . chr(130) . chr(131) . chr(132) - . chr(133) . chr(134) . chr(135) . chr(136) . chr(137) - . chr(138) . chr(139) . chr(140) . chr(141) . chr(142) - . chr(143) . chr(144) . chr(145) . chr(146) . chr(147) - . chr(148) . chr(149) . chr(150) . chr(151) . chr(152) - . chr(153) . chr(154) . chr(155) . chr(156) . chr(157) - . chr(158) . chr(159) . chr(160), 'f3dfdda6d6fdbd747c86f042fc649193'), - array('', chr(128) . chr(129) . chr(130) . chr(131) . chr(132) - . chr(133) . chr(134) . chr(135) . chr(136) . chr(137) - . chr(138) . chr(139) . chr(140) . chr(141) . chr(142) - . chr(143) . chr(144) . chr(145) . chr(146) . chr(147) - . chr(148) . chr(149) . chr(150) . chr(151) . chr(152) - . chr(153) . chr(154) . chr(155) . chr(156) . chr(157) - . chr(158) . chr(159) . chr(160) . chr(161) . chr(162) - . chr(163) . chr(164) . chr(165) . chr(166) . chr(167) - . chr(168) . chr(169) . chr(170) . chr(171) . chr(172) - . chr(173) . chr(174) . chr(175) . chr(176) . chr(177) - . chr(178) . chr(179) . chr(180) . chr(181) . chr(182) - . chr(183) . chr(184) . chr(185) . chr(186) . chr(187) - . chr(188) . chr(189) . chr(190), 'ee473dc76e160671f3d1991777894323'), - array('', '012345: : : : : : : : ', 'b7ae80e65d754dc17fe116aaddd33c24'), - array('', '012345. , ', '92b442e5f1b33be91c576eddc12bcca7'), - array('', '012345. , . , . , . , ', '598fd97d8a28b1514cd0bf88369c68e9'), - array('', '~~~~~~. , ', 'c40fc61717a7e802d7458897197227b1'), - array('', '******. , ', 'abbe0bdfdc10ad059ad2c415e79dab31'), - array('', chr(188) . chr(189) . chr(190) . '. , ', 'c9ae209e0c6d03014753363affffee8b') - ); + return [[',100,A,A,0', 'A', 'c48da49052f674edc66fa02e52334b17'], ['', ' ABCDEFGHIJKLMNOPQRSTUVWXYZ', '74f1e68830f0c635cd01167245743098'], ['', ' abcdefghijklmnopqrstuvwxyz', '100ebf910c88922b0ccee88256ba0c81'], ['', ' ,.0123456789', 'ee2a70b7c88a9e0956b1896983e93f91'], ['', ' !"#$%&\'()*+,-./:;<=>?[]{}', '6965459e50f7c3029de42ef5dc5c1fdf'], ['', chr(1) . chr(2) . chr(3) . chr(4) . chr(5) + . chr(6) . chr(7) . chr(8) . chr(9) . chr(10) + . chr(11) . chr(12) . chr(13) . chr(27) . chr(28) + . chr(29) . chr(30) . chr(31) . chr(64) . chr(92) + . chr(94) . chr(95) . chr(96) . chr(124) . chr(126) + . chr(127), 'b8961abf38519b529f7dc6a20e8f3e59'], ['', 'AaB0C#D' . chr(126), '9b1f2af28b8d9d222de93dfe6a09a047'], ['', 'aAb0c#d' . chr(126), 'f4c58cabbdb5d94fa0cc1c31d510936a'], ['', '#A$a%0&' . chr(126), 'a17634a1db6372efbf8ea25a303c38f8'], ['', chr(1) . 'A' . chr(1) . 'a' . chr(1) . '0' . chr(1) . '#', 'c1a585888c7a1eb424ff98bbf7b32d46'], ['', 'PUNCT pairs , . : +', '35281793cc5247b291abb8e3fe5ed853'], ['', 'ABCDEabcdeABCDE012345ABCDE?[]{}ABCDE' + . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), '4ae19b80469a1afff8e490f5afaa8b73'], ['', 'abcdeABCDEabcde012345abcde?[]{}abcde' + . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), 'b0158bfe19c6fe20042128d59e40ca3b'], ['', '?[]{}ABCDE?[]{}abcde?[]{}012345?[]{}' + . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), '71ba0ed8c308c93af6af7cd23a76355a'], ['', chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . 'ABCDE' + . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . 'abcde' + . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . '012345' + . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . '?[]{}', 'f31e14be0b2c1f903e77af11e6c901b0'], ['', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit,' + . ' sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' + . ' Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris' + . ' nisi ut aliquip ex ea commodo consequat.' + . ' Duis aute irure dolor in reprehenderit in voluptate velit esse' + . ' cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat' + . ' cupidatat non proident,' . + ' sunt in culpa qui officia deserunt mollit anim id est laborum.', 'bb2b103d59e035a581fed0619090f89c'], ['', chr(128) . chr(129) . chr(130) . chr(131) . chr(132), 'da92b009c1f4430e2f62c76c5f708121'], ['', chr(128) . chr(129) . chr(130) . chr(131) . chr(132) + . chr(133) . chr(134) . chr(135) . chr(136) . chr(137) + . chr(138) . chr(139) . chr(140) . chr(141) . chr(142) + . chr(143) . chr(144) . chr(145) . chr(146) . chr(147) + . chr(148) . chr(149) . chr(150) . chr(151) . chr(152) + . chr(153) . chr(154) . chr(155) . chr(156) . chr(157) + . chr(158) . chr(159) . chr(160), 'f3dfdda6d6fdbd747c86f042fc649193'], ['', chr(128) . chr(129) . chr(130) . chr(131) . chr(132) + . chr(133) . chr(134) . chr(135) . chr(136) . chr(137) + . chr(138) . chr(139) . chr(140) . chr(141) . chr(142) + . chr(143) . chr(144) . chr(145) . chr(146) . chr(147) + . chr(148) . chr(149) . chr(150) . chr(151) . chr(152) + . chr(153) . chr(154) . chr(155) . chr(156) . chr(157) + . chr(158) . chr(159) . chr(160) . chr(161) . chr(162) + . chr(163) . chr(164) . chr(165) . chr(166) . chr(167) + . chr(168) . chr(169) . chr(170) . chr(171) . chr(172) + . chr(173) . chr(174) . chr(175) . chr(176) . chr(177) + . chr(178) . chr(179) . chr(180) . chr(181) . chr(182) + . chr(183) . chr(184) . chr(185) . chr(186) . chr(187) + . chr(188) . chr(189) . chr(190), 'ee473dc76e160671f3d1991777894323'], ['', '012345: : : : : : : : ', 'b7ae80e65d754dc17fe116aaddd33c24'], ['', '012345. , ', '92b442e5f1b33be91c576eddc12bcca7'], ['', '012345. , . , . , . , ', '598fd97d8a28b1514cd0bf88369c68e9'], ['', '~~~~~~. , ', 'c40fc61717a7e802d7458897197227b1'], ['', '******. , ', 'abbe0bdfdc10ad059ad2c415e79dab31'], ['', chr(188) . chr(189) . chr(190) . '. , ', 'c9ae209e0c6d03014753363affffee8b']]; } /** * @dataProvider getStringDataProvider */ - public function testStrings($code) + public function testStrings(string|array $code): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('AZTEC,50,B,F', $code); - $this->assertNotNull($bobj); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('AZTEC,50,B,F', $code); + $this->assertNotNull($type); } public static function getStringDataProvider() diff --git a/test/Square/DatamatrixTest.php b/test/Square/DatamatrixTest.php index 049ae15f..53ba0ddc 100644 --- a/test/Square/DatamatrixTest.php +++ b/test/Square/DatamatrixTest.php @@ -32,442 +32,402 @@ */ class DatamatrixTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('DATAMATRIX', ''); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('DATAMATRIX', ''); } - public function testCapacityException() + public function testCapacityException(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); $code = str_pad('', 3000, 'X'); - $testObj->getBarcodeObj('DATAMATRIX', $code); + $barcode->getBarcodeObj('DATAMATRIX', $code); } - public function testEncodeTXTC40shiftException() + public function testEncodeTXTC40shiftException(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $obj = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode(); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $encode = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode(); $chr = -1; $enc = -1; $temp_cw = []; $ptr = 0; - $obj->encodeTXTC40shift($chr, $enc, $temp_cw, $ptr); + $encode->encodeTXTC40shift($chr, $enc, $temp_cw, $ptr); } - public function testEncodeTXTC40Exception() + public function testEncodeTXTC40Exception(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $obj = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode(); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $encode = new \Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode(); $data = "\x80"; $enc = \Com\Tecnick\Barcode\Type\Square\Datamatrix\Data::ENC_X12; $temp_cw = []; $ptr = 0; $epos = 0; $charset = []; - $obj->encodeTXTC40($data, $enc, $temp_cw, $ptr, $epos, $charset); + $encode->encodeTXTC40($data, $enc, $temp_cw, $ptr, $epos, $charset); } /** * @dataProvider getGridDataProvider */ - public function testGetGrid($mode, $code, $expected) + public function testGetGrid(string $mode, string $code, mixed $expected): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj($mode, $code); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj($mode, $code); + $grid = $type->getGrid(); $this->assertEquals($expected, md5($grid)); } - public static function getGridDataProvider() + public static function getGridDataProvider(): array { - return array( - array('DATAMATRIX', '0&0&0&0&0&0&_', 'fffdfdaec33af0788d24cdfa8cba5ac6'), - array('DATAMATRIX', '0&0&0&0&0&0&0', '10d0faf5a6e7b71829f268218df7e6af'), - array('DATAMATRIX', '-=-1-=-2-=-3', '75c6038d90476cec641ad07690989b36'), - array('DATAMATRIX', '-=-1-=-2-=-3x', 'f020e44d0926d17af7eb21febdb38d53'), - array('DATAMATRIX', '-=-1-=-2-=-3xyz', '17420fbffefddb5f1b8abd0d05de724d'), - array('DATAMATRIX', '-=-1-=-2-=-3-', 'a63372ce839b51294964f0da0ae0f9f9'), - array('DATAMATRIX', '-=-1-=-2-=-3-xy', 'f65ab07c374c53e2a93016776041de42'), - array('DATAMATRIX', '-=-1-=-2-=-3-=x', '7a30efdf7616397a1ea2fd5fd95fed2c'), - array('DATAMATRIX', '(400)BS2WZ64PA(00)0', '9cb7f1c2aa5989909229ef8e4252d61d'), - array('DATAMATRIX', '(400)BS2WZ64QA(00)0', '0494f709138a1feef5a1c9f14852dbe5'), - array('DATAMATRIX', 'LD2B 1 CLNGP', 'f806889d1dbe0908dcfb530f86098041'), - array('DATAMATRIX', 'XXXXXXXXXNGP', 'c6f2b7b293a2943bae74f2a191ec4aea'), - array('DATAMATRIX', 'XXXXXXXXXXXXNGP', 'f7679d5a7ab4a8edf12571a6866d92bc'), - array('DATAMATRIX', 'ABCDABCDAB' . chr(128) . 'DABCD', '39aca5ed58b922bee369e5ab8e3add8c'), - array('DATAMATRIX', '123aabcdefghijklmnopqrstuvwxyzc', 'b2d1e957af10655d7a8c3bae86696314'), - array('DATAMATRIX', 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq', 'c45bd372694ad7a20fca7d45f3d459ab'), - array('DATAMATRIX', 'abcdefghijklmnop', '4fc7940fe3d19fca12454340c38e3421'), - array('DATAMATRIX', 'abcdefghijklmnopq', 'a452e658e3096d8187969cbdc930909c'), - array('DATAMATRIX', 'abcdefghij', '8ec27153e5d173aa2cb907845334e68c'), - array('DATAMATRIX', '30Q324343430794|', '4993e149fd20569c8a4f0d758b6dfa76'), - array('DATAMATRIX', '!"£$', '792181edb48c6722217dc7e2e4cd4095'), - array( - 'DATAMATRIX', - 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\1234567890', - '7360a5a6c25476711139ae1244f56c29' - ), - array( - 'DATAMATRIX', chr(254) - . chr(253) - . 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\' - . chr(252) - . chr(251), - '0f078e5e5735396312245740484fa6d1' - ), - array('DATAMATRIX', 'aABCDEFG', 'f074dee3f0f386d9b2f30b1ce4ad08a8'), - array('DATAMATRIX', '123 45678', '6c2e6503625e408fe9a4e392743f31a8'), - array('DATAMATRIX', 'DATA MATRIX', '3ba4f4ef8449d795813b353ddcce4d23'), - array('DATAMATRIX', '123ABCD89', '7ce2f8433b82c16e80f4a4c59cad5d10'), - array('DATAMATRIX', 'AB/C123-X', '703318e1964c63d5d500d14a821827cd'), - array('DATAMATRIX', - str_pad('', 300, chr(254) - . chr(253) - . chr(252) - . chr(251)), - 'e524bb17821d0461f3db6f313d35018f'), - array('DATAMATRIX', 'ec:b47' . chr(127) . '4#P d*b}gI2#DB|hl{!~[EYH*=cmR{lf' - . chr(127) . '=gcGIa.st286. #*"!eG[.Ryr?Kn,1mIyQqC3 6\'3N>', - '57fbb9bfb7d542e2e5eadb615e6be549' - ), - array('DATAMATRIX', 'eA211101A2raJTGL/r9o93CVk4gtpEvWd2A2Qz8jvPc7l8ybD3m' - . 'Wel91ih727kldinPeHJCjhr7fIBX1KQQfsN7BFMX00nlS8FlZG+', - 'b2f0d45920c7da5b298bbab5cff5d402' - ), + . chr(158), '9300000cee5a5f7b3b48145d44aa7fff'], + ['DATAMATRIX', '!"£$%^&*()-+_={}[]\'#@~;:/?,.<>|', '4993e149fd20569c8a4f0d758b6dfa76'], + ['DATAMATRIX', '!"£$', '792181edb48c6722217dc7e2e4cd4095'], + ['DATAMATRIX', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\1234567890', '7360a5a6c25476711139ae1244f56c29'], + ['DATAMATRIX', chr(254) + . chr(253) + . 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\' + . chr(252) + . chr(251), '0f078e5e5735396312245740484fa6d1'], + ['DATAMATRIX', 'aABCDEFG', 'f074dee3f0f386d9b2f30b1ce4ad08a8'], + ['DATAMATRIX', '123 45678', '6c2e6503625e408fe9a4e392743f31a8'], + ['DATAMATRIX', 'DATA MATRIX', '3ba4f4ef8449d795813b353ddcce4d23'], + ['DATAMATRIX', '123ABCD89', '7ce2f8433b82c16e80f4a4c59cad5d10'], + ['DATAMATRIX', 'AB/C123-X', '703318e1964c63d5d500d14a821827cd'], + ['DATAMATRIX', str_pad('', 300, chr(254) + . chr(253) + . chr(252) + . chr(251)), 'e524bb17821d0461f3db6f313d35018f'], + ['DATAMATRIX', 'ec:b47' . chr(127) . '4#P d*b}gI2#DB|hl{!~[EYH*=cmR{lf' + . chr(127) . '=gcGIa.st286. #*"!eG[.Ryr?Kn,1mIyQqC3 6\'3N>', '57fbb9bfb7d542e2e5eadb615e6be549'], + ['DATAMATRIX', 'eA211101A2raJTGL/r9o93CVk4gtpEvWd2A2Qz8jvPc7l8ybD3m' + . 'Wel91ih727kldinPeHJCjhr7fIBX1KQQfsN7BFMX00nlS8FlZG+', 'b2f0d45920c7da5b298bbab5cff5d402'], // Square - array( - 'DATAMATRIX,S', - chr(255) - . chr(254) - . chr(253) - . chr(252) - . chr(251) - . chr(250) - . chr(249) - . chr(248) - . chr(247) - . chr(246) - . chr(245) - . chr(244) - . chr(243) - . chr(242) - . chr(241) - . chr(240) - . chr(239) - . chr(238) - . chr(237) - . chr(236) - . chr(235) - . chr(234) - . chr(233) - . chr(232) - . chr(231) - . chr(230) - . chr(229) - . chr(228) - . chr(227) - . chr(226) - . chr(225) - . chr(224) - . chr(223) - . chr(222) - . chr(221) - . chr(220) - . chr(219) - . chr(218) - . chr(217) - . chr(216) - . chr(215) - . chr(214) - . chr(213) - . chr(212) - . chr(211) - . chr(210) - . chr(209) - . chr(208) - . chr(207) - . chr(206) - . chr(205) - . chr(204) - . chr(203) - . chr(202) - . chr(201) - . chr(200) - . chr(199) - . chr(198) - . chr(197) - . chr(196) - . chr(195) - . chr(194) - . chr(193) - . chr(192) - . chr(191) - . chr(190) - . chr(189) - . chr(188) - . chr(187) - . chr(186) - . chr(185) - . chr(184) - . chr(183) - . chr(182) - . chr(181) - . chr(180) - . chr(179) - . chr(178) - . chr(177) - . chr(176) - . chr(175) - . chr(174) - . chr(173) - . chr(172) - . chr(171) - . chr(170) - . chr(169) - . chr(168) - . chr(167) - . chr(166) - . chr(165) - . chr(164) - . chr(163) - . chr(162) - . chr(161) - . chr(160) - . chr(159) - . chr(158) - . chr(157) - . chr(156) - . chr(155) - . chr(154) - . chr(153) - . chr(152) - . chr(151) - . chr(150) - . chr(149) - . chr(148) - . chr(147) - . chr(146) - . chr(145) - . chr(144) - . chr(143) - . chr(142) - . chr(141) - . chr(140) - . chr(139) - . chr(138) - . chr(137) - . chr(136) - . chr(135) - . chr(134) - . chr(133) - . chr(132) - . chr(131) - . chr(130) - . chr(129) - . chr(128) - . chr(127) - . chr(126) - . chr(125) - . chr(124) - . chr(123) - . chr(122) - . chr(121) - . chr(120) - . chr(119) - . chr(118) - . chr(117) - . chr(116) - . chr(115) - . chr(114) - . chr(113) - . chr(112) - . chr(111) - . chr(110) - . chr(109) - . chr(108) - . chr(107) - . chr(106) - . chr(105) - . chr(104) - . chr(103) - . chr(102) - . chr(101) - . chr(100) - . chr(99) - . chr(98) - . chr(97) - . chr(96) - . chr(95) - . chr(94) - . chr(93) - . chr(92) - . chr(91) - . chr(90) - . chr(89) - . chr(88) - . chr(87) - . chr(86) - . chr(85) - . chr(84) - . chr(83) - . chr(82) - . chr(81) - . chr(80) - . chr(79) - . chr(78) - . chr(77) - . chr(76) - . chr(75) - . chr(74) - . chr(73) - . chr(72) - . chr(71) - . chr(70) - . chr(69) - . chr(68) - . chr(67) - . chr(66) - . chr(65) - . chr(64) - . chr(63) - . chr(62) - . chr(61) - . chr(60) - . chr(59) - . chr(58) - . chr(57) - . chr(56) - . chr(55) - . chr(54) - . chr(53) - . chr(52) - . chr(51) - . chr(50) - . chr(49) - . chr(48) - . chr(47) - . chr(46) - . chr(45) - . chr(44) - . chr(43) - . chr(42) - . chr(41) - . chr(40) - . chr(39) - . chr(38) - . chr(37) - . chr(36) - . chr(35) - . chr(34) - . chr(33) - . chr(32) - . chr(31) - . chr(30) - . chr(29) - . chr(28) - . chr(27) - . chr(26) - . chr(25) - . chr(24) - . chr(23) - . chr(22) - . chr(21) - . chr(20) - . chr(19) - . chr(18) - . chr(17) - . chr(16) - . chr(15) - . chr(14) - . chr(13) - . chr(12) - . chr(11) - . chr(10) - . chr(9) - . chr(8) - . chr(7) - . chr(6) - . chr(5) - . chr(4) - . chr(3) - . chr(2) - . chr(1), - '514963c4fde0cee7ff91f76dd56015cc' - ), + ['DATAMATRIX,S', chr(255) + . chr(254) + . chr(253) + . chr(252) + . chr(251) + . chr(250) + . chr(249) + . chr(248) + . chr(247) + . chr(246) + . chr(245) + . chr(244) + . chr(243) + . chr(242) + . chr(241) + . chr(240) + . chr(239) + . chr(238) + . chr(237) + . chr(236) + . chr(235) + . chr(234) + . chr(233) + . chr(232) + . chr(231) + . chr(230) + . chr(229) + . chr(228) + . chr(227) + . chr(226) + . chr(225) + . chr(224) + . chr(223) + . chr(222) + . chr(221) + . chr(220) + . chr(219) + . chr(218) + . chr(217) + . chr(216) + . chr(215) + . chr(214) + . chr(213) + . chr(212) + . chr(211) + . chr(210) + . chr(209) + . chr(208) + . chr(207) + . chr(206) + . chr(205) + . chr(204) + . chr(203) + . chr(202) + . chr(201) + . chr(200) + . chr(199) + . chr(198) + . chr(197) + . chr(196) + . chr(195) + . chr(194) + . chr(193) + . chr(192) + . chr(191) + . chr(190) + . chr(189) + . chr(188) + . chr(187) + . chr(186) + . chr(185) + . chr(184) + . chr(183) + . chr(182) + . chr(181) + . chr(180) + . chr(179) + . chr(178) + . chr(177) + . chr(176) + . chr(175) + . chr(174) + . chr(173) + . chr(172) + . chr(171) + . chr(170) + . chr(169) + . chr(168) + . chr(167) + . chr(166) + . chr(165) + . chr(164) + . chr(163) + . chr(162) + . chr(161) + . chr(160) + . chr(159) + . chr(158) + . chr(157) + . chr(156) + . chr(155) + . chr(154) + . chr(153) + . chr(152) + . chr(151) + . chr(150) + . chr(149) + . chr(148) + . chr(147) + . chr(146) + . chr(145) + . chr(144) + . chr(143) + . chr(142) + . chr(141) + . chr(140) + . chr(139) + . chr(138) + . chr(137) + . chr(136) + . chr(135) + . chr(134) + . chr(133) + . chr(132) + . chr(131) + . chr(130) + . chr(129) + . chr(128) + . chr(127) + . chr(126) + . chr(125) + . chr(124) + . chr(123) + . chr(122) + . chr(121) + . chr(120) + . chr(119) + . chr(118) + . chr(117) + . chr(116) + . chr(115) + . chr(114) + . chr(113) + . chr(112) + . chr(111) + . chr(110) + . chr(109) + . chr(108) + . chr(107) + . chr(106) + . chr(105) + . chr(104) + . chr(103) + . chr(102) + . chr(101) + . chr(100) + . chr(99) + . chr(98) + . chr(97) + . chr(96) + . chr(95) + . chr(94) + . chr(93) + . chr(92) + . chr(91) + . chr(90) + . chr(89) + . chr(88) + . chr(87) + . chr(86) + . chr(85) + . chr(84) + . chr(83) + . chr(82) + . chr(81) + . chr(80) + . chr(79) + . chr(78) + . chr(77) + . chr(76) + . chr(75) + . chr(74) + . chr(73) + . chr(72) + . chr(71) + . chr(70) + . chr(69) + . chr(68) + . chr(67) + . chr(66) + . chr(65) + . chr(64) + . chr(63) + . chr(62) + . chr(61) + . chr(60) + . chr(59) + . chr(58) + . chr(57) + . chr(56) + . chr(55) + . chr(54) + . chr(53) + . chr(52) + . chr(51) + . chr(50) + . chr(49) + . chr(48) + . chr(47) + . chr(46) + . chr(45) + . chr(44) + . chr(43) + . chr(42) + . chr(41) + . chr(40) + . chr(39) + . chr(38) + . chr(37) + . chr(36) + . chr(35) + . chr(34) + . chr(33) + . chr(32) + . chr(31) + . chr(30) + . chr(29) + . chr(28) + . chr(27) + . chr(26) + . chr(25) + . chr(24) + . chr(23) + . chr(22) + . chr(21) + . chr(20) + . chr(19) + . chr(18) + . chr(17) + . chr(16) + . chr(15) + . chr(14) + . chr(13) + . chr(12) + . chr(11) + . chr(10) + . chr(9) + . chr(8) + . chr(7) + . chr(6) + . chr(5) + . chr(4) + . chr(3) + . chr(2) + . chr(1), '514963c4fde0cee7ff91f76dd56015cc'], // Rectangular shape - array('DATAMATRIX,R', '01234567890', 'd3811e018f960beed6d3fa5e675e290e'), - array('DATAMATRIX,R', '01234567890123456789', 'fe3ecb042dabc4b40c5017e204df105b'), - array('DATAMATRIX,R', '012345678901234567890123456789', '3f8e9aa4413b90f7e1c2e85b4471fd20'), - array('DATAMATRIX,R', '0123456789012345678901234567890123456789', 'b748b02c1c4cae621a84c8dbba97c710'), + ['DATAMATRIX,R', '01234567890', 'd3811e018f960beed6d3fa5e675e290e'], + ['DATAMATRIX,R', '01234567890123456789', 'fe3ecb042dabc4b40c5017e204df105b'], + ['DATAMATRIX,R', '012345678901234567890123456789', '3f8e9aa4413b90f7e1c2e85b4471fd20'], + ['DATAMATRIX,R', '0123456789012345678901234567890123456789', 'b748b02c1c4cae621a84c8dbba97c710'], // Rectangular GS1 - array('DATAMATRIX,R,GS1', - chr(232) . '01034531200000111719112510ABCD1234', - 'f55524d239fc95072d99eafe5363cfeb'), - array('DATAMATRIX,R,GS1', - chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', - 'e17f2a052271a18cdc00b161908eccb9'), - array('DATAMATRIX,R,GS1', - chr(232) . '01034531200000111712050810ABCD1234' . chr(232) . '4109501101020917', - '31759950f3253805b100fedf3e536575'), + ['DATAMATRIX,R,GS1', chr(232) . '01034531200000111719112510ABCD1234', 'f55524d239fc95072d99eafe5363cfeb'], + ['DATAMATRIX,R,GS1', chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', 'e17f2a052271a18cdc00b161908eccb9'], + ['DATAMATRIX,R,GS1', chr(232) . '01034531200000111712050810ABCD1234' . chr(232) . '4109501101020917', '31759950f3253805b100fedf3e536575'], // Square GS1 - array('DATAMATRIX,S,GS1', - chr(232) . '01034531200000111719112510ABCD1234', - 'c9efb69a62114fb6a3d2b52f139a372a'), - array('DATAMATRIX,S,GS1', - chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', - '9630bdba9fc79b4a4911fc465aa08951'), - array('DATAMATRIX,S,GS1', - chr(232) . '01034531200000111712050810ABCD1234' . chr(232) . '4109501101020917', - 'a29a330a01cce34a346cf7049e2259ee'), - ); + ['DATAMATRIX,S,GS1', chr(232) . '01034531200000111719112510ABCD1234', 'c9efb69a62114fb6a3d2b52f139a372a'], + ['DATAMATRIX,S,GS1', chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', '9630bdba9fc79b4a4911fc465aa08951'], + ['DATAMATRIX,S,GS1', chr(232) . '01034531200000111712050810ABCD1234' . chr(232) . '4109501101020917', 'a29a330a01cce34a346cf7049e2259ee'], + ]; } /** * @dataProvider getStringDataProvider */ - public function testStrings($code) + public function testStrings(string|array $code): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('DATAMATRIX', $code); - $this->assertNotNull($bobj); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('DATAMATRIX', $code); + $this->assertNotNull($type); } public static function getStringDataProvider() diff --git a/test/Square/PdfFourOneSevenTest.php b/test/Square/PdfFourOneSevenTest.php index f2074894..14cbe59e 100644 --- a/test/Square/PdfFourOneSevenTest.php +++ b/test/Square/PdfFourOneSevenTest.php @@ -32,1367 +32,1361 @@ */ class PdfFourOneSevenTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('PDF417', ''); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('PDF417', ''); } - public function testCapacityException() + public function testCapacityException(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); $code = str_pad('', 1000, 'X1'); - $testObj->getBarcodeObj('PDF417', $code); + $barcode->getBarcodeObj('PDF417', $code); } /** * @dataProvider getGridDataProvider */ - public function testGetGrid($options, $code, $expected) + public function testGetGrid(string $options, string $code, mixed $expected): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('PDF417' . $options, $code); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('PDF417' . $options, $code); + $grid = $type->getGrid(); $this->assertEquals($expected, md5($grid)); } - public static function getGridDataProvider() + public static function getGridDataProvider(): array { - return array( - array('', str_pad('', 1850, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), '38e205c911b94a62c72b7d20fa4361f8'), // max text - array('', str_pad('', 2710, '123456789'), '32ba9be56f3e66559b4d4a50f6276da7'), // max digits - array('', 'abc/abc', '831874fe7d1b3d865c222858eba3507c'), - array('', '0123456789', '4f9cdac81d62f0020beb93fc3ecdd8ad'), - array(',2,8,1,0,0,0,1,2', str_pad('', 1750, 'X'), 'f0874a35e15f11f9aa8bc070a4be24bf'), - array(',15,8,1,0,0,0,1,2', str_pad('', 1750, 'X'), '0288f0a87cc069fc34d6168d7a9f7846'), - array('', str_pad('', 350, '0123456789'), '394d93048831fee232413da29fb709fb'), - array('', 'abcdefghijklmnopqrstuvwxyz01234567890123456789', 'bd4f4215aca0bbc3452a35b81fcf7bdb'), - array( - '', - chr(158) - . chr(19) - . chr(192) - . chr(8) - . chr(71) - . chr(113) - . chr(107) - . chr(252) - . chr(171) - . chr(169) - . chr(114) - . chr(114) - . chr(204) - . chr(151) - . chr(183) - . chr(20) - . chr(180) - . chr(26) - . chr(73) - . chr(76) - . chr(193) - . chr(16) - . chr(69) - . chr(212) - . chr(232) - . chr(90) - . chr(248) - . chr(115) - . chr(9) - . chr(104) - . chr(149) - . chr(167) - . chr(123) - . chr(86) - . chr(175) - . chr(193) - . chr(199) - . chr(27) - . chr(190) - . chr(115) - . chr(196) - . chr(50) - . chr(228) - . chr(146) - . chr(201) - . chr(156) - . chr(165) - . chr(126) - . chr(182) - . chr(237) - . chr(201) - . chr(121) - . chr(253) - . chr(15) - . chr(78) - . chr(231) - . chr(105) - . chr(72) - . chr(92) - . chr(114) - . chr(175) - . chr(240) - . chr(26) - . chr(43) - . chr(71) - . chr(200) - . chr(236) - . chr(15) - . chr(227) - . chr(172) - . chr(129) - . chr(169) - . chr(221) - . chr(103) - . chr(60) - . chr(167) - . chr(5) - . chr(225) - . chr(39) - . chr(186) - . chr(208) - . chr(240) - . chr(52) - . chr(206) - . chr(254) - . chr(130) - . chr(183) - . chr(105) - . chr(201) - . chr(20) - . chr(218) - . chr(122) - . chr(5) - . chr(244) - . chr(165) - . chr(76) - . chr(189) - . chr(146) - . chr(91) - . chr(162) - . chr(63) - . chr(220) - . chr(76) - . chr(30) - . chr(68) - . chr(135) - . chr(196) - . chr(73) - . chr(106) - . chr(235) - . chr(5) - . chr(59) - . chr(220) - . chr(56) - . chr(11) - . chr(220) - . chr(186) - . chr(194) - . chr(70) - . chr(132) - . chr(213) - . chr(34) - . chr(254) - . chr(218) - . chr(23) - . chr(164) - . chr(40) - . chr(212) - . chr(56) - . chr(130) - . chr(119) - . chr(118) - . chr(95) - . chr(194) - . chr(148) - . chr(163) - . chr(75) - . chr(90) - . chr(236) - . chr(180) - . chr(70) - . chr(240) - . chr(239) - . chr(35) - . chr(42) - . chr(250) - . chr(254) - . chr(227) - . chr(189) - . chr(70) - . chr(105) - . chr(148) - . chr(103) - . chr(104) - . chr(112) - . chr(126) - . chr(13) - . chr(151) - . chr(83) - . chr(68) - . chr(27) - . chr(201) - . chr(186) - . chr(121) - . chr(141) - . chr(80) - . chr(30) - . chr(215) - . chr(169) - . chr(12) - . chr(141) - . chr(238) - . chr(251) - . chr(126) - . chr(18) - . chr(39) - . chr(121) - . chr(18) - . chr(12) - . chr(56) - . chr(88) - . chr(116) - . chr(203) - . chr(190) - . chr(220) - . chr(60) - . chr(61) - . chr(233) - . chr(211) - . chr(144) - . chr(47) - . chr(237) - . chr(90) - . chr(232) - . chr(104) - . chr(230) - . chr(57) - . chr(134) - . chr(191) - . chr(226) - . chr(145) - . chr(77) - . chr(209) - . chr(142) - . chr(202) - . chr(227) - . chr(180) - . chr(69) - . chr(245) - . chr(191) - . chr(124) - . chr(78) - . chr(53) - . chr(73) - . chr(13) - . chr(18) - . chr(133) - . chr(74) - . chr(250) - . chr(89) - . chr(217) - . chr(42) - . chr(71) - . chr(53) - . chr(20) - . chr(175) - . chr(29) - . chr(77) - . chr(54) - . chr(219) - . chr(48) - . chr(198) - . chr(41) - . chr(3) - . chr(85) - . chr(243) - . chr(229) - . chr(11) - . chr(57) - . chr(219) - . chr(201) - . chr(180) - . chr(43) - . chr(253) - . chr(252) - . chr(56) - . chr(17) - . chr(131) - . chr(129) - . chr(12) - . chr(219) - . chr(92) - . chr(54) - . chr(36) - . chr(145) - . chr(74) - . chr(210) - . chr(173) - . chr(151) - . chr(9) - . chr(137) - . chr(198) - . chr(207) - . chr(178) - . chr(201) - . chr(38) - . chr(166) - . chr(175) - . chr(48) - . chr(223) - . chr(140) - . chr(249) - . chr(149) - . chr(182) - . chr(248) - . chr(147) - . chr(237) - . chr(10) - . chr(23) - . chr(112) - . chr(22) - . chr(241) - . chr(204) - . chr(76) - . chr(23) - . chr(94) - . chr(150) - . chr(232) - . chr(13) - . chr(46) - . chr(241) - . chr(149) - . chr(243) - . chr(193) - . chr(73) - . chr(190) - . chr(230) - . chr(239) - . chr(110) - . chr(24), - '1cae7ca47cde6ca52522ce31771a5c54' - ), - array( - '', - chr(158) - . chr(198) - . chr(45) - . chr(94) - . chr(231) - . chr(83) - . chr(60) - . chr(45) - . chr(104) - . chr(62) - . chr(122) - . chr(88) - . chr(245) - . chr(8) - . chr(21) - . chr(76) - . chr(170) - . chr(250) - . chr(87) - . chr(6) - . chr(162) - . chr(32) - . chr(43) - . chr(208) - . chr(17) - . chr(96) - . chr(139) - . chr(43) - . chr(192) - . chr(15) - . chr(57) - . chr(95) - . chr(212) - . chr(102) - . chr(189) - . chr(188) - . chr(184) - . chr(249) - . chr(233) - . chr(34) - . chr(56) - . chr(101) - . chr(122) - . chr(47) - . chr(108) - . chr(142) - . chr(122) - . chr(24) - . chr(137) - . chr(209) - . chr(30) - . chr(45) - . chr(240) - . chr(72) - . chr(253) - . chr(2) - . chr(167) - . chr(138) - . chr(44) - . chr(105) - . chr(152) - . chr(101) - . chr(200) - . chr(109) - . chr(202) - . chr(135) - . chr(43) - . chr(132) - . chr(129) - . chr(21) - . chr(165) - . chr(185) - . chr(121) - . chr(32) - . chr(231) - . chr(229) - . chr(174) - . chr(99) - . chr(252) - . chr(57) - . chr(53) - . chr(27) - . chr(101) - . chr(38) - . chr(99) - . chr(100) - . chr(39) - . chr(12) - . chr(237) - . chr(83) - . chr(116) - . chr(134) - . chr(183) - . chr(62) - . chr(243) - . chr(131) - . chr(196) - . chr(31) - . chr(8) - . chr(70) - . chr(52) - . chr(172) - . chr(254) - . chr(173) - . chr(204) - . chr(231) - . chr(147) - . chr(124) - . chr(75) - . chr(145) - . chr(180) - . chr(128) - . chr(172) - . chr(27) - . chr(165) - . chr(16) - . chr(126) - . chr(204) - . chr(27) - . chr(109) - . chr(33) - . chr(143) - . chr(242) - . chr(216) - . chr(204) - . chr(231) - . chr(92) - . chr(145) - . chr(7) - . chr(99) - . chr(214) - . chr(59) - . chr(17) - . chr(214) - . chr(231) - . chr(221) - . chr(190) - . chr(124) - . chr(90) - . chr(11) - . chr(14) - . chr(16) - . chr(138) - . chr(186) - . chr(43) - . chr(49) - . chr(201) - . chr(168) - . chr(252) - . chr(227) - . chr(22) - . chr(31) - . chr(116) - . chr(10) - . chr(246) - . chr(65) - . chr(240) - . chr(83) - . chr(209) - . chr(247) - . chr(182) - . chr(169) - . chr(52) - . chr(199) - . chr(129) - . chr(29) - . chr(165) - . chr(65) - . chr(152) - . chr(1) - . chr(75) - . chr(166) - . chr(17) - . chr(212) - . chr(97) - . chr(59) - . chr(7) - . chr(44) - . chr(227) - . chr(4) - . chr(17) - . chr(249) - . chr(35) - . chr(132) - . chr(5) - . chr(26) - . chr(196) - . chr(244) - . chr(108) - . chr(151) - . chr(237) - . chr(36) - . chr(66) - . chr(34) - . chr(234) - . chr(194) - . chr(63) - . chr(145) - . chr(4) - . chr(214) - . chr(146) - . chr(79) - . chr(126) - . chr(162) - . chr(36) - . chr(222) - . chr(220) - . chr(42) - . chr(12) - . chr(193) - . chr(46) - . chr(28) - . chr(187) - . chr(80) - . chr(159) - . chr(191) - . chr(106) - . chr(100) - . chr(181) - . chr(213) - . chr(251) - . chr(164) - . chr(249) - . chr(62) - . chr(198) - . chr(228) - . chr(2) - . chr(6) - . chr(119) - . chr(5) - . chr(220) - . chr(10) - . chr(83) - . chr(91) - . chr(171) - . chr(119) - . chr(59) - . chr(137) - . chr(161) - . chr(70) - . chr(75) - . chr(207) - . chr(97) - . chr(8) - . chr(33) - . chr(1) - . chr(198) - . chr(138) - . chr(101) - . chr(125) - . chr(97) - . chr(97) - . chr(34) - . chr(91) - . chr(159) - . chr(231) - . chr(65) - . chr(160) - . chr(237) - . chr(183) - . chr(165) - . chr(202) - . chr(192) - . chr(248) - . chr(38) - . chr(108) - . chr(112) - . chr(96) - . chr(245) - . chr(19) - . chr(166) - . chr(65) - . chr(225) - . chr(8) - . chr(72) - . chr(4) - . chr(9) - . chr(16) - . chr(141) - . chr(109) - . chr(141) - . chr(237) - . chr(206) - . chr(174) - . chr(73) - . chr(111) - . chr(151) - . chr(138) - . chr(16) - . chr(133) - . chr(66) - . chr(180) - . chr(81) - . chr(3) - . chr(173) - . chr(118) - . chr(111) - . chr(31) - . chr(214) - . chr(101) - . chr(49) - . chr(125) - . chr(166) - . chr(20) - . chr(133) - . chr(238) - . chr(23) - . chr(141) - . chr(254) - . chr(163) - . chr(250) - . chr(140) - . chr(146) - . chr(202) - . chr(60) - . chr(219) - . chr(58) - . chr(211) - . chr(102) - . chr(73) - . chr(90) - . chr(167) - . chr(253) - . chr(170) - . chr(170) - . chr(172) - . chr(34) - . chr(27) - . chr(202) - . chr(247) - . chr(128) - . chr(251) - . chr(117) - . chr(39) - . chr(17) - . chr(249) - . chr(23) - . chr(39) - . chr(136) - . chr(22) - . chr(202) - . chr(131) - . chr(162) - . chr(94) - . chr(78) - . chr(222) - . chr(58) - . chr(136) - . chr(178) - . chr(159) - . chr(209) - . chr(14) - . chr(72) - . chr(207) - . chr(183) - . chr(242) - . chr(124) - . chr(217) - . chr(14) - . chr(72) - . chr(209) - . chr(141) - . chr(69) - . chr(72) - . chr(180) - . chr(85) - . chr(67) - . chr(202) - . chr(124) - . chr(202) - . chr(224) - . chr(72) - . chr(79) - . chr(131) - . chr(165) - . chr(157) - . chr(99) - . chr(223) - . chr(38) - . chr(23) - . chr(128) - . chr(246) - . chr(36) - . chr(199) - . chr(199) - . chr(219) - . chr(187) - . chr(69) - . chr(181) - . chr(200) - . chr(140) - . chr(136) - . chr(86) - . chr(208) - . chr(207) - . chr(11) - . chr(39) - . chr(19) - . chr(213) - . chr(162) - . chr(221) - . chr(182) - . chr(233) - . chr(46) - . chr(59) - . chr(144) - . chr(202) - . chr(157) - . chr(112) - . chr(240) - . chr(179) - . chr(240) - . chr(231) - . chr(215) - . chr(185) - . chr(176) - . chr(180) - . chr(117) - . chr(244) - . chr(106) - . chr(62) - . chr(129) - . chr(242) - . chr(148) - . chr(83) - . chr(194) - . chr(159) - . chr(121) - . chr(213) - . chr(117) - . chr(29) - . chr(179) - . chr(44) - . chr(8) - . chr(224) - . chr(103) - . chr(151) - . chr(172) - . chr(5) - . chr(9) - . chr(157) - . chr(184) - . chr(248) - . chr(134) - . chr(145) - . chr(179) - . chr(55) - . chr(70) - . chr(41) - . chr(44) - . chr(176) - . chr(102) - . chr(173) - . chr(163) - . chr(250) - . chr(2) - . chr(103) - . chr(154) - . chr(123) - . chr(61) - . chr(16) - . chr(151) - . chr(240) - . chr(60) - . chr(159) - . chr(210) - . chr(162) - . chr(55) - . chr(127) - . chr(167) - . chr(64) - . chr(30) - . chr(97) - . chr(58) - . chr(163) - . chr(241) - . chr(236) - . chr(218) - . chr(57) - . chr(22) - . chr(8) - . chr(233) - . chr(124) - . chr(180) - . chr(141) - . chr(119) - . chr(182) - . chr(243) - . chr(18) - . chr(51) - . chr(50) - . chr(34) - . chr(201) - . chr(35) - . chr(93) - . chr(106) - . chr(244) - . chr(1) - . chr(161) - . chr(116) - . chr(167) - . chr(224) - . chr(146) - . chr(9) - . chr(28) - . chr(54) - . chr(250) - . chr(10) - . chr(17) - . chr(53) - . chr(32) - . chr(24) - . chr(31) - . chr(155) - . chr(204) - . chr(172) - . chr(20) - . chr(132) - . chr(160) - . chr(38) - . chr(182) - . chr(209) - . chr(72) - . chr(129) - . chr(243) - . chr(164) - . chr(234) - . chr(233) - . chr(164) - . chr(140) - . chr(95) - . chr(77) - . chr(110) - . chr(240) - . chr(86) - . chr(137) - . chr(39) - . chr(81) - . chr(146) - . chr(56) - . chr(134) - . chr(177) - . chr(80) - . chr(164) - . chr(78) - . chr(30) - . chr(81) - . chr(98) - . chr(161) - . chr(241) - . chr(135) - . chr(88) - . chr(196) - . chr(206) - . chr(216) - . chr(185) - . chr(116) - . chr(195) - . chr(163) - . chr(26) - . chr(81) - . chr(3) - . chr(102) - . chr(190) - . chr(243) - . chr(187) - . chr(72) - . chr(28) - . chr(14) - . chr(218) - . chr(83) - . chr(147) - . chr(141) - . chr(163) - . chr(57) - . chr(218) - . chr(192) - . chr(137) - . chr(61) - . chr(98) - . chr(124) - . chr(196) - . chr(186) - . chr(65) - . chr(148) - . chr(147) - . chr(249) - . chr(9) - . chr(88) - . chr(157) - . chr(34) - . chr(168) - . chr(160) - . chr(135) - . chr(103) - . chr(148) - . chr(68) - . chr(175) - . chr(176) - . chr(81) - . chr(138) - . chr(4) - . chr(228) - . chr(25) - . chr(167) - . chr(30) - . chr(242) - . chr(104) - . chr(167) - . chr(49) - . chr(202) - . chr(36) - . chr(244) - . chr(133) - . chr(100) - . chr(138) - . chr(26) - . chr(94) - . chr(146) - . chr(113) - . chr(251) - . chr(180) - . chr(27) - . chr(157) - . chr(61) - . chr(129) - . chr(51) - . chr(128) - . chr(50) - . chr(226) - . chr(209) - . chr(188) - . chr(230) - . chr(182) - . chr(212) - . chr(142) - . chr(212) - . chr(200) - . chr(246) - . chr(124) - . chr(248) - . chr(193) - . chr(159) - . chr(238) - . chr(71) - . chr(4) - . chr(121) - . chr(96) - . chr(98) - . chr(13) - . chr(209) - . chr(95) - . chr(193) - . chr(235) - . chr(251) - . chr(253) - . chr(110) - . chr(47) - . chr(127) - . chr(159) - . chr(18) - . chr(81) - . chr(93) - . chr(247) - . chr(9) - . chr(50) - . chr(135) - . chr(220) - . chr(249) - . chr(126) - . chr(90) - . chr(243) - . chr(64) - . chr(248) - . chr(227) - . chr(135) - . chr(252) - . chr(94) - . chr(231) - . chr(96) - . chr(106) - . chr(186) - . chr(190) - . chr(44) - . chr(166) - . chr(187) - . chr(43) - . chr(21) - . chr(233) - . chr(169) - . chr(180) - . chr(251) - . chr(250) - . chr(18) - . chr(244) - . chr(5) - . chr(68) - . chr(124) - . chr(225) - . chr(63) - . chr(250) - . chr(60) - . chr(52) - . chr(59) - . chr(53) - . chr(24) - . chr(194) - . chr(51) - . chr(117) - . chr(171) - . chr(146) - . chr(223) - . chr(102) - . chr(82) - . chr(12) - . chr(13) - . chr(14) - . chr(54) - . chr(34) - . chr(246) - . chr(223) - . chr(214) - . chr(243) - . chr(218) - . chr(232) - . chr(232) - . chr(222) - . chr(45) - . chr(102) - . chr(192) - . chr(108) - . chr(97) - . chr(252) - . chr(159) - . chr(156) - . chr(50) - . chr(183) - . chr(96) - . chr(101) - . chr(45) - . chr(12) - . chr(246) - . chr(13) - . chr(113) - . chr(73) - . chr(25) - . chr(126) - . chr(87) - . chr(79) - . chr(160) - . chr(78) - . chr(47) - . chr(119) - . chr(67) - . chr(11) - . chr(96) - . chr(45) - . chr(233) - . chr(141) - . chr(146) - . chr(171) - . chr(249) - . chr(242) - . chr(168) - . chr(153) - . chr(143) - . chr(218) - . chr(81) - . chr(238) - . chr(64) - . chr(126) - . chr(250) - . chr(55) - . chr(139) - . chr(109) - . chr(128) - . chr(163) - . chr(234) - . chr(214) - . chr(242) - . chr(139) - . chr(38) - . chr(34) - . chr(4) - . chr(104) - . chr(45) - . chr(100) - . chr(148) - . chr(23) - . chr(241) - . chr(40) - . chr(194) - . chr(235) - . chr(27) - . chr(107) - . chr(133) - . chr(170) - . chr(70) - . chr(214) - . chr(154) - . chr(133) - . chr(86) - . chr(149) - . chr(188) - . chr(224) - . chr(3) - . chr(61) - . chr(133) - . chr(237) - . chr(21) - . chr(121) - . chr(122) - . chr(59) - . chr(154) - . chr(125) - . chr(163) - . chr(199) - . chr(225) - . chr(56) - . chr(222) - . chr(211) - . chr(96) - . chr(161) - . chr(191) - . chr(122) - . chr(13) - . chr(70) - . chr(38) - . chr(82) - . chr(30) - . chr(191) - . chr(215) - . chr(115) - . chr(86) - . chr(148) - . chr(85) - . chr(89) - . chr(209) - . chr(218) - . chr(71) - . chr(230) - . chr(84) - . chr(193) - . chr(34) - . chr(238) - . chr(63) - . chr(196) - . chr(182) - . chr(34) - . chr(252) - . chr(149) - . chr(244) - . chr(93) - . chr(55) - . chr(180) - . chr(215) - . chr(68) - . chr(249) - . chr(252) - . chr(150) - . chr(24) - . chr(189) - . chr(110) - . chr(139) - . chr(21) - . chr(4) - . chr(223) - . chr(109) - . chr(213) - . chr(186) - . chr(180) - . chr(188) - . chr(16) - . chr(118) - . chr(221) - . chr(253) - . chr(181) - . chr(163) - . chr(180) - . chr(214) - . chr(160) - . chr(75) - . chr(203) - . chr(252) - . chr(130) - . chr(129) - . chr(213) - . chr(197) - . chr(124) - . chr(210) - . chr(92) - . chr(148) - . chr(145) - . chr(202) - . chr(32) - . chr(166) - . chr(205) - . chr(1) - . chr(21) - . chr(164) - . chr(187) - . chr(200) - . chr(97) - . chr(202) - . chr(64) - . chr(64) - . chr(200) - . chr(245) - . chr(226) - . chr(126) - . chr(205) - . chr(132) - . chr(201) - . chr(154) - . chr(130) - . chr(76) - . chr(28) - . chr(88) - . chr(18) - . chr(152) - . chr(44) - . chr(110) - . chr(45) - . chr(188) - . chr(57) - . chr(76) - . chr(100) - . chr(8) - . chr(76) - . chr(120) - . chr(172) - . chr(9) - . chr(65) - . chr(14) - . chr(210) - . chr(129) - . chr(78) - . chr(156) - . chr(120) - . chr(50) - . chr(28) - . chr(70) - . chr(181) - . chr(228) - . chr(223) - . chr(56) - . chr(49) - . chr(251) - . chr(143) - . chr(67) - . chr(148) - . chr(187) - . chr(176) - . chr(192) - . chr(120) - . chr(233) - . chr(14) - . chr(219) - . chr(241) - . chr(90) - . chr(85) - . chr(158) - . chr(98) - . chr(150) - . chr(172) - . chr(54) - . chr(24) - . chr(249) - . chr(209) - . chr(143) - . chr(45) - . chr(236) - . chr(213) - . chr(225) - . chr(210) - . chr(182) - . chr(27) - . chr(4) - . chr(179) - . chr(169) - . chr(70) - . chr(72) - . chr(101) - . chr(246) - . chr(10) - . chr(221) - . chr(225) - . chr(24) - . chr(186) - . chr(212) - . chr(113) - . chr(16) - . chr(115) - . chr(211) - . chr(165) - . chr(33) - . chr(10) - . chr(189) - . chr(28) - . chr(219), - '6c1033648fc11250ad22006398cd1bdc' - ), - ); + return [ + ['', str_pad('', 1850, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), '38e205c911b94a62c72b7d20fa4361f8'], + // max text + ['', str_pad('', 2710, '123456789'), '32ba9be56f3e66559b4d4a50f6276da7'], + // max digits + ['', 'abc/abc', '831874fe7d1b3d865c222858eba3507c'], + ['', '0123456789', '4f9cdac81d62f0020beb93fc3ecdd8ad'], + [',2,8,1,0,0,0,1,2', str_pad('', 1750, 'X'), 'f0874a35e15f11f9aa8bc070a4be24bf'], + [',15,8,1,0,0,0,1,2', str_pad('', 1750, 'X'), '0288f0a87cc069fc34d6168d7a9f7846'], + ['', str_pad('', 350, '0123456789'), '394d93048831fee232413da29fb709fb'], + ['', 'abcdefghijklmnopqrstuvwxyz01234567890123456789', 'bd4f4215aca0bbc3452a35b81fcf7bdb'], + ['', chr(158) + . chr(19) + . chr(192) + . chr(8) + . chr(71) + . chr(113) + . chr(107) + . chr(252) + . chr(171) + . chr(169) + . chr(114) + . chr(114) + . chr(204) + . chr(151) + . chr(183) + . chr(20) + . chr(180) + . chr(26) + . chr(73) + . chr(76) + . chr(193) + . chr(16) + . chr(69) + . chr(212) + . chr(232) + . chr(90) + . chr(248) + . chr(115) + . chr(9) + . chr(104) + . chr(149) + . chr(167) + . chr(123) + . chr(86) + . chr(175) + . chr(193) + . chr(199) + . chr(27) + . chr(190) + . chr(115) + . chr(196) + . chr(50) + . chr(228) + . chr(146) + . chr(201) + . chr(156) + . chr(165) + . chr(126) + . chr(182) + . chr(237) + . chr(201) + . chr(121) + . chr(253) + . chr(15) + . chr(78) + . chr(231) + . chr(105) + . chr(72) + . chr(92) + . chr(114) + . chr(175) + . chr(240) + . chr(26) + . chr(43) + . chr(71) + . chr(200) + . chr(236) + . chr(15) + . chr(227) + . chr(172) + . chr(129) + . chr(169) + . chr(221) + . chr(103) + . chr(60) + . chr(167) + . chr(5) + . chr(225) + . chr(39) + . chr(186) + . chr(208) + . chr(240) + . chr(52) + . chr(206) + . chr(254) + . chr(130) + . chr(183) + . chr(105) + . chr(201) + . chr(20) + . chr(218) + . chr(122) + . chr(5) + . chr(244) + . chr(165) + . chr(76) + . chr(189) + . chr(146) + . chr(91) + . chr(162) + . chr(63) + . chr(220) + . chr(76) + . chr(30) + . chr(68) + . chr(135) + . chr(196) + . chr(73) + . chr(106) + . chr(235) + . chr(5) + . chr(59) + . chr(220) + . chr(56) + . chr(11) + . chr(220) + . chr(186) + . chr(194) + . chr(70) + . chr(132) + . chr(213) + . chr(34) + . chr(254) + . chr(218) + . chr(23) + . chr(164) + . chr(40) + . chr(212) + . chr(56) + . chr(130) + . chr(119) + . chr(118) + . chr(95) + . chr(194) + . chr(148) + . chr(163) + . chr(75) + . chr(90) + . chr(236) + . chr(180) + . chr(70) + . chr(240) + . chr(239) + . chr(35) + . chr(42) + . chr(250) + . chr(254) + . chr(227) + . chr(189) + . chr(70) + . chr(105) + . chr(148) + . chr(103) + . chr(104) + . chr(112) + . chr(126) + . chr(13) + . chr(151) + . chr(83) + . chr(68) + . chr(27) + . chr(201) + . chr(186) + . chr(121) + . chr(141) + . chr(80) + . chr(30) + . chr(215) + . chr(169) + . chr(12) + . chr(141) + . chr(238) + . chr(251) + . chr(126) + . chr(18) + . chr(39) + . chr(121) + . chr(18) + . chr(12) + . chr(56) + . chr(88) + . chr(116) + . chr(203) + . chr(190) + . chr(220) + . chr(60) + . chr(61) + . chr(233) + . chr(211) + . chr(144) + . chr(47) + . chr(237) + . chr(90) + . chr(232) + . chr(104) + . chr(230) + . chr(57) + . chr(134) + . chr(191) + . chr(226) + . chr(145) + . chr(77) + . chr(209) + . chr(142) + . chr(202) + . chr(227) + . chr(180) + . chr(69) + . chr(245) + . chr(191) + . chr(124) + . chr(78) + . chr(53) + . chr(73) + . chr(13) + . chr(18) + . chr(133) + . chr(74) + . chr(250) + . chr(89) + . chr(217) + . chr(42) + . chr(71) + . chr(53) + . chr(20) + . chr(175) + . chr(29) + . chr(77) + . chr(54) + . chr(219) + . chr(48) + . chr(198) + . chr(41) + . chr(3) + . chr(85) + . chr(243) + . chr(229) + . chr(11) + . chr(57) + . chr(219) + . chr(201) + . chr(180) + . chr(43) + . chr(253) + . chr(252) + . chr(56) + . chr(17) + . chr(131) + . chr(129) + . chr(12) + . chr(219) + . chr(92) + . chr(54) + . chr(36) + . chr(145) + . chr(74) + . chr(210) + . chr(173) + . chr(151) + . chr(9) + . chr(137) + . chr(198) + . chr(207) + . chr(178) + . chr(201) + . chr(38) + . chr(166) + . chr(175) + . chr(48) + . chr(223) + . chr(140) + . chr(249) + . chr(149) + . chr(182) + . chr(248) + . chr(147) + . chr(237) + . chr(10) + . chr(23) + . chr(112) + . chr(22) + . chr(241) + . chr(204) + . chr(76) + . chr(23) + . chr(94) + . chr(150) + . chr(232) + . chr(13) + . chr(46) + . chr(241) + . chr(149) + . chr(243) + . chr(193) + . chr(73) + . chr(190) + . chr(230) + . chr(239) + . chr(110) + . chr(24), '1cae7ca47cde6ca52522ce31771a5c54'], + ['', chr(158) + . chr(198) + . chr(45) + . chr(94) + . chr(231) + . chr(83) + . chr(60) + . chr(45) + . chr(104) + . chr(62) + . chr(122) + . chr(88) + . chr(245) + . chr(8) + . chr(21) + . chr(76) + . chr(170) + . chr(250) + . chr(87) + . chr(6) + . chr(162) + . chr(32) + . chr(43) + . chr(208) + . chr(17) + . chr(96) + . chr(139) + . chr(43) + . chr(192) + . chr(15) + . chr(57) + . chr(95) + . chr(212) + . chr(102) + . chr(189) + . chr(188) + . chr(184) + . chr(249) + . chr(233) + . chr(34) + . chr(56) + . chr(101) + . chr(122) + . chr(47) + . chr(108) + . chr(142) + . chr(122) + . chr(24) + . chr(137) + . chr(209) + . chr(30) + . chr(45) + . chr(240) + . chr(72) + . chr(253) + . chr(2) + . chr(167) + . chr(138) + . chr(44) + . chr(105) + . chr(152) + . chr(101) + . chr(200) + . chr(109) + . chr(202) + . chr(135) + . chr(43) + . chr(132) + . chr(129) + . chr(21) + . chr(165) + . chr(185) + . chr(121) + . chr(32) + . chr(231) + . chr(229) + . chr(174) + . chr(99) + . chr(252) + . chr(57) + . chr(53) + . chr(27) + . chr(101) + . chr(38) + . chr(99) + . chr(100) + . chr(39) + . chr(12) + . chr(237) + . chr(83) + . chr(116) + . chr(134) + . chr(183) + . chr(62) + . chr(243) + . chr(131) + . chr(196) + . chr(31) + . chr(8) + . chr(70) + . chr(52) + . chr(172) + . chr(254) + . chr(173) + . chr(204) + . chr(231) + . chr(147) + . chr(124) + . chr(75) + . chr(145) + . chr(180) + . chr(128) + . chr(172) + . chr(27) + . chr(165) + . chr(16) + . chr(126) + . chr(204) + . chr(27) + . chr(109) + . chr(33) + . chr(143) + . chr(242) + . chr(216) + . chr(204) + . chr(231) + . chr(92) + . chr(145) + . chr(7) + . chr(99) + . chr(214) + . chr(59) + . chr(17) + . chr(214) + . chr(231) + . chr(221) + . chr(190) + . chr(124) + . chr(90) + . chr(11) + . chr(14) + . chr(16) + . chr(138) + . chr(186) + . chr(43) + . chr(49) + . chr(201) + . chr(168) + . chr(252) + . chr(227) + . chr(22) + . chr(31) + . chr(116) + . chr(10) + . chr(246) + . chr(65) + . chr(240) + . chr(83) + . chr(209) + . chr(247) + . chr(182) + . chr(169) + . chr(52) + . chr(199) + . chr(129) + . chr(29) + . chr(165) + . chr(65) + . chr(152) + . chr(1) + . chr(75) + . chr(166) + . chr(17) + . chr(212) + . chr(97) + . chr(59) + . chr(7) + . chr(44) + . chr(227) + . chr(4) + . chr(17) + . chr(249) + . chr(35) + . chr(132) + . chr(5) + . chr(26) + . chr(196) + . chr(244) + . chr(108) + . chr(151) + . chr(237) + . chr(36) + . chr(66) + . chr(34) + . chr(234) + . chr(194) + . chr(63) + . chr(145) + . chr(4) + . chr(214) + . chr(146) + . chr(79) + . chr(126) + . chr(162) + . chr(36) + . chr(222) + . chr(220) + . chr(42) + . chr(12) + . chr(193) + . chr(46) + . chr(28) + . chr(187) + . chr(80) + . chr(159) + . chr(191) + . chr(106) + . chr(100) + . chr(181) + . chr(213) + . chr(251) + . chr(164) + . chr(249) + . chr(62) + . chr(198) + . chr(228) + . chr(2) + . chr(6) + . chr(119) + . chr(5) + . chr(220) + . chr(10) + . chr(83) + . chr(91) + . chr(171) + . chr(119) + . chr(59) + . chr(137) + . chr(161) + . chr(70) + . chr(75) + . chr(207) + . chr(97) + . chr(8) + . chr(33) + . chr(1) + . chr(198) + . chr(138) + . chr(101) + . chr(125) + . chr(97) + . chr(97) + . chr(34) + . chr(91) + . chr(159) + . chr(231) + . chr(65) + . chr(160) + . chr(237) + . chr(183) + . chr(165) + . chr(202) + . chr(192) + . chr(248) + . chr(38) + . chr(108) + . chr(112) + . chr(96) + . chr(245) + . chr(19) + . chr(166) + . chr(65) + . chr(225) + . chr(8) + . chr(72) + . chr(4) + . chr(9) + . chr(16) + . chr(141) + . chr(109) + . chr(141) + . chr(237) + . chr(206) + . chr(174) + . chr(73) + . chr(111) + . chr(151) + . chr(138) + . chr(16) + . chr(133) + . chr(66) + . chr(180) + . chr(81) + . chr(3) + . chr(173) + . chr(118) + . chr(111) + . chr(31) + . chr(214) + . chr(101) + . chr(49) + . chr(125) + . chr(166) + . chr(20) + . chr(133) + . chr(238) + . chr(23) + . chr(141) + . chr(254) + . chr(163) + . chr(250) + . chr(140) + . chr(146) + . chr(202) + . chr(60) + . chr(219) + . chr(58) + . chr(211) + . chr(102) + . chr(73) + . chr(90) + . chr(167) + . chr(253) + . chr(170) + . chr(170) + . chr(172) + . chr(34) + . chr(27) + . chr(202) + . chr(247) + . chr(128) + . chr(251) + . chr(117) + . chr(39) + . chr(17) + . chr(249) + . chr(23) + . chr(39) + . chr(136) + . chr(22) + . chr(202) + . chr(131) + . chr(162) + . chr(94) + . chr(78) + . chr(222) + . chr(58) + . chr(136) + . chr(178) + . chr(159) + . chr(209) + . chr(14) + . chr(72) + . chr(207) + . chr(183) + . chr(242) + . chr(124) + . chr(217) + . chr(14) + . chr(72) + . chr(209) + . chr(141) + . chr(69) + . chr(72) + . chr(180) + . chr(85) + . chr(67) + . chr(202) + . chr(124) + . chr(202) + . chr(224) + . chr(72) + . chr(79) + . chr(131) + . chr(165) + . chr(157) + . chr(99) + . chr(223) + . chr(38) + . chr(23) + . chr(128) + . chr(246) + . chr(36) + . chr(199) + . chr(199) + . chr(219) + . chr(187) + . chr(69) + . chr(181) + . chr(200) + . chr(140) + . chr(136) + . chr(86) + . chr(208) + . chr(207) + . chr(11) + . chr(39) + . chr(19) + . chr(213) + . chr(162) + . chr(221) + . chr(182) + . chr(233) + . chr(46) + . chr(59) + . chr(144) + . chr(202) + . chr(157) + . chr(112) + . chr(240) + . chr(179) + . chr(240) + . chr(231) + . chr(215) + . chr(185) + . chr(176) + . chr(180) + . chr(117) + . chr(244) + . chr(106) + . chr(62) + . chr(129) + . chr(242) + . chr(148) + . chr(83) + . chr(194) + . chr(159) + . chr(121) + . chr(213) + . chr(117) + . chr(29) + . chr(179) + . chr(44) + . chr(8) + . chr(224) + . chr(103) + . chr(151) + . chr(172) + . chr(5) + . chr(9) + . chr(157) + . chr(184) + . chr(248) + . chr(134) + . chr(145) + . chr(179) + . chr(55) + . chr(70) + . chr(41) + . chr(44) + . chr(176) + . chr(102) + . chr(173) + . chr(163) + . chr(250) + . chr(2) + . chr(103) + . chr(154) + . chr(123) + . chr(61) + . chr(16) + . chr(151) + . chr(240) + . chr(60) + . chr(159) + . chr(210) + . chr(162) + . chr(55) + . chr(127) + . chr(167) + . chr(64) + . chr(30) + . chr(97) + . chr(58) + . chr(163) + . chr(241) + . chr(236) + . chr(218) + . chr(57) + . chr(22) + . chr(8) + . chr(233) + . chr(124) + . chr(180) + . chr(141) + . chr(119) + . chr(182) + . chr(243) + . chr(18) + . chr(51) + . chr(50) + . chr(34) + . chr(201) + . chr(35) + . chr(93) + . chr(106) + . chr(244) + . chr(1) + . chr(161) + . chr(116) + . chr(167) + . chr(224) + . chr(146) + . chr(9) + . chr(28) + . chr(54) + . chr(250) + . chr(10) + . chr(17) + . chr(53) + . chr(32) + . chr(24) + . chr(31) + . chr(155) + . chr(204) + . chr(172) + . chr(20) + . chr(132) + . chr(160) + . chr(38) + . chr(182) + . chr(209) + . chr(72) + . chr(129) + . chr(243) + . chr(164) + . chr(234) + . chr(233) + . chr(164) + . chr(140) + . chr(95) + . chr(77) + . chr(110) + . chr(240) + . chr(86) + . chr(137) + . chr(39) + . chr(81) + . chr(146) + . chr(56) + . chr(134) + . chr(177) + . chr(80) + . chr(164) + . chr(78) + . chr(30) + . chr(81) + . chr(98) + . chr(161) + . chr(241) + . chr(135) + . chr(88) + . chr(196) + . chr(206) + . chr(216) + . chr(185) + . chr(116) + . chr(195) + . chr(163) + . chr(26) + . chr(81) + . chr(3) + . chr(102) + . chr(190) + . chr(243) + . chr(187) + . chr(72) + . chr(28) + . chr(14) + . chr(218) + . chr(83) + . chr(147) + . chr(141) + . chr(163) + . chr(57) + . chr(218) + . chr(192) + . chr(137) + . chr(61) + . chr(98) + . chr(124) + . chr(196) + . chr(186) + . chr(65) + . chr(148) + . chr(147) + . chr(249) + . chr(9) + . chr(88) + . chr(157) + . chr(34) + . chr(168) + . chr(160) + . chr(135) + . chr(103) + . chr(148) + . chr(68) + . chr(175) + . chr(176) + . chr(81) + . chr(138) + . chr(4) + . chr(228) + . chr(25) + . chr(167) + . chr(30) + . chr(242) + . chr(104) + . chr(167) + . chr(49) + . chr(202) + . chr(36) + . chr(244) + . chr(133) + . chr(100) + . chr(138) + . chr(26) + . chr(94) + . chr(146) + . chr(113) + . chr(251) + . chr(180) + . chr(27) + . chr(157) + . chr(61) + . chr(129) + . chr(51) + . chr(128) + . chr(50) + . chr(226) + . chr(209) + . chr(188) + . chr(230) + . chr(182) + . chr(212) + . chr(142) + . chr(212) + . chr(200) + . chr(246) + . chr(124) + . chr(248) + . chr(193) + . chr(159) + . chr(238) + . chr(71) + . chr(4) + . chr(121) + . chr(96) + . chr(98) + . chr(13) + . chr(209) + . chr(95) + . chr(193) + . chr(235) + . chr(251) + . chr(253) + . chr(110) + . chr(47) + . chr(127) + . chr(159) + . chr(18) + . chr(81) + . chr(93) + . chr(247) + . chr(9) + . chr(50) + . chr(135) + . chr(220) + . chr(249) + . chr(126) + . chr(90) + . chr(243) + . chr(64) + . chr(248) + . chr(227) + . chr(135) + . chr(252) + . chr(94) + . chr(231) + . chr(96) + . chr(106) + . chr(186) + . chr(190) + . chr(44) + . chr(166) + . chr(187) + . chr(43) + . chr(21) + . chr(233) + . chr(169) + . chr(180) + . chr(251) + . chr(250) + . chr(18) + . chr(244) + . chr(5) + . chr(68) + . chr(124) + . chr(225) + . chr(63) + . chr(250) + . chr(60) + . chr(52) + . chr(59) + . chr(53) + . chr(24) + . chr(194) + . chr(51) + . chr(117) + . chr(171) + . chr(146) + . chr(223) + . chr(102) + . chr(82) + . chr(12) + . chr(13) + . chr(14) + . chr(54) + . chr(34) + . chr(246) + . chr(223) + . chr(214) + . chr(243) + . chr(218) + . chr(232) + . chr(232) + . chr(222) + . chr(45) + . chr(102) + . chr(192) + . chr(108) + . chr(97) + . chr(252) + . chr(159) + . chr(156) + . chr(50) + . chr(183) + . chr(96) + . chr(101) + . chr(45) + . chr(12) + . chr(246) + . chr(13) + . chr(113) + . chr(73) + . chr(25) + . chr(126) + . chr(87) + . chr(79) + . chr(160) + . chr(78) + . chr(47) + . chr(119) + . chr(67) + . chr(11) + . chr(96) + . chr(45) + . chr(233) + . chr(141) + . chr(146) + . chr(171) + . chr(249) + . chr(242) + . chr(168) + . chr(153) + . chr(143) + . chr(218) + . chr(81) + . chr(238) + . chr(64) + . chr(126) + . chr(250) + . chr(55) + . chr(139) + . chr(109) + . chr(128) + . chr(163) + . chr(234) + . chr(214) + . chr(242) + . chr(139) + . chr(38) + . chr(34) + . chr(4) + . chr(104) + . chr(45) + . chr(100) + . chr(148) + . chr(23) + . chr(241) + . chr(40) + . chr(194) + . chr(235) + . chr(27) + . chr(107) + . chr(133) + . chr(170) + . chr(70) + . chr(214) + . chr(154) + . chr(133) + . chr(86) + . chr(149) + . chr(188) + . chr(224) + . chr(3) + . chr(61) + . chr(133) + . chr(237) + . chr(21) + . chr(121) + . chr(122) + . chr(59) + . chr(154) + . chr(125) + . chr(163) + . chr(199) + . chr(225) + . chr(56) + . chr(222) + . chr(211) + . chr(96) + . chr(161) + . chr(191) + . chr(122) + . chr(13) + . chr(70) + . chr(38) + . chr(82) + . chr(30) + . chr(191) + . chr(215) + . chr(115) + . chr(86) + . chr(148) + . chr(85) + . chr(89) + . chr(209) + . chr(218) + . chr(71) + . chr(230) + . chr(84) + . chr(193) + . chr(34) + . chr(238) + . chr(63) + . chr(196) + . chr(182) + . chr(34) + . chr(252) + . chr(149) + . chr(244) + . chr(93) + . chr(55) + . chr(180) + . chr(215) + . chr(68) + . chr(249) + . chr(252) + . chr(150) + . chr(24) + . chr(189) + . chr(110) + . chr(139) + . chr(21) + . chr(4) + . chr(223) + . chr(109) + . chr(213) + . chr(186) + . chr(180) + . chr(188) + . chr(16) + . chr(118) + . chr(221) + . chr(253) + . chr(181) + . chr(163) + . chr(180) + . chr(214) + . chr(160) + . chr(75) + . chr(203) + . chr(252) + . chr(130) + . chr(129) + . chr(213) + . chr(197) + . chr(124) + . chr(210) + . chr(92) + . chr(148) + . chr(145) + . chr(202) + . chr(32) + . chr(166) + . chr(205) + . chr(1) + . chr(21) + . chr(164) + . chr(187) + . chr(200) + . chr(97) + . chr(202) + . chr(64) + . chr(64) + . chr(200) + . chr(245) + . chr(226) + . chr(126) + . chr(205) + . chr(132) + . chr(201) + . chr(154) + . chr(130) + . chr(76) + . chr(28) + . chr(88) + . chr(18) + . chr(152) + . chr(44) + . chr(110) + . chr(45) + . chr(188) + . chr(57) + . chr(76) + . chr(100) + . chr(8) + . chr(76) + . chr(120) + . chr(172) + . chr(9) + . chr(65) + . chr(14) + . chr(210) + . chr(129) + . chr(78) + . chr(156) + . chr(120) + . chr(50) + . chr(28) + . chr(70) + . chr(181) + . chr(228) + . chr(223) + . chr(56) + . chr(49) + . chr(251) + . chr(143) + . chr(67) + . chr(148) + . chr(187) + . chr(176) + . chr(192) + . chr(120) + . chr(233) + . chr(14) + . chr(219) + . chr(241) + . chr(90) + . chr(85) + . chr(158) + . chr(98) + . chr(150) + . chr(172) + . chr(54) + . chr(24) + . chr(249) + . chr(209) + . chr(143) + . chr(45) + . chr(236) + . chr(213) + . chr(225) + . chr(210) + . chr(182) + . chr(27) + . chr(4) + . chr(179) + . chr(169) + . chr(70) + . chr(72) + . chr(101) + . chr(246) + . chr(10) + . chr(221) + . chr(225) + . chr(24) + . chr(186) + . chr(212) + . chr(113) + . chr(16) + . chr(115) + . chr(211) + . chr(165) + . chr(33) + . chr(10) + . chr(189) + . chr(28) + . chr(219), '6c1033648fc11250ad22006398cd1bdc'], + ]; } /** * @dataProvider getStringDataProvider */ - public function testStrings($code) + public function testStrings(string|array $code): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('PDF417', $code); - $this->assertNotNull($bobj); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('PDF417', $code); + $this->assertNotNull($type); } public static function getStringDataProvider() diff --git a/test/Square/QrCodeTest.php b/test/Square/QrCodeTest.php index 7301837e..3f474e7e 100644 --- a/test/Square/QrCodeTest.php +++ b/test/Square/QrCodeTest.php @@ -32,1666 +32,1613 @@ */ class QrCodeTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testInvalidInput() + public function testInvalidInput(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); - $testObj->getBarcodeObj('QRCODE', ''); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); + $barcode->getBarcodeObj('QRCODE', ''); } - public function testCapacityException() + public function testCapacityException(): void { - $this->bcExpectException('\Com\Tecnick\Barcode\Exception'); - $testObj = $this->getTestObject(); + $this->bcExpectException('\\' . \Com\Tecnick\Barcode\Exception::class); + $barcode = $this->getTestObject(); $code = str_pad('', 4000, 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjBmu7 GM3ZK!qp|)!P1" sRanqC(:Ky'); - $testObj->getBarcodeObj('QRCODE', $code); + $barcode->getBarcodeObj('QRCODE', $code); } /** * @dataProvider getGridDataProvider */ - public function testGetGrid($options, $code, $expected) + public function testGetGrid(string $options, string $code, mixed $expected): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('QRCODE' . $options, $code); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('QRCODE' . $options, $code); + $grid = $type->getGrid(); $this->assertEquals($expected, md5($grid)); } - public static function getGridDataProvider() + public static function getGridDataProvider(): array { - return array( - array('', '0123456789', '89e599523008751db7eef3b5befc37ed'), - array(',L', '0123456789', '89e599523008751db7eef3b5befc37ed'), - array(',H,NM', '0123456789', '3c4ecb6cc99b7843de8d2d3274a43d9e'), - array(',L,8B,0,0', '123aeiouàèìòù', '1622068066c77d3e6ea0a3ad420d105c'), - array(',H,KJ,0,0', 'ぎポ亊', '1d429dd6a1627f6dc1620b3f56862d52'), - array(',H,ST,0,0', 'ABCdef0123', '3a8260f504bca8de8f55a7b3776080bb'), - array('', str_pad('', 350, '0123456789'), '3cca7eb0f61bc39c5a79d7eb3e23a409'), - array('', 'abcdefghijklmnopqrstuvwxyz01234567890123456789', '9c489cd7ded55a82b2d7e3589afbd7d0'), - array(',H,AN,40,1,0,1,2', - 'abcdefghijklmnopqrstuvwxyz01234567890123456789', - '5ba221be81b269ab1f105b07bf49b372' - ), - array( - '', - chr(158) - . chr(19) - . chr(192) - . chr(8) - . chr(71) - . chr(113) - . chr(107) - . chr(252) - . chr(171) - . chr(169) - . chr(114) - . chr(114) - . chr(204) - . chr(151) - . chr(183) - . chr(20) - . chr(180) - . chr(26) - . chr(73) - . chr(76) - . chr(193) - . chr(16) - . chr(69) - . chr(212) - . chr(232) - . chr(90) - . chr(248) - . chr(115) - . chr(9) - . chr(104) - . chr(149) - . chr(167) - . chr(123) - . chr(86) - . chr(175) - . chr(193) - . chr(199) - . chr(27) - . chr(190) - . chr(115) - . chr(196) - . chr(50) - . chr(228) - . chr(146) - . chr(201) - . chr(156) - . chr(165) - . chr(126) - . chr(182) - . chr(237) - . chr(201) - . chr(121) - . chr(253) - . chr(15) - . chr(78) - . chr(231) - . chr(105) - . chr(72) - . chr(92) - . chr(114) - . chr(175) - . chr(240) - . chr(26) - . chr(43) - . chr(71) - . chr(200) - . chr(236) - . chr(15) - . chr(227) - . chr(172) - . chr(129) - . chr(169) - . chr(221) - . chr(103) - . chr(60) - . chr(167) - . chr(5) - . chr(225) - . chr(39) - . chr(186) - . chr(208) - . chr(240) - . chr(52) - . chr(206) - . chr(254) - . chr(130) - . chr(183) - . chr(105) - . chr(201) - . chr(20) - . chr(218) - . chr(122) - . chr(5) - . chr(244) - . chr(165) - . chr(76) - . chr(189) - . chr(146) - . chr(91) - . chr(162) - . chr(63) - . chr(220) - . chr(76) - . chr(30) - . chr(68) - . chr(135) - . chr(196) - . chr(73) - . chr(106) - . chr(235) - . chr(5) - . chr(59) - . chr(220) - . chr(56) - . chr(11) - . chr(220) - . chr(186) - . chr(194) - . chr(70) - . chr(132) - . chr(213) - . chr(34) - . chr(254) - . chr(218) - . chr(23) - . chr(164) - . chr(40) - . chr(212) - . chr(56) - . chr(130) - . chr(119) - . chr(118) - . chr(95) - . chr(194) - . chr(148) - . chr(163) - . chr(75) - . chr(90) - . chr(236) - . chr(180) - . chr(70) - . chr(240) - . chr(239) - . chr(35) - . chr(42) - . chr(250) - . chr(254) - . chr(227) - . chr(189) - . chr(70) - . chr(105) - . chr(148) - . chr(103) - . chr(104) - . chr(112) - . chr(126) - . chr(13) - . chr(151) - . chr(83) - . chr(68) - . chr(27) - . chr(201) - . chr(186) - . chr(121) - . chr(141) - . chr(80) - . chr(30) - . chr(215) - . chr(169) - . chr(12) - . chr(141) - . chr(238) - . chr(251) - . chr(126) - . chr(18) - . chr(39) - . chr(121) - . chr(18) - . chr(12) - . chr(56) - . chr(88) - . chr(116) - . chr(203) - . chr(190) - . chr(220) - . chr(60) - . chr(61) - . chr(233) - . chr(211) - . chr(144) - . chr(47) - . chr(237) - . chr(90) - . chr(232) - . chr(104) - . chr(230) - . chr(57) - . chr(134) - . chr(191) - . chr(226) - . chr(145) - . chr(77) - . chr(209) - . chr(142) - . chr(202) - . chr(227) - . chr(180) - . chr(69) - . chr(245) - . chr(191) - . chr(124) - . chr(78) - . chr(53) - . chr(73) - . chr(13) - . chr(18) - . chr(133) - . chr(74) - . chr(250) - . chr(89) - . chr(217) - . chr(42) - . chr(71) - . chr(53) - . chr(20) - . chr(175) - . chr(29) - . chr(77) - . chr(54) - . chr(219) - . chr(48) - . chr(198) - . chr(41) - . chr(3) - . chr(85) - . chr(243) - . chr(229) - . chr(11) - . chr(57) - . chr(219) - . chr(201) - . chr(180) - . chr(43) - . chr(253) - . chr(252) - . chr(56) - . chr(17) - . chr(131) - . chr(129) - . chr(12) - . chr(219) - . chr(92) - . chr(54) - . chr(36) - . chr(145) - . chr(74) - . chr(210) - . chr(173) - . chr(151) - . chr(9) - . chr(137) - . chr(198) - . chr(207) - . chr(178) - . chr(201) - . chr(38) - . chr(166) - . chr(175) - . chr(48) - . chr(223) - . chr(140) - . chr(249) - . chr(149) - . chr(182) - . chr(248) - . chr(147) - . chr(237) - . chr(10) - . chr(23) - . chr(112) - . chr(22) - . chr(241) - . chr(204) - . chr(76) - . chr(23) - . chr(94) - . chr(150) - . chr(232) - . chr(13) - . chr(46) - . chr(241) - . chr(149) - . chr(243) - . chr(193) - . chr(73) - . chr(190) - . chr(230) - . chr(239) - . chr(110) - . chr(24), - 'd1977c58334ea034ef4201fe95ee4d2b' - ), - array( - '', - chr(158) - . chr(198) - . chr(45) - . chr(94) - . chr(231) - . chr(83) - . chr(60) - . chr(45) - . chr(104) - . chr(62) - . chr(122) - . chr(88) - . chr(245) - . chr(8) - . chr(21) - . chr(76) - . chr(170) - . chr(250) - . chr(87) - . chr(6) - . chr(162) - . chr(32) - . chr(43) - . chr(208) - . chr(17) - . chr(96) - . chr(139) - . chr(43) - . chr(192) - . chr(15) - . chr(57) - . chr(95) - . chr(212) - . chr(102) - . chr(189) - . chr(188) - . chr(184) - . chr(249) - . chr(233) - . chr(34) - . chr(56) - . chr(101) - . chr(122) - . chr(47) - . chr(108) - . chr(142) - . chr(122) - . chr(24) - . chr(137) - . chr(209) - . chr(30) - . chr(45) - . chr(240) - . chr(72) - . chr(253) - . chr(2) - . chr(167) - . chr(138) - . chr(44) - . chr(105) - . chr(152) - . chr(101) - . chr(200) - . chr(109) - . chr(202) - . chr(135) - . chr(43) - . chr(132) - . chr(129) - . chr(21) - . chr(165) - . chr(185) - . chr(121) - . chr(32) - . chr(231) - . chr(229) - . chr(174) - . chr(99) - . chr(252) - . chr(57) - . chr(53) - . chr(27) - . chr(101) - . chr(38) - . chr(99) - . chr(100) - . chr(39) - . chr(12) - . chr(237) - . chr(83) - . chr(116) - . chr(134) - . chr(183) - . chr(62) - . chr(243) - . chr(131) - . chr(196) - . chr(31) - . chr(8) - . chr(70) - . chr(52) - . chr(172) - . chr(254) - . chr(173) - . chr(204) - . chr(231) - . chr(147) - . chr(124) - . chr(75) - . chr(145) - . chr(180) - . chr(128) - . chr(172) - . chr(27) - . chr(165) - . chr(16) - . chr(126) - . chr(204) - . chr(27) - . chr(109) - . chr(33) - . chr(143) - . chr(242) - . chr(216) - . chr(204) - . chr(231) - . chr(92) - . chr(145) - . chr(7) - . chr(99) - . chr(214) - . chr(59) - . chr(17) - . chr(214) - . chr(231) - . chr(221) - . chr(190) - . chr(124) - . chr(90) - . chr(11) - . chr(14) - . chr(16) - . chr(138) - . chr(186) - . chr(43) - . chr(49) - . chr(201) - . chr(168) - . chr(252) - . chr(227) - . chr(22) - . chr(31) - . chr(116) - . chr(10) - . chr(246) - . chr(65) - . chr(240) - . chr(83) - . chr(209) - . chr(247) - . chr(182) - . chr(169) - . chr(52) - . chr(199) - . chr(129) - . chr(29) - . chr(165) - . chr(65) - . chr(152) - . chr(1) - . chr(75) - . chr(166) - . chr(17) - . chr(212) - . chr(97) - . chr(59) - . chr(7) - . chr(44) - . chr(227) - . chr(4) - . chr(17) - . chr(249) - . chr(35) - . chr(132) - . chr(5) - . chr(26) - . chr(196) - . chr(244) - . chr(108) - . chr(151) - . chr(237) - . chr(36) - . chr(66) - . chr(34) - . chr(234) - . chr(194) - . chr(63) - . chr(145) - . chr(4) - . chr(214) - . chr(146) - . chr(79) - . chr(126) - . chr(162) - . chr(36) - . chr(222) - . chr(220) - . chr(42) - . chr(12) - . chr(193) - . chr(46) - . chr(28) - . chr(187) - . chr(80) - . chr(159) - . chr(191) - . chr(106) - . chr(100) - . chr(181) - . chr(213) - . chr(251) - . chr(164) - . chr(249) - . chr(62) - . chr(198) - . chr(228) - . chr(2) - . chr(6) - . chr(119) - . chr(5) - . chr(220) - . chr(10) - . chr(83) - . chr(91) - . chr(171) - . chr(119) - . chr(59) - . chr(137) - . chr(161) - . chr(70) - . chr(75) - . chr(207) - . chr(97) - . chr(8) - . chr(33) - . chr(1) - . chr(198) - . chr(138) - . chr(101) - . chr(125) - . chr(97) - . chr(97) - . chr(34) - . chr(91) - . chr(159) - . chr(231) - . chr(65) - . chr(160) - . chr(237) - . chr(183) - . chr(165) - . chr(202) - . chr(192) - . chr(248) - . chr(38) - . chr(108) - . chr(112) - . chr(96) - . chr(245) - . chr(19) - . chr(166) - . chr(65) - . chr(225) - . chr(8) - . chr(72) - . chr(4) - . chr(9) - . chr(16) - . chr(141) - . chr(109) - . chr(141) - . chr(237) - . chr(206) - . chr(174) - . chr(73) - . chr(111) - . chr(151) - . chr(138) - . chr(16) - . chr(133) - . chr(66) - . chr(180) - . chr(81) - . chr(3) - . chr(173) - . chr(118) - . chr(111) - . chr(31) - . chr(214) - . chr(101) - . chr(49) - . chr(125) - . chr(166) - . chr(20) - . chr(133) - . chr(238) - . chr(23) - . chr(141) - . chr(254) - . chr(163) - . chr(250) - . chr(140) - . chr(146) - . chr(202) - . chr(60) - . chr(219) - . chr(58) - . chr(211) - . chr(102) - . chr(73) - . chr(90) - . chr(167) - . chr(253) - . chr(170) - . chr(170) - . chr(172) - . chr(34) - . chr(27) - . chr(202) - . chr(247) - . chr(128) - . chr(251) - . chr(117) - . chr(39) - . chr(17) - . chr(249) - . chr(23) - . chr(39) - . chr(136) - . chr(22) - . chr(202) - . chr(131) - . chr(162) - . chr(94) - . chr(78) - . chr(222) - . chr(58) - . chr(136) - . chr(178) - . chr(159) - . chr(209) - . chr(14) - . chr(72) - . chr(207) - . chr(183) - . chr(242) - . chr(124) - . chr(217) - . chr(14) - . chr(72) - . chr(209) - . chr(141) - . chr(69) - . chr(72) - . chr(180) - . chr(85) - . chr(67) - . chr(202) - . chr(124) - . chr(202) - . chr(224) - . chr(72) - . chr(79) - . chr(131) - . chr(165) - . chr(157) - . chr(99) - . chr(223) - . chr(38) - . chr(23) - . chr(128) - . chr(246) - . chr(36) - . chr(199) - . chr(199) - . chr(219) - . chr(187) - . chr(69) - . chr(181) - . chr(200) - . chr(140) - . chr(136) - . chr(86) - . chr(208) - . chr(207) - . chr(11) - . chr(39) - . chr(19) - . chr(213) - . chr(162) - . chr(221) - . chr(182) - . chr(233) - . chr(46) - . chr(59) - . chr(144) - . chr(202) - . chr(157) - . chr(112) - . chr(240) - . chr(179) - . chr(240) - . chr(231) - . chr(215) - . chr(185) - . chr(176) - . chr(180) - . chr(117) - . chr(244) - . chr(106) - . chr(62) - . chr(129) - . chr(242) - . chr(148) - . chr(83) - . chr(194) - . chr(159) - . chr(121) - . chr(213) - . chr(117) - . chr(29) - . chr(179) - . chr(44) - . chr(8) - . chr(224) - . chr(103) - . chr(151) - . chr(172) - . chr(5) - . chr(9) - . chr(157) - . chr(184) - . chr(248) - . chr(134) - . chr(145) - . chr(179) - . chr(55) - . chr(70) - . chr(41) - . chr(44) - . chr(176) - . chr(102) - . chr(173) - . chr(163) - . chr(250) - . chr(2) - . chr(103) - . chr(154) - . chr(123) - . chr(61) - . chr(16) - . chr(151) - . chr(240) - . chr(60) - . chr(159) - . chr(210) - . chr(162) - . chr(55) - . chr(127) - . chr(167) - . chr(64) - . chr(30) - . chr(97) - . chr(58) - . chr(163) - . chr(241) - . chr(236) - . chr(218) - . chr(57) - . chr(22) - . chr(8) - . chr(233) - . chr(124) - . chr(180) - . chr(141) - . chr(119) - . chr(182) - . chr(243) - . chr(18) - . chr(51) - . chr(50) - . chr(34) - . chr(201) - . chr(35) - . chr(93) - . chr(106) - . chr(244) - . chr(1) - . chr(161) - . chr(116) - . chr(167) - . chr(224) - . chr(146) - . chr(9) - . chr(28) - . chr(54) - . chr(250) - . chr(10) - . chr(17) - . chr(53) - . chr(32) - . chr(24) - . chr(31) - . chr(155) - . chr(204) - . chr(172) - . chr(20) - . chr(132) - . chr(160) - . chr(38) - . chr(182) - . chr(209) - . chr(72) - . chr(129) - . chr(243) - . chr(164) - . chr(234) - . chr(233) - . chr(164) - . chr(140) - . chr(95) - . chr(77) - . chr(110) - . chr(240) - . chr(86) - . chr(137) - . chr(39) - . chr(81) - . chr(146) - . chr(56) - . chr(134) - . chr(177) - . chr(80) - . chr(164) - . chr(78) - . chr(30) - . chr(81) - . chr(98) - . chr(161) - . chr(241) - . chr(135) - . chr(88) - . chr(196) - . chr(206) - . chr(216) - . chr(185) - . chr(116) - . chr(195) - . chr(163) - . chr(26) - . chr(81) - . chr(3) - . chr(102) - . chr(190) - . chr(243) - . chr(187) - . chr(72) - . chr(28) - . chr(14) - . chr(218) - . chr(83) - . chr(147) - . chr(141) - . chr(163) - . chr(57) - . chr(218) - . chr(192) - . chr(137) - . chr(61) - . chr(98) - . chr(124) - . chr(196) - . chr(186) - . chr(65) - . chr(148) - . chr(147) - . chr(249) - . chr(9) - . chr(88) - . chr(157) - . chr(34) - . chr(168) - . chr(160) - . chr(135) - . chr(103) - . chr(148) - . chr(68) - . chr(175) - . chr(176) - . chr(81) - . chr(138) - . chr(4) - . chr(228) - . chr(25) - . chr(167) - . chr(30) - . chr(242) - . chr(104) - . chr(167) - . chr(49) - . chr(202) - . chr(36) - . chr(244) - . chr(133) - . chr(100) - . chr(138) - . chr(26) - . chr(94) - . chr(146) - . chr(113) - . chr(251) - . chr(180) - . chr(27) - . chr(157) - . chr(61) - . chr(129) - . chr(51) - . chr(128) - . chr(50) - . chr(226) - . chr(209) - . chr(188) - . chr(230) - . chr(182) - . chr(212) - . chr(142) - . chr(212) - . chr(200) - . chr(246) - . chr(124) - . chr(248) - . chr(193) - . chr(159) - . chr(238) - . chr(71) - . chr(4) - . chr(121) - . chr(96) - . chr(98) - . chr(13) - . chr(209) - . chr(95) - . chr(193) - . chr(235) - . chr(251) - . chr(253) - . chr(110) - . chr(47) - . chr(127) - . chr(159) - . chr(18) - . chr(81) - . chr(93) - . chr(247) - . chr(9) - . chr(50) - . chr(135) - . chr(220) - . chr(249) - . chr(126) - . chr(90) - . chr(243) - . chr(64) - . chr(248) - . chr(227) - . chr(135) - . chr(252) - . chr(94) - . chr(231) - . chr(96) - . chr(106) - . chr(186) - . chr(190) - . chr(44) - . chr(166) - . chr(187) - . chr(43) - . chr(21) - . chr(233) - . chr(169) - . chr(180) - . chr(251) - . chr(250) - . chr(18) - . chr(244) - . chr(5) - . chr(68) - . chr(124) - . chr(225) - . chr(63) - . chr(250) - . chr(60) - . chr(52) - . chr(59) - . chr(53) - . chr(24) - . chr(194) - . chr(51) - . chr(117) - . chr(171) - . chr(146) - . chr(223) - . chr(102) - . chr(82) - . chr(12) - . chr(13) - . chr(14) - . chr(54) - . chr(34) - . chr(246) - . chr(223) - . chr(214) - . chr(243) - . chr(218) - . chr(232) - . chr(232) - . chr(222) - . chr(45) - . chr(102) - . chr(192) - . chr(108) - . chr(97) - . chr(252) - . chr(159) - . chr(156) - . chr(50) - . chr(183) - . chr(96) - . chr(101) - . chr(45) - . chr(12) - . chr(246) - . chr(13) - . chr(113) - . chr(73) - . chr(25) - . chr(126) - . chr(87) - . chr(79) - . chr(160) - . chr(78) - . chr(47) - . chr(119) - . chr(67) - . chr(11) - . chr(96) - . chr(45) - . chr(233) - . chr(141) - . chr(146) - . chr(171) - . chr(249) - . chr(242) - . chr(168) - . chr(153) - . chr(143) - . chr(218) - . chr(81) - . chr(238) - . chr(64) - . chr(126) - . chr(250) - . chr(55) - . chr(139) - . chr(109) - . chr(128) - . chr(163) - . chr(234) - . chr(214) - . chr(242) - . chr(139) - . chr(38) - . chr(34) - . chr(4) - . chr(104) - . chr(45) - . chr(100) - . chr(148) - . chr(23) - . chr(241) - . chr(40) - . chr(194) - . chr(235) - . chr(27) - . chr(107) - . chr(133) - . chr(170) - . chr(70) - . chr(214) - . chr(154) - . chr(133) - . chr(86) - . chr(149) - . chr(188) - . chr(224) - . chr(3) - . chr(61) - . chr(133) - . chr(237) - . chr(21) - . chr(121) - . chr(122) - . chr(59) - . chr(154) - . chr(125) - . chr(163) - . chr(199) - . chr(225) - . chr(56) - . chr(222) - . chr(211) - . chr(96) - . chr(161) - . chr(191) - . chr(122) - . chr(13) - . chr(70) - . chr(38) - . chr(82) - . chr(30) - . chr(191) - . chr(215) - . chr(115) - . chr(86) - . chr(148) - . chr(85) - . chr(89) - . chr(209) - . chr(218) - . chr(71) - . chr(230) - . chr(84) - . chr(193) - . chr(34) - . chr(238) - . chr(63) - . chr(196) - . chr(182) - . chr(34) - . chr(252) - . chr(149) - . chr(244) - . chr(93) - . chr(55) - . chr(180) - . chr(215) - . chr(68) - . chr(249) - . chr(252) - . chr(150) - . chr(24) - . chr(189) - . chr(110) - . chr(139) - . chr(21) - . chr(4) - . chr(223) - . chr(109) - . chr(213) - . chr(186) - . chr(180) - . chr(188) - . chr(16) - . chr(118) - . chr(221) - . chr(253) - . chr(181) - . chr(163) - . chr(180) - . chr(214) - . chr(160) - . chr(75) - . chr(203) - . chr(252) - . chr(130) - . chr(129) - . chr(213) - . chr(197) - . chr(124) - . chr(210) - . chr(92) - . chr(148) - . chr(145) - . chr(202) - . chr(32) - . chr(166) - . chr(205) - . chr(1) - . chr(21) - . chr(164) - . chr(187) - . chr(200) - . chr(97) - . chr(202) - . chr(64) - . chr(64) - . chr(200) - . chr(245) - . chr(226) - . chr(126) - . chr(205) - . chr(132) - . chr(201) - . chr(154) - . chr(130) - . chr(76) - . chr(28) - . chr(88) - . chr(18) - . chr(152) - . chr(44) - . chr(110) - . chr(45) - . chr(188) - . chr(57) - . chr(76) - . chr(100) - . chr(8) - . chr(76) - . chr(120) - . chr(172) - . chr(9) - . chr(65) - . chr(14) - . chr(210) - . chr(129) - . chr(78) - . chr(156) - . chr(120) - . chr(50) - . chr(28) - . chr(70) - . chr(181) - . chr(228) - . chr(223) - . chr(56) - . chr(49) - . chr(251) - . chr(143) - . chr(67) - . chr(148) - . chr(187) - . chr(176) - . chr(192) - . chr(120) - . chr(233) - . chr(14) - . chr(219) - . chr(241) - . chr(90) - . chr(85) - . chr(158) - . chr(98) - . chr(150) - . chr(172) - . chr(54) - . chr(24) - . chr(249) - . chr(209) - . chr(143) - . chr(45) - . chr(236) - . chr(213) - . chr(225) - . chr(210) - . chr(182) - . chr(27) - . chr(4) - . chr(179) - . chr(169) - . chr(70) - . chr(72) - . chr(101) - . chr(246) - . chr(10) - . chr(221) - . chr(225) - . chr(24) - . chr(186) - . chr(212) - . chr(113) - . chr(16) - . chr(115) - . chr(211) - . chr(165) - . chr(33) - . chr(10) - . chr(189) - . chr(28) - . chr(219), - 'f4bf6b42c6964562a3a91e054fc8ec51' - ), - array( - ',H,NM', - chr(26) - . chr(151) - . chr(224) - . chr(193) - . chr(71) - . chr(32) - . chr(162) - . chr(191) - . chr(30) - . chr(98) - . chr(82) - . chr(13) - . chr(153) - . chr(145) - . chr(69) - . chr(3) - . chr(123) - . chr(227) - . chr(50) - . chr(200) - . chr(24) - . chr(234) - . chr(128) - . chr(81) - . chr(232) - . chr(112) - . chr(147) - . chr(45) - . chr(25) - . chr(8) - . chr(38) - . chr(51) - . chr(158) - . chr(7) - . chr(243) - . chr(229) - . chr(39) - . chr(150) - . chr(165) - . chr(69) - . chr(247) - . chr(246) - . chr(81) - . chr(146) - . chr(137) - . chr(149) - . chr(148) - . chr(6) - . chr(122) - . chr(197), - '4f6fd3799489b48fa07e1a7aef0561fc' - ), - array( - ',H,AN', - chr(205) - . chr(146) - . chr(176) - . chr(79) - . chr(226) - . chr(154) - . chr(191) - . chr(118) - . chr(198) - . chr(215) - . chr(126) - . chr(236) - . chr(12) - . chr(29) - . chr(243) - . chr(254) - . chr(4) - . chr(27) - . chr(150) - . chr(168) - . chr(96) - . chr(142) - . chr(160) - . chr(176) - . chr(34) - . chr(42) - . chr(71) - . chr(182) - . chr(48) - . chr(192) - . chr(125) - . chr(252) - . chr(84) - . chr(46) - . chr(77) - . chr(55) - . chr(200) - . chr(13) - . chr(173) - . chr(144) - . chr(227) - . chr(44) - . chr(125) - . chr(238) - . chr(73) - . chr(113) - . chr(238) - . chr(76) - . chr(140) - . chr(133), - '55cd590ed76d12591c6df3b673904530' - ), - array( - ',H,KJ', - chr(244) - . chr(235) - . chr(21) - . chr(149) - . chr(157) - . chr(54) - . chr(191) - . chr(227) - . chr(235) - . chr(238) - . chr(165) - . chr(105) - . chr(236) - . chr(248) - . chr(151) - . chr(58) - . chr(49) - . chr(97) - . chr(70) - . chr(221) - . chr(240) - . chr(43) - . chr(11) - . chr(111) - . chr(27) - . chr(83) - . chr(223) - . chr(10) - . chr(159) - . chr(109) - . chr(142) - . chr(148) - . chr(89) - . chr(163) - . chr(42) - . chr(246) - . chr(216) - . chr(233) - . chr(218) - . chr(197) - . chr(216) - . chr(129) - . chr(48) - . chr(197) - . chr(122) - . chr(199) - . chr(1) - . chr(170) - . chr(41) - . chr(70), - '92e82c296965d97d35ab7168ece11dd0' - ), - array( - ',H,8B', - chr(137) - . chr(27) - . chr(112) - . chr(147) - . chr(137) - . chr(138) - . chr(230) - . chr(106) - . chr(148) - . chr(134) - . chr(214) - . chr(36) - . chr(27) - . chr(49) - . chr(198) - . chr(69) - . chr(40) - . chr(160) - . chr(47) - . chr(4) - . chr(103) - . chr(9) - . chr(133) - . chr(150) - . chr(206) - . chr(254) - . chr(95) - . chr(206) - . chr(170) - . chr(136) - . chr(22) - . chr(53) - . chr(162) - . chr(134) - . chr(199) - . chr(45) - . chr(18) - . chr(174) - . chr(150) - . chr(165) - . chr(54) - . chr(109) - . chr(201) - . chr(81) - . chr(158) - . chr(144) - . chr(150) - . chr(198) - . chr(50) - . chr(196), - '68799fdb9685b5e2f258245833006425' - ), - array( - ',H,ST', - chr(201) - . chr(152) - . chr(205) - . chr(79) - . chr(47) - . chr(157) - . chr(79) - . chr(142) - . chr(108) - . chr(249) - . chr(23) - . chr(130) - . chr(47) - . chr(185) - . chr(9) - . chr(246) - . chr(229) - . chr(26) - . chr(166) - . chr(124) - . chr(191) - . chr(219) - . chr(233) - . chr(137) - . chr(45) - . chr(137) - . chr(27) - . chr(194) - . chr(80) - . chr(76) - . chr(136) - . chr(27) - . chr(227) - . chr(87) - . chr(106) - . chr(20) - . chr(243) - . chr(184) - . chr(161) - . chr(97) - . chr(179) - . chr(184) - . chr(226) - . chr(226) - . chr(114) - . chr(235) - . chr(217) - . chr(88) - . chr(6) - . chr(129), - '6fb328c418ea40c6c94277f420ba9357' - ), - array( - '', - 'w(fa`nC]e=}OY(K^ 3xN1Vz1gkKnFS;&TN $`W~r?;9\\l?]5MF@<~oh>\\4-#hH*=w*AYaAL!]f^J&<`Tc!' - . 'pcpZ"Nn0RWY\\uQf8+HZXJ8?*bFGDz+Eln7Gqe6"8n[te.\\}:&YrQq3[UY#yU.@B}Xio>!rWoNMV]*Uw0/kb!~>WYAR0PrROK' - . '=?j>3B/boe@z;8,K$nM$-%]OWm KAOv^oa}#%-ets&p/?|[Dk)Hy.\'IfuI27y*viktmq#Tfv[X\'zUb?Bkh=zofbe1t|+~tuk' - . 'id]l9Edt}kpTO0wSr^PK|T2SZ:[Jb0UX!I8}Grc^>L)jzG>n\'n:%DMX g5KKF!$GJ=Er0*QOVZ:R#YA+H\\0m*inr :>G;Cof`5Yq@,Avg\\J' - . 'j6lv_J(MUqv>?03:!+8ig9`\\-PZW\'D%Qz^wEC,z3JrQj#d&$p>nYXP6f!p' - . '?)5EZ1$RWH_S[+F-vIr|Nc<==tmT\\oF{x\\ASnF\'FnfyKr@YijLg91$VOyD%V4KS-(tav;h>+P8VCY0.D]u^nz6?tZDLoo }' - . 'xt_p1I0=zIs?#%MHbD(R?>q4y7ai(ah"WIrir$\'nM{.P![yd "7@@*T:A7%IxmKP7?:+CAyp>)B?e<$e><\'_F\\yhs~2ll^>' - . '%~X1Bz+494VYys^`2zhrBEl+9l>&Y}D_|}p@y|T32,m- Ln3HW&j|sv6`6=;5bz2alS[i(o{5]*6*xIRPP>NE6d&L#Abe=tG+H' - . '$tQsqgQ{}\\tH0FyNt?eZE2]gtD&jl14p\'fdxO7uMskv$2pS(19bWLA@BeF-RXBD_*)YY@O\'5;~9NolV!\':YS[yuA@$tyF9' - . 'YPC3*cc2y~13N"!%$(@][{WR>xV4r|MMNp`YUDkPD|cr~ex#m9`J69}T2Th&R7S")4[_YG0~EtqDZkHI&*tw+T.8r!mk4j"CEn9+S!Qn]\'Ohu%y0`9)lm7' - . '%a9sMN^Oq$?,0r.ablh2U_8PoxixeX1k;K_hy>9lBXxRL\'5/s~BJ^Z{OSfI:?[&[\'eD!$^mG8gzen1uc08/or+@Fria2FgnM' - . 'N3NRr=z+%uqt\'gY8 h(rtI:g4{zZdi(3}Wfpta|zXoo`WIxX3"L)Kgp_cl:IVB\\UyCGo&Ej^5[?m&8F::rCfZ4F?"`hX$F/~' - . 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjBmu7 GM3ZK!qp|)!P1" sRanqC(:Ky&mh{&hDS|~ }qqzzrL,u' - . 'L!H/o:RwU}r[l\\XrE|FB{FAm9=i-iv#7wKFgfx`RM883KI~dMkt}L9 ]uN[,@:6/[",:jKl8c%L/OKs}7i{c#{BxK}%' - . 'k9(0*S}C7#oGS;TW2x8z]!sK=k]rf', - '83747986cf0df320b915587609232076' - ), - ); + return [['', '0123456789', '89e599523008751db7eef3b5befc37ed'], [',L', '0123456789', '89e599523008751db7eef3b5befc37ed'], [',H,NM', '0123456789', '3c4ecb6cc99b7843de8d2d3274a43d9e'], [',L,8B,0,0', '123aeiouàèìòù', '1622068066c77d3e6ea0a3ad420d105c'], [',H,KJ,0,0', 'ぎポ亊', '1d429dd6a1627f6dc1620b3f56862d52'], [',H,ST,0,0', 'ABCdef0123', '3a8260f504bca8de8f55a7b3776080bb'], ['', str_pad('', 350, '0123456789'), '3cca7eb0f61bc39c5a79d7eb3e23a409'], ['', 'abcdefghijklmnopqrstuvwxyz01234567890123456789', '9c489cd7ded55a82b2d7e3589afbd7d0'], [',H,AN,40,1,0,1,2', 'abcdefghijklmnopqrstuvwxyz01234567890123456789', '5ba221be81b269ab1f105b07bf49b372'], ['', chr(158) + . chr(19) + . chr(192) + . chr(8) + . chr(71) + . chr(113) + . chr(107) + . chr(252) + . chr(171) + . chr(169) + . chr(114) + . chr(114) + . chr(204) + . chr(151) + . chr(183) + . chr(20) + . chr(180) + . chr(26) + . chr(73) + . chr(76) + . chr(193) + . chr(16) + . chr(69) + . chr(212) + . chr(232) + . chr(90) + . chr(248) + . chr(115) + . chr(9) + . chr(104) + . chr(149) + . chr(167) + . chr(123) + . chr(86) + . chr(175) + . chr(193) + . chr(199) + . chr(27) + . chr(190) + . chr(115) + . chr(196) + . chr(50) + . chr(228) + . chr(146) + . chr(201) + . chr(156) + . chr(165) + . chr(126) + . chr(182) + . chr(237) + . chr(201) + . chr(121) + . chr(253) + . chr(15) + . chr(78) + . chr(231) + . chr(105) + . chr(72) + . chr(92) + . chr(114) + . chr(175) + . chr(240) + . chr(26) + . chr(43) + . chr(71) + . chr(200) + . chr(236) + . chr(15) + . chr(227) + . chr(172) + . chr(129) + . chr(169) + . chr(221) + . chr(103) + . chr(60) + . chr(167) + . chr(5) + . chr(225) + . chr(39) + . chr(186) + . chr(208) + . chr(240) + . chr(52) + . chr(206) + . chr(254) + . chr(130) + . chr(183) + . chr(105) + . chr(201) + . chr(20) + . chr(218) + . chr(122) + . chr(5) + . chr(244) + . chr(165) + . chr(76) + . chr(189) + . chr(146) + . chr(91) + . chr(162) + . chr(63) + . chr(220) + . chr(76) + . chr(30) + . chr(68) + . chr(135) + . chr(196) + . chr(73) + . chr(106) + . chr(235) + . chr(5) + . chr(59) + . chr(220) + . chr(56) + . chr(11) + . chr(220) + . chr(186) + . chr(194) + . chr(70) + . chr(132) + . chr(213) + . chr(34) + . chr(254) + . chr(218) + . chr(23) + . chr(164) + . chr(40) + . chr(212) + . chr(56) + . chr(130) + . chr(119) + . chr(118) + . chr(95) + . chr(194) + . chr(148) + . chr(163) + . chr(75) + . chr(90) + . chr(236) + . chr(180) + . chr(70) + . chr(240) + . chr(239) + . chr(35) + . chr(42) + . chr(250) + . chr(254) + . chr(227) + . chr(189) + . chr(70) + . chr(105) + . chr(148) + . chr(103) + . chr(104) + . chr(112) + . chr(126) + . chr(13) + . chr(151) + . chr(83) + . chr(68) + . chr(27) + . chr(201) + . chr(186) + . chr(121) + . chr(141) + . chr(80) + . chr(30) + . chr(215) + . chr(169) + . chr(12) + . chr(141) + . chr(238) + . chr(251) + . chr(126) + . chr(18) + . chr(39) + . chr(121) + . chr(18) + . chr(12) + . chr(56) + . chr(88) + . chr(116) + . chr(203) + . chr(190) + . chr(220) + . chr(60) + . chr(61) + . chr(233) + . chr(211) + . chr(144) + . chr(47) + . chr(237) + . chr(90) + . chr(232) + . chr(104) + . chr(230) + . chr(57) + . chr(134) + . chr(191) + . chr(226) + . chr(145) + . chr(77) + . chr(209) + . chr(142) + . chr(202) + . chr(227) + . chr(180) + . chr(69) + . chr(245) + . chr(191) + . chr(124) + . chr(78) + . chr(53) + . chr(73) + . chr(13) + . chr(18) + . chr(133) + . chr(74) + . chr(250) + . chr(89) + . chr(217) + . chr(42) + . chr(71) + . chr(53) + . chr(20) + . chr(175) + . chr(29) + . chr(77) + . chr(54) + . chr(219) + . chr(48) + . chr(198) + . chr(41) + . chr(3) + . chr(85) + . chr(243) + . chr(229) + . chr(11) + . chr(57) + . chr(219) + . chr(201) + . chr(180) + . chr(43) + . chr(253) + . chr(252) + . chr(56) + . chr(17) + . chr(131) + . chr(129) + . chr(12) + . chr(219) + . chr(92) + . chr(54) + . chr(36) + . chr(145) + . chr(74) + . chr(210) + . chr(173) + . chr(151) + . chr(9) + . chr(137) + . chr(198) + . chr(207) + . chr(178) + . chr(201) + . chr(38) + . chr(166) + . chr(175) + . chr(48) + . chr(223) + . chr(140) + . chr(249) + . chr(149) + . chr(182) + . chr(248) + . chr(147) + . chr(237) + . chr(10) + . chr(23) + . chr(112) + . chr(22) + . chr(241) + . chr(204) + . chr(76) + . chr(23) + . chr(94) + . chr(150) + . chr(232) + . chr(13) + . chr(46) + . chr(241) + . chr(149) + . chr(243) + . chr(193) + . chr(73) + . chr(190) + . chr(230) + . chr(239) + . chr(110) + . chr(24), 'd1977c58334ea034ef4201fe95ee4d2b'], ['', chr(158) + . chr(198) + . chr(45) + . chr(94) + . chr(231) + . chr(83) + . chr(60) + . chr(45) + . chr(104) + . chr(62) + . chr(122) + . chr(88) + . chr(245) + . chr(8) + . chr(21) + . chr(76) + . chr(170) + . chr(250) + . chr(87) + . chr(6) + . chr(162) + . chr(32) + . chr(43) + . chr(208) + . chr(17) + . chr(96) + . chr(139) + . chr(43) + . chr(192) + . chr(15) + . chr(57) + . chr(95) + . chr(212) + . chr(102) + . chr(189) + . chr(188) + . chr(184) + . chr(249) + . chr(233) + . chr(34) + . chr(56) + . chr(101) + . chr(122) + . chr(47) + . chr(108) + . chr(142) + . chr(122) + . chr(24) + . chr(137) + . chr(209) + . chr(30) + . chr(45) + . chr(240) + . chr(72) + . chr(253) + . chr(2) + . chr(167) + . chr(138) + . chr(44) + . chr(105) + . chr(152) + . chr(101) + . chr(200) + . chr(109) + . chr(202) + . chr(135) + . chr(43) + . chr(132) + . chr(129) + . chr(21) + . chr(165) + . chr(185) + . chr(121) + . chr(32) + . chr(231) + . chr(229) + . chr(174) + . chr(99) + . chr(252) + . chr(57) + . chr(53) + . chr(27) + . chr(101) + . chr(38) + . chr(99) + . chr(100) + . chr(39) + . chr(12) + . chr(237) + . chr(83) + . chr(116) + . chr(134) + . chr(183) + . chr(62) + . chr(243) + . chr(131) + . chr(196) + . chr(31) + . chr(8) + . chr(70) + . chr(52) + . chr(172) + . chr(254) + . chr(173) + . chr(204) + . chr(231) + . chr(147) + . chr(124) + . chr(75) + . chr(145) + . chr(180) + . chr(128) + . chr(172) + . chr(27) + . chr(165) + . chr(16) + . chr(126) + . chr(204) + . chr(27) + . chr(109) + . chr(33) + . chr(143) + . chr(242) + . chr(216) + . chr(204) + . chr(231) + . chr(92) + . chr(145) + . chr(7) + . chr(99) + . chr(214) + . chr(59) + . chr(17) + . chr(214) + . chr(231) + . chr(221) + . chr(190) + . chr(124) + . chr(90) + . chr(11) + . chr(14) + . chr(16) + . chr(138) + . chr(186) + . chr(43) + . chr(49) + . chr(201) + . chr(168) + . chr(252) + . chr(227) + . chr(22) + . chr(31) + . chr(116) + . chr(10) + . chr(246) + . chr(65) + . chr(240) + . chr(83) + . chr(209) + . chr(247) + . chr(182) + . chr(169) + . chr(52) + . chr(199) + . chr(129) + . chr(29) + . chr(165) + . chr(65) + . chr(152) + . chr(1) + . chr(75) + . chr(166) + . chr(17) + . chr(212) + . chr(97) + . chr(59) + . chr(7) + . chr(44) + . chr(227) + . chr(4) + . chr(17) + . chr(249) + . chr(35) + . chr(132) + . chr(5) + . chr(26) + . chr(196) + . chr(244) + . chr(108) + . chr(151) + . chr(237) + . chr(36) + . chr(66) + . chr(34) + . chr(234) + . chr(194) + . chr(63) + . chr(145) + . chr(4) + . chr(214) + . chr(146) + . chr(79) + . chr(126) + . chr(162) + . chr(36) + . chr(222) + . chr(220) + . chr(42) + . chr(12) + . chr(193) + . chr(46) + . chr(28) + . chr(187) + . chr(80) + . chr(159) + . chr(191) + . chr(106) + . chr(100) + . chr(181) + . chr(213) + . chr(251) + . chr(164) + . chr(249) + . chr(62) + . chr(198) + . chr(228) + . chr(2) + . chr(6) + . chr(119) + . chr(5) + . chr(220) + . chr(10) + . chr(83) + . chr(91) + . chr(171) + . chr(119) + . chr(59) + . chr(137) + . chr(161) + . chr(70) + . chr(75) + . chr(207) + . chr(97) + . chr(8) + . chr(33) + . chr(1) + . chr(198) + . chr(138) + . chr(101) + . chr(125) + . chr(97) + . chr(97) + . chr(34) + . chr(91) + . chr(159) + . chr(231) + . chr(65) + . chr(160) + . chr(237) + . chr(183) + . chr(165) + . chr(202) + . chr(192) + . chr(248) + . chr(38) + . chr(108) + . chr(112) + . chr(96) + . chr(245) + . chr(19) + . chr(166) + . chr(65) + . chr(225) + . chr(8) + . chr(72) + . chr(4) + . chr(9) + . chr(16) + . chr(141) + . chr(109) + . chr(141) + . chr(237) + . chr(206) + . chr(174) + . chr(73) + . chr(111) + . chr(151) + . chr(138) + . chr(16) + . chr(133) + . chr(66) + . chr(180) + . chr(81) + . chr(3) + . chr(173) + . chr(118) + . chr(111) + . chr(31) + . chr(214) + . chr(101) + . chr(49) + . chr(125) + . chr(166) + . chr(20) + . chr(133) + . chr(238) + . chr(23) + . chr(141) + . chr(254) + . chr(163) + . chr(250) + . chr(140) + . chr(146) + . chr(202) + . chr(60) + . chr(219) + . chr(58) + . chr(211) + . chr(102) + . chr(73) + . chr(90) + . chr(167) + . chr(253) + . chr(170) + . chr(170) + . chr(172) + . chr(34) + . chr(27) + . chr(202) + . chr(247) + . chr(128) + . chr(251) + . chr(117) + . chr(39) + . chr(17) + . chr(249) + . chr(23) + . chr(39) + . chr(136) + . chr(22) + . chr(202) + . chr(131) + . chr(162) + . chr(94) + . chr(78) + . chr(222) + . chr(58) + . chr(136) + . chr(178) + . chr(159) + . chr(209) + . chr(14) + . chr(72) + . chr(207) + . chr(183) + . chr(242) + . chr(124) + . chr(217) + . chr(14) + . chr(72) + . chr(209) + . chr(141) + . chr(69) + . chr(72) + . chr(180) + . chr(85) + . chr(67) + . chr(202) + . chr(124) + . chr(202) + . chr(224) + . chr(72) + . chr(79) + . chr(131) + . chr(165) + . chr(157) + . chr(99) + . chr(223) + . chr(38) + . chr(23) + . chr(128) + . chr(246) + . chr(36) + . chr(199) + . chr(199) + . chr(219) + . chr(187) + . chr(69) + . chr(181) + . chr(200) + . chr(140) + . chr(136) + . chr(86) + . chr(208) + . chr(207) + . chr(11) + . chr(39) + . chr(19) + . chr(213) + . chr(162) + . chr(221) + . chr(182) + . chr(233) + . chr(46) + . chr(59) + . chr(144) + . chr(202) + . chr(157) + . chr(112) + . chr(240) + . chr(179) + . chr(240) + . chr(231) + . chr(215) + . chr(185) + . chr(176) + . chr(180) + . chr(117) + . chr(244) + . chr(106) + . chr(62) + . chr(129) + . chr(242) + . chr(148) + . chr(83) + . chr(194) + . chr(159) + . chr(121) + . chr(213) + . chr(117) + . chr(29) + . chr(179) + . chr(44) + . chr(8) + . chr(224) + . chr(103) + . chr(151) + . chr(172) + . chr(5) + . chr(9) + . chr(157) + . chr(184) + . chr(248) + . chr(134) + . chr(145) + . chr(179) + . chr(55) + . chr(70) + . chr(41) + . chr(44) + . chr(176) + . chr(102) + . chr(173) + . chr(163) + . chr(250) + . chr(2) + . chr(103) + . chr(154) + . chr(123) + . chr(61) + . chr(16) + . chr(151) + . chr(240) + . chr(60) + . chr(159) + . chr(210) + . chr(162) + . chr(55) + . chr(127) + . chr(167) + . chr(64) + . chr(30) + . chr(97) + . chr(58) + . chr(163) + . chr(241) + . chr(236) + . chr(218) + . chr(57) + . chr(22) + . chr(8) + . chr(233) + . chr(124) + . chr(180) + . chr(141) + . chr(119) + . chr(182) + . chr(243) + . chr(18) + . chr(51) + . chr(50) + . chr(34) + . chr(201) + . chr(35) + . chr(93) + . chr(106) + . chr(244) + . chr(1) + . chr(161) + . chr(116) + . chr(167) + . chr(224) + . chr(146) + . chr(9) + . chr(28) + . chr(54) + . chr(250) + . chr(10) + . chr(17) + . chr(53) + . chr(32) + . chr(24) + . chr(31) + . chr(155) + . chr(204) + . chr(172) + . chr(20) + . chr(132) + . chr(160) + . chr(38) + . chr(182) + . chr(209) + . chr(72) + . chr(129) + . chr(243) + . chr(164) + . chr(234) + . chr(233) + . chr(164) + . chr(140) + . chr(95) + . chr(77) + . chr(110) + . chr(240) + . chr(86) + . chr(137) + . chr(39) + . chr(81) + . chr(146) + . chr(56) + . chr(134) + . chr(177) + . chr(80) + . chr(164) + . chr(78) + . chr(30) + . chr(81) + . chr(98) + . chr(161) + . chr(241) + . chr(135) + . chr(88) + . chr(196) + . chr(206) + . chr(216) + . chr(185) + . chr(116) + . chr(195) + . chr(163) + . chr(26) + . chr(81) + . chr(3) + . chr(102) + . chr(190) + . chr(243) + . chr(187) + . chr(72) + . chr(28) + . chr(14) + . chr(218) + . chr(83) + . chr(147) + . chr(141) + . chr(163) + . chr(57) + . chr(218) + . chr(192) + . chr(137) + . chr(61) + . chr(98) + . chr(124) + . chr(196) + . chr(186) + . chr(65) + . chr(148) + . chr(147) + . chr(249) + . chr(9) + . chr(88) + . chr(157) + . chr(34) + . chr(168) + . chr(160) + . chr(135) + . chr(103) + . chr(148) + . chr(68) + . chr(175) + . chr(176) + . chr(81) + . chr(138) + . chr(4) + . chr(228) + . chr(25) + . chr(167) + . chr(30) + . chr(242) + . chr(104) + . chr(167) + . chr(49) + . chr(202) + . chr(36) + . chr(244) + . chr(133) + . chr(100) + . chr(138) + . chr(26) + . chr(94) + . chr(146) + . chr(113) + . chr(251) + . chr(180) + . chr(27) + . chr(157) + . chr(61) + . chr(129) + . chr(51) + . chr(128) + . chr(50) + . chr(226) + . chr(209) + . chr(188) + . chr(230) + . chr(182) + . chr(212) + . chr(142) + . chr(212) + . chr(200) + . chr(246) + . chr(124) + . chr(248) + . chr(193) + . chr(159) + . chr(238) + . chr(71) + . chr(4) + . chr(121) + . chr(96) + . chr(98) + . chr(13) + . chr(209) + . chr(95) + . chr(193) + . chr(235) + . chr(251) + . chr(253) + . chr(110) + . chr(47) + . chr(127) + . chr(159) + . chr(18) + . chr(81) + . chr(93) + . chr(247) + . chr(9) + . chr(50) + . chr(135) + . chr(220) + . chr(249) + . chr(126) + . chr(90) + . chr(243) + . chr(64) + . chr(248) + . chr(227) + . chr(135) + . chr(252) + . chr(94) + . chr(231) + . chr(96) + . chr(106) + . chr(186) + . chr(190) + . chr(44) + . chr(166) + . chr(187) + . chr(43) + . chr(21) + . chr(233) + . chr(169) + . chr(180) + . chr(251) + . chr(250) + . chr(18) + . chr(244) + . chr(5) + . chr(68) + . chr(124) + . chr(225) + . chr(63) + . chr(250) + . chr(60) + . chr(52) + . chr(59) + . chr(53) + . chr(24) + . chr(194) + . chr(51) + . chr(117) + . chr(171) + . chr(146) + . chr(223) + . chr(102) + . chr(82) + . chr(12) + . chr(13) + . chr(14) + . chr(54) + . chr(34) + . chr(246) + . chr(223) + . chr(214) + . chr(243) + . chr(218) + . chr(232) + . chr(232) + . chr(222) + . chr(45) + . chr(102) + . chr(192) + . chr(108) + . chr(97) + . chr(252) + . chr(159) + . chr(156) + . chr(50) + . chr(183) + . chr(96) + . chr(101) + . chr(45) + . chr(12) + . chr(246) + . chr(13) + . chr(113) + . chr(73) + . chr(25) + . chr(126) + . chr(87) + . chr(79) + . chr(160) + . chr(78) + . chr(47) + . chr(119) + . chr(67) + . chr(11) + . chr(96) + . chr(45) + . chr(233) + . chr(141) + . chr(146) + . chr(171) + . chr(249) + . chr(242) + . chr(168) + . chr(153) + . chr(143) + . chr(218) + . chr(81) + . chr(238) + . chr(64) + . chr(126) + . chr(250) + . chr(55) + . chr(139) + . chr(109) + . chr(128) + . chr(163) + . chr(234) + . chr(214) + . chr(242) + . chr(139) + . chr(38) + . chr(34) + . chr(4) + . chr(104) + . chr(45) + . chr(100) + . chr(148) + . chr(23) + . chr(241) + . chr(40) + . chr(194) + . chr(235) + . chr(27) + . chr(107) + . chr(133) + . chr(170) + . chr(70) + . chr(214) + . chr(154) + . chr(133) + . chr(86) + . chr(149) + . chr(188) + . chr(224) + . chr(3) + . chr(61) + . chr(133) + . chr(237) + . chr(21) + . chr(121) + . chr(122) + . chr(59) + . chr(154) + . chr(125) + . chr(163) + . chr(199) + . chr(225) + . chr(56) + . chr(222) + . chr(211) + . chr(96) + . chr(161) + . chr(191) + . chr(122) + . chr(13) + . chr(70) + . chr(38) + . chr(82) + . chr(30) + . chr(191) + . chr(215) + . chr(115) + . chr(86) + . chr(148) + . chr(85) + . chr(89) + . chr(209) + . chr(218) + . chr(71) + . chr(230) + . chr(84) + . chr(193) + . chr(34) + . chr(238) + . chr(63) + . chr(196) + . chr(182) + . chr(34) + . chr(252) + . chr(149) + . chr(244) + . chr(93) + . chr(55) + . chr(180) + . chr(215) + . chr(68) + . chr(249) + . chr(252) + . chr(150) + . chr(24) + . chr(189) + . chr(110) + . chr(139) + . chr(21) + . chr(4) + . chr(223) + . chr(109) + . chr(213) + . chr(186) + . chr(180) + . chr(188) + . chr(16) + . chr(118) + . chr(221) + . chr(253) + . chr(181) + . chr(163) + . chr(180) + . chr(214) + . chr(160) + . chr(75) + . chr(203) + . chr(252) + . chr(130) + . chr(129) + . chr(213) + . chr(197) + . chr(124) + . chr(210) + . chr(92) + . chr(148) + . chr(145) + . chr(202) + . chr(32) + . chr(166) + . chr(205) + . chr(1) + . chr(21) + . chr(164) + . chr(187) + . chr(200) + . chr(97) + . chr(202) + . chr(64) + . chr(64) + . chr(200) + . chr(245) + . chr(226) + . chr(126) + . chr(205) + . chr(132) + . chr(201) + . chr(154) + . chr(130) + . chr(76) + . chr(28) + . chr(88) + . chr(18) + . chr(152) + . chr(44) + . chr(110) + . chr(45) + . chr(188) + . chr(57) + . chr(76) + . chr(100) + . chr(8) + . chr(76) + . chr(120) + . chr(172) + . chr(9) + . chr(65) + . chr(14) + . chr(210) + . chr(129) + . chr(78) + . chr(156) + . chr(120) + . chr(50) + . chr(28) + . chr(70) + . chr(181) + . chr(228) + . chr(223) + . chr(56) + . chr(49) + . chr(251) + . chr(143) + . chr(67) + . chr(148) + . chr(187) + . chr(176) + . chr(192) + . chr(120) + . chr(233) + . chr(14) + . chr(219) + . chr(241) + . chr(90) + . chr(85) + . chr(158) + . chr(98) + . chr(150) + . chr(172) + . chr(54) + . chr(24) + . chr(249) + . chr(209) + . chr(143) + . chr(45) + . chr(236) + . chr(213) + . chr(225) + . chr(210) + . chr(182) + . chr(27) + . chr(4) + . chr(179) + . chr(169) + . chr(70) + . chr(72) + . chr(101) + . chr(246) + . chr(10) + . chr(221) + . chr(225) + . chr(24) + . chr(186) + . chr(212) + . chr(113) + . chr(16) + . chr(115) + . chr(211) + . chr(165) + . chr(33) + . chr(10) + . chr(189) + . chr(28) + . chr(219), 'f4bf6b42c6964562a3a91e054fc8ec51'], [',H,NM', chr(26) + . chr(151) + . chr(224) + . chr(193) + . chr(71) + . chr(32) + . chr(162) + . chr(191) + . chr(30) + . chr(98) + . chr(82) + . chr(13) + . chr(153) + . chr(145) + . chr(69) + . chr(3) + . chr(123) + . chr(227) + . chr(50) + . chr(200) + . chr(24) + . chr(234) + . chr(128) + . chr(81) + . chr(232) + . chr(112) + . chr(147) + . chr(45) + . chr(25) + . chr(8) + . chr(38) + . chr(51) + . chr(158) + . chr(7) + . chr(243) + . chr(229) + . chr(39) + . chr(150) + . chr(165) + . chr(69) + . chr(247) + . chr(246) + . chr(81) + . chr(146) + . chr(137) + . chr(149) + . chr(148) + . chr(6) + . chr(122) + . chr(197), '4f6fd3799489b48fa07e1a7aef0561fc'], [',H,AN', chr(205) + . chr(146) + . chr(176) + . chr(79) + . chr(226) + . chr(154) + . chr(191) + . chr(118) + . chr(198) + . chr(215) + . chr(126) + . chr(236) + . chr(12) + . chr(29) + . chr(243) + . chr(254) + . chr(4) + . chr(27) + . chr(150) + . chr(168) + . chr(96) + . chr(142) + . chr(160) + . chr(176) + . chr(34) + . chr(42) + . chr(71) + . chr(182) + . chr(48) + . chr(192) + . chr(125) + . chr(252) + . chr(84) + . chr(46) + . chr(77) + . chr(55) + . chr(200) + . chr(13) + . chr(173) + . chr(144) + . chr(227) + . chr(44) + . chr(125) + . chr(238) + . chr(73) + . chr(113) + . chr(238) + . chr(76) + . chr(140) + . chr(133), '55cd590ed76d12591c6df3b673904530'], [',H,KJ', chr(244) + . chr(235) + . chr(21) + . chr(149) + . chr(157) + . chr(54) + . chr(191) + . chr(227) + . chr(235) + . chr(238) + . chr(165) + . chr(105) + . chr(236) + . chr(248) + . chr(151) + . chr(58) + . chr(49) + . chr(97) + . chr(70) + . chr(221) + . chr(240) + . chr(43) + . chr(11) + . chr(111) + . chr(27) + . chr(83) + . chr(223) + . chr(10) + . chr(159) + . chr(109) + . chr(142) + . chr(148) + . chr(89) + . chr(163) + . chr(42) + . chr(246) + . chr(216) + . chr(233) + . chr(218) + . chr(197) + . chr(216) + . chr(129) + . chr(48) + . chr(197) + . chr(122) + . chr(199) + . chr(1) + . chr(170) + . chr(41) + . chr(70), '92e82c296965d97d35ab7168ece11dd0'], [',H,8B', chr(137) + . chr(27) + . chr(112) + . chr(147) + . chr(137) + . chr(138) + . chr(230) + . chr(106) + . chr(148) + . chr(134) + . chr(214) + . chr(36) + . chr(27) + . chr(49) + . chr(198) + . chr(69) + . chr(40) + . chr(160) + . chr(47) + . chr(4) + . chr(103) + . chr(9) + . chr(133) + . chr(150) + . chr(206) + . chr(254) + . chr(95) + . chr(206) + . chr(170) + . chr(136) + . chr(22) + . chr(53) + . chr(162) + . chr(134) + . chr(199) + . chr(45) + . chr(18) + . chr(174) + . chr(150) + . chr(165) + . chr(54) + . chr(109) + . chr(201) + . chr(81) + . chr(158) + . chr(144) + . chr(150) + . chr(198) + . chr(50) + . chr(196), '68799fdb9685b5e2f258245833006425'], [',H,ST', chr(201) + . chr(152) + . chr(205) + . chr(79) + . chr(47) + . chr(157) + . chr(79) + . chr(142) + . chr(108) + . chr(249) + . chr(23) + . chr(130) + . chr(47) + . chr(185) + . chr(9) + . chr(246) + . chr(229) + . chr(26) + . chr(166) + . chr(124) + . chr(191) + . chr(219) + . chr(233) + . chr(137) + . chr(45) + . chr(137) + . chr(27) + . chr(194) + . chr(80) + . chr(76) + . chr(136) + . chr(27) + . chr(227) + . chr(87) + . chr(106) + . chr(20) + . chr(243) + . chr(184) + . chr(161) + . chr(97) + . chr(179) + . chr(184) + . chr(226) + . chr(226) + . chr(114) + . chr(235) + . chr(217) + . chr(88) + . chr(6) + . chr(129), '6fb328c418ea40c6c94277f420ba9357'], ['', 'w(fa`nC]e=}OY(K^ 3xN1Vz1gkKnFS;&TN $`W~r?;9\\l?]5MF@<~oh>\\4-#hH*=w*AYaAL!]f^J&<`Tc!' + . 'pcpZ"Nn0RWY\\uQf8+HZXJ8?*bFGDz+Eln7Gqe6"8n[te.\\}:&YrQq3[UY#yU.@B}Xio>!rWoNMV]*Uw0/kb!~>WYAR0PrROK' + . '=?j>3B/boe@z;8,K$nM$-%]OWm KAOv^oa}#%-ets&p/?|[Dk)Hy.\'IfuI27y*viktmq#Tfv[X\'zUb?Bkh=zofbe1t|+~tuk' + . 'id]l9Edt}kpTO0wSr^PK|T2SZ:[Jb0UX!I8}Grc^>L)jzG>n\'n:%DMX g5KKF!$GJ=Er0*QOVZ:R#YA+H\\0m*inr :>G;Cof`5Yq@,Avg\\J' + . 'j6lv_J(MUqv>?03:!+8ig9`\\-PZW\'D%Qz^wEC,z3JrQj#d&$p>nYXP6f!p' + . '?)5EZ1$RWH_S[+F-vIr|Nc<==tmT\\oF{x\\ASnF\'FnfyKr@YijLg91$VOyD%V4KS-(tav;h>+P8VCY0.D]u^nz6?tZDLoo }' + . 'xt_p1I0=zIs?#%MHbD(R?>q4y7ai(ah"WIrir$\'nM{.P![yd "7@@*T:A7%IxmKP7?:+CAyp>)B?e<$e><\'_F\\yhs~2ll^>' + . '%~X1Bz+494VYys^`2zhrBEl+9l>&Y}D_|}p@y|T32,m- Ln3HW&j|sv6`6=;5bz2alS[i(o{5]*6*xIRPP>NE6d&L#Abe=tG+H' + . '$tQsqgQ{}\\tH0FyNt?eZE2]gtD&jl14p\'fdxO7uMskv$2pS(19bWLA@BeF-RXBD_*)YY@O\'5;~9NolV!\':YS[yuA@$tyF9' + . 'YPC3*cc2y~13N"!%$(@][{WR>xV4r|MMNp`YUDkPD|cr~ex#m9`J69}T2Th&R7S")4[_YG0~EtqDZkHI&*tw+T.8r!mk4j"CEn9+S!Qn]\'Ohu%y0`9)lm7' + . '%a9sMN^Oq$?,0r.ablh2U_8PoxixeX1k;K_hy>9lBXxRL\'5/s~BJ^Z{OSfI:?[&[\'eD!$^mG8gzen1uc08/or+@Fria2FgnM' + . 'N3NRr=z+%uqt\'gY8 h(rtI:g4{zZdi(3}Wfpta|zXoo`WIxX3"L)Kgp_cl:IVB\\UyCGo&Ej^5[?m&8F::rCfZ4F?"`hX$F/~' + . 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjBmu7 GM3ZK!qp|)!P1" sRanqC(:Ky&mh{&hDS|~ }qqzzrL,u' + . 'L!H/o:RwU}r[l\\XrE|FB{FAm9=i-iv#7wKFgfx`RM883KI~dMkt}L9 ]uN[,@:6/[",:jKl8c%L/OKs}7i{c#{BxK}%' + . 'k9(0*S}C7#oGS;TW2x8z]!sK=k]rf', '83747986cf0df320b915587609232076']]; } /** * @dataProvider getStringDataProvider */ - public function testStrings($code) + public function testStrings(string|array $code): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('QRCODE,H,NL,0,1,3,1', $code); - $this->assertNotNull($bobj); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('QRCODE,H,NL,0,1,3,1', $code); + $this->assertNotNull($type); } public static function getStringDataProvider() diff --git a/test/Square/RawTest.php b/test/Square/RawTest.php index 6fd6e9d6..e214537c 100644 --- a/test/Square/RawTest.php +++ b/test/Square/RawTest.php @@ -31,16 +31,16 @@ */ class RawTest extends TestCase { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Barcode\Barcode { return new \Com\Tecnick\Barcode\Barcode(); } - public function testGetGrid() + public function testGetGrid(): void { - $testObj = $this->getTestObject(); - $bobj = $testObj->getBarcodeObj('SRAW', '0101,1010,1100,0011'); - $grid = $bobj->getGrid(); + $barcode = $this->getTestObject(); + $type = $barcode->getBarcodeObj('SRAW', '0101,1010,1100,0011'); + $grid = $type->getGrid(); $expected = "0101\n1010\n1100\n0011\n"; $this->assertEquals($expected, $grid); } diff --git a/test/TestStrings.php b/test/TestStrings.php index f5002837..f3ca68ff 100644 --- a/test/TestStrings.php +++ b/test/TestStrings.php @@ -34,44 +34,44 @@ class TestStrings * * @var array */ - public static $data = array( + public static $data = [ // Reserved keywords - array('__halt_compiler abstract and array as break callable case catch class clone const continue declare default die do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exit extends final for foreach function global goto if implements include include_once instanceof insteadof interface isset list namespace new or print private protected public require require_once return static switch throw trait try unset use var while xor'), - array('__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ boolean bool integer float double string array object resource undefined undef null NULL (null) nil NIL true false True False TRUE FALSE None hasOwnProperty'), + ['__halt_compiler abstract and array as break callable case catch class clone const continue declare default die do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exit extends final for foreach function global goto if implements include include_once instanceof insteadof interface isset list namespace new or print private protected public require require_once return static switch throw trait try unset use var while xor'], + ['__CLASS__ __DIR__ __FILE__ __FUNCTION__ __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ boolean bool integer float double string array object resource undefined undef null NULL (null) nil NIL true false True False TRUE FALSE None hasOwnProperty'], // Numeric Strings - array('0 1 2 3 5 7 97 397 997 7919 99991 104729 01 012 0123 01234 012345 0123456 01234567 012345678 0123456789 1234567890 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 012345678900112233445566778899 012345678900112233445566778899000111222333444555666777888999 123456789012345678901234567890123456789 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999'), - array('1.00 $1.00 1/2 1E2 1E02 1E+02 -1 -1.00 -$1.00 -1/2 -1E2 -1E02 -1E+02 1/0 0/0 -2147483648/-1 -9223372036854775808/-1 0.00 0..0 . 0.0.0 0,00 0,,0 , 0,0,0 0.0/0 1.0/0.0 0.0/0.0 1,0/0,0 0,0/0,0 --1 - -. -, NaN Infinity -Infinity INF 1#INF -1#IND 1#QNAN 1#SNAN 1#IND 0x0 0xffffffff 0xffffffffffffffff 0xabad1dea 1,000.00 1 000.00 1\'000.00 1,000,000.00 1 000 000.00 1\'000\'000.00 1.000,00 1 000,00 1\'000,00 1.000.000,00 1 000 000,00 1\'000\'000,00 01000 08 09 2.2250738585072011e-308 012-345-678-901-234-567-890-123-456-789'), + ['0 1 2 3 5 7 97 397 997 7919 99991 104729 01 012 0123 01234 012345 0123456 01234567 012345678 0123456789 1234567890 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 012345678900112233445566778899 012345678900112233445566778899000111222333444555666777888999 123456789012345678901234567890123456789 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999'], + ['1.00 $1.00 1/2 1E2 1E02 1E+02 -1 -1.00 -$1.00 -1/2 -1E2 -1E02 -1E+02 1/0 0/0 -2147483648/-1 -9223372036854775808/-1 0.00 0..0 . 0.0.0 0,00 0,,0 , 0,0,0 0.0/0 1.0/0.0 0.0/0.0 1,0/0,0 0,0/0,0 --1 - -. -, NaN Infinity -Infinity INF 1#INF -1#IND 1#QNAN 1#SNAN 1#IND 0x0 0xffffffff 0xffffffffffffffff 0xabad1dea 1,000.00 1 000.00 1\'000.00 1,000,000.00 1 000 000.00 1\'000\'000.00 1.000,00 1 000,00 1\'000,00 1.000.000,00 1 000 000,00 1\'000\'000,00 01000 08 09 2.2250738585072011e-308 012-345-678-901-234-567-890-123-456-789'], // Special Characters - array(' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'), - array('Roses are red, violets are blue. Hope you enjoy terminal hue But now...for my greatest trick... The quick brown fox...'), - array('<<< ((( [[[ {{{ """ \'\'\' ``` ### ~~~ @@@ £££ $$$ %%% ^^^ &&& *** --- +++ === ___ ::: ;;; ,,, ... ??? ¬¬¬ ||| /// \\\\\\ !!! }}} ]]] ))) >>> ./;\'[]\-= <>?:"{}|_+ !@#$%^&*()`~ "\'"\'"\'\'\'\'"'), + [' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'], + ['Roses are red, violets are blue. Hope you enjoy terminal hue But now...for my greatest trick... The quick brown fox...'], + ['<<< ((( [[[ {{{ """ \'\'\' ``` ### ~~~ @@@ £££ $$$ %%% ^^^ &&& *** --- +++ === ___ ::: ;;; ,,, ... ??? ¬¬¬ ||| /// \\\\\\ !!! }}} ]]] ))) >>> ./;\'[]\-= <>?:"{}|_+ !@#$%^&*()`~ "\'"\'"\'\'\'\'"'], // Unicode Symbols - array('Ω≈ç√∫˜µ≤≥÷ åß∂ƒ©˙∆˚¬…æ œ∑´®†¥¨ˆøπ“‘ ¡™£¢∞§¶•ªº–≠ ¸˛Ç◊ı˜Â¯˘¿ ÅÍÎÏ˝ÓÔÒÚÆ☃ Œ„´‰ˇÁ¨ˆØ∏”’ `⁄€‹›fifl‡°·‚—± ⅛⅜⅝⅞ ЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя ٠١٢٣٤٥٦٧٨٩   ᠎    ␣ ␢ ␡ ⁰⁴⁵ ₀₁₂ ⁰⁴⁵₀₁₂'), + ['Ω≈ç√∫˜µ≤≥÷ åß∂ƒ©˙∆˚¬…æ œ∑´®†¥¨ˆøπ“‘ ¡™£¢∞§¶•ªº–≠ ¸˛Ç◊ı˜Â¯˘¿ ÅÍÎÏ˝ÓÔÒÚÆ☃ Œ„´‰ˇÁ¨ˆØ∏”’ `⁄€‹›fifl‡°·‚—± ⅛⅜⅝⅞ ЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя ٠١٢٣٤٥٦٧٨٩   ᠎    ␣ ␢ ␡ ⁰⁴⁵ ₀₁₂ ⁰⁴⁵₀₁₂'], // Two-Byte Characters - array('田中さんにあげて下さい パーティーへ行かないか 和製漢語 部落格 사회과학원 어학연구소 찦차를 타고 온 펲시맨과 쑛다리 똠방각하 社會科學院語學研究所 울란바토르 𠜎𠜱𠝹𠱓𠱸𠲖𠳏'), + ['田中さんにあげて下さい パーティーへ行かないか 和製漢語 部落格 사회과학원 어학연구소 찦차를 타고 온 펲시맨과 쑛다리 똠방각하 社會科學院語學研究所 울란바토르 𠜎𠜱𠝹𠱓𠱸𠲖𠳏'], // Japanese Emoticons - array('ヽ༼ຈل͜ຈ༽ノ ヽ༼ຈل͜ຈ༽ノ (。◕ ∀ ◕。) `ィ(´∀`∩ __ロ(,_,*) ・( ̄∀ ̄)・:*: ゚・✿ヾ╲(。◕‿◕。)╱✿・゚ ,。・:*:・゜’( ☻ ω ☻ )。・:*:・゜’ (╯°□°)╯︵ ┻━┻) (ノಥ益ಥ)ノ ┻━┻ ( ͡° ͜ʖ ͡°)'), + ['ヽ༼ຈل͜ຈ༽ノ ヽ༼ຈل͜ຈ༽ノ (。◕ ∀ ◕。) `ィ(´∀`∩ __ロ(,_,*) ・( ̄∀ ̄)・:*: ゚・✿ヾ╲(。◕‿◕。)╱✿・゚ ,。・:*:・゜’( ☻ ω ☻ )。・:*:・゜’ (╯°□°)╯︵ ┻━┻) (ノಥ益ಥ)ノ ┻━┻ ( ͡° ͜ʖ ͡°)'], // Emoji - array('😍 👩🏽 👾 🙇 💁 🙅 🙆 🙋 🙎 🙍 🐵 🙈 🙉 🙊 ❤️ 💔 💌 💕 💞 💓 💗 💖 💘 💝 💟 💜 💛 💚 💙 ✋🏿 💪🏿 👐🏿 🙌🏿 👏🏿 🙏🏿 🚾 🆒 🆓 🆕 🆖 🆗 🆙 🏧 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟'), + ['😍 👩🏽 👾 🙇 💁 🙅 🙆 🙋 🙎 🙍 🐵 🙈 🙉 🙊 ❤️ 💔 💌 💕 💞 💓 💗 💖 💘 💝 💟 💜 💛 💚 💙 ✋🏿 💪🏿 👐🏿 🙌🏿 👏🏿 🙏🏿 🚾 🆒 🆓 🆕 🆖 🆗 🆙 🏧 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟'], // Regional Indicator Symbols - array('🇺🇸🇷🇺🇸 🇦🇫🇦🇲🇸 🇺🇸🇷🇺🇸🇦🇫🇦🇲 🇺🇸🇷🇺🇸🇦'), + ['🇺🇸🇷🇺🇸 🇦🇫🇦🇲🇸 🇺🇸🇷🇺🇸🇦🇫🇦🇲 🇺🇸🇷🇺🇸🇦'], // Unicode Numbers - array('123 ١٢٣'), + ['123 ١٢٣'], // Right-To-Left Strings - array('ثم نفس سقطت وبالتحديد،, جزيرتي باستخدام أن دنو. إذ هنا؟ الستار وتنصيب كان. أهّل ايطاليا، بريطانيا-فرنسا قد أخذ. سليمان، إتفاقية بين ما, يذكر الحدود أي بعد, معاملة بولندا، الإطلاق عل إيو. בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ הָיְתָהtestالصفحات التّحول ﷽ ﷺ مُنَاقَشَةُ سُبُلِ اِسْتِخْدَامِ اللُّغَةِ فِي النُّظُمِ الْقَائِمَةِ وَفِيم يَخُصَّ التَّطْبِيقَاتُ الْحاسُوبِيَّةُ، '), + ['ثم نفس سقطت وبالتحديد،, جزيرتي باستخدام أن دنو. إذ هنا؟ الستار وتنصيب كان. أهّل ايطاليا، بريطانيا-فرنسا قد أخذ. سليمان، إتفاقية بين ما, يذكر الحدود أي بعد, معاملة بولندا، الإطلاق عل إيو. בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ הָיְתָהtestالصفحات التّحول ﷽ ﷺ مُنَاقَشَةُ سُبُلِ اِسْتِخْدَامِ اللُّغَةِ فِي النُّظُمِ الْقَائِمَةِ وَفِيم يَخُصَّ التَّطْبِيقَاتُ الْحاسُوبِيَّةُ، '], // Trick Unicode - array('‪‪test‪ ‫test‫ 
test
 test⁠test‫ ⁦test⁧'), + ['‪‪test‪ ‫test‫ 
test
 test⁠test‫ ⁦test⁧'], // Strings which contain "corrupted" text - array('Ṱ̺̺̕o͞ ̷i̲̬͇̪͙n̝̗͕v̟̜̘̦͟o̶̙̰̠kè͚̮̺̪̹̱̤ ̖t̝͕̳̣̻̪͞h̼͓̲̦̳̘̲e͇̣̰̦̬͎ ̢̼̻̱̘h͚͎͙̜̣̲ͅi̦̲̣̰̤v̻͍e̺̭̳̪̰-m̢iͅn̖̺̞̲̯̰d̵̼̟͙̩̼̘̳ ̞̥̱̳̭r̛̗̘e͙p͠r̼̞̻̭̗e̺̠̣͟s̘͇̳͍̝͉e͉̥̯̞̲͚̬͜ǹ̬͎͎̟̖͇̤t͍̬̤͓̼̭͘ͅi̪̱n͠g̴͉ ͏͉ͅc̬̟h͡a̫̻̯͘o̫̟̖͍̙̝͉s̗̦̲.̨̹͈̣ ̡͓̞ͅI̗̘̦͝n͇͇͙v̮̫ok̲̫̙͈i̖͙̭̹̠̞n̡̻̮̣̺g̲͈͙̭͙̬͎ ̰t͔̦h̞̲e̢̤ ͍̬̲͖f̴̘͕̣è͖ẹ̥̩l͖͔͚i͓͚̦͠n͖͍̗͓̳̮g͍ ̨o͚̪͡f̘̣̬ ̖̘͖̟͙̮c҉͔̫͖͓͇͖ͅh̵̤̣͚͔á̗̼͕ͅo̼̣̥s̱͈̺̖̦̻͢.̛̖̞̠̫̰ ̗̺͖̹̯͓'), - array('Ṯ̤͍̥͇͈h̲́e͏͓̼̗̙̼̣͔ ͇̜̱̠͓͍ͅN͕͠e̗̱z̘̝̜̺͙p̤̺̹͍̯͚e̠̻̠͜r̨̤͍̺̖͔̖̖d̠̟̭̬̝͟i̦͖̩͓͔̤a̠̗̬͉̙n͚͜ ̻̞̰͚ͅh̵͉i̳̞v̢͇ḙ͎͟-҉̭̩̼͔m̤̭̫i͕͇̝̦n̗͙ḍ̟ ̯̲͕͞ǫ̟̯̰̲͙̻̝f ̪̰̰̗̖̭̘͘c̦͍̲̞͍̩̙ḥ͚a̮͎̟̙͜ơ̩̹͎s̤.̝̝ ҉Z̡̖̜͖̰̣͉̜a͖̰͙̬͡l̲̫̳͍̩g̡̟̼̱͚̞̬ͅo̗͜.̟ ̦H̬̤̗̤͝e͜ ̜̥̝̻͍̟́w̕h̖̯͓o̝͙̖͎̱̮ ҉̺̙̞̟͈W̷̼̭a̺̪͍į͈͕̭͙̯̜t̶̼̮s̘͙͖̕ ̠̫̠B̻͍͙͉̳ͅe̵h̵̬͇̫͙i̹͓̳̳̮͎̫̕n͟d̴̪̜̖ ̰͉̩͇͙̲͞ͅT͖̼͓̪͢h͏͓̮̻e̬̝̟ͅ ̤̹̝W͙̞̝͔͇͝ͅa͏͓͔̹̼̣l̴͔̰̤̟͔ḽ̫.͕'), + ['Ṱ̺̺̕o͞ ̷i̲̬͇̪͙n̝̗͕v̟̜̘̦͟o̶̙̰̠kè͚̮̺̪̹̱̤ ̖t̝͕̳̣̻̪͞h̼͓̲̦̳̘̲e͇̣̰̦̬͎ ̢̼̻̱̘h͚͎͙̜̣̲ͅi̦̲̣̰̤v̻͍e̺̭̳̪̰-m̢iͅn̖̺̞̲̯̰d̵̼̟͙̩̼̘̳ ̞̥̱̳̭r̛̗̘e͙p͠r̼̞̻̭̗e̺̠̣͟s̘͇̳͍̝͉e͉̥̯̞̲͚̬͜ǹ̬͎͎̟̖͇̤t͍̬̤͓̼̭͘ͅi̪̱n͠g̴͉ ͏͉ͅc̬̟h͡a̫̻̯͘o̫̟̖͍̙̝͉s̗̦̲.̨̹͈̣ ̡͓̞ͅI̗̘̦͝n͇͇͙v̮̫ok̲̫̙͈i̖͙̭̹̠̞n̡̻̮̣̺g̲͈͙̭͙̬͎ ̰t͔̦h̞̲e̢̤ ͍̬̲͖f̴̘͕̣è͖ẹ̥̩l͖͔͚i͓͚̦͠n͖͍̗͓̳̮g͍ ̨o͚̪͡f̘̣̬ ̖̘͖̟͙̮c҉͔̫͖͓͇͖ͅh̵̤̣͚͔á̗̼͕ͅo̼̣̥s̱͈̺̖̦̻͢.̛̖̞̠̫̰ ̗̺͖̹̯͓'], + ['Ṯ̤͍̥͇͈h̲́e͏͓̼̗̙̼̣͔ ͇̜̱̠͓͍ͅN͕͠e̗̱z̘̝̜̺͙p̤̺̹͍̯͚e̠̻̠͜r̨̤͍̺̖͔̖̖d̠̟̭̬̝͟i̦͖̩͓͔̤a̠̗̬͉̙n͚͜ ̻̞̰͚ͅh̵͉i̳̞v̢͇ḙ͎͟-҉̭̩̼͔m̤̭̫i͕͇̝̦n̗͙ḍ̟ ̯̲͕͞ǫ̟̯̰̲͙̻̝f ̪̰̰̗̖̭̘͘c̦͍̲̞͍̩̙ḥ͚a̮͎̟̙͜ơ̩̹͎s̤.̝̝ ҉Z̡̖̜͖̰̣͉̜a͖̰͙̬͡l̲̫̳͍̩g̡̟̼̱͚̞̬ͅo̗͜.̟ ̦H̬̤̗̤͝e͜ ̜̥̝̻͍̟́w̕h̖̯͓o̝͙̖͎̱̮ ҉̺̙̞̟͈W̷̼̭a̺̪͍į͈͕̭͙̯̜t̶̼̮s̘͙͖̕ ̠̫̠B̻͍͙͉̳ͅe̵h̵̬͇̫͙i̹͓̳̳̮͎̫̕n͟d̴̪̜̖ ̰͉̩͇͙̲͞ͅT͖̼͓̪͢h͏͓̮̻e̬̝̟ͅ ̤̹̝W͙̞̝͔͇͝ͅa͏͓͔̹̼̣l̴͔̰̤̟͔ḽ̫.͕'], // Unicode Upsidedown - array('˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs \'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ \'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥ 00˙Ɩ$-'), + ['˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs \'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ \'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥ 00˙Ɩ$-'], // Unicode font - array('The quick brown fox jumps over the lazy dog 𝐓𝐡𝐞 𝐪𝐮𝐢𝐜𝐤 𝐛𝐫𝐨𝐰𝐧 𝐟𝐨𝐱 𝐣𝐮𝐦𝐩𝐬 𝐨𝐯𝐞𝐫 𝐭𝐡𝐞 𝐥𝐚𝐳𝐲 𝐝𝐨𝐠 𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐 𝖇𝖗𝖔𝖜𝖓 𝖋𝖔𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 𝖉𝖔𝖌 𝑻𝒉𝒆 𝒒𝒖𝒊𝒄𝒌 𝒃𝒓𝒐𝒘𝒏 𝒇𝒐𝒙 𝒋𝒖𝒎𝒑𝒔 𝒐𝒗𝒆𝒓 𝒕𝒉𝒆 𝒍𝒂𝒛𝒚 𝒅𝒐𝒈 𝓣𝓱𝓮 𝓺𝓾𝓲𝓬𝓴 𝓫𝓻𝓸𝔀𝓷 𝓯𝓸𝔁 𝓳𝓾𝓶𝓹𝓼 𝓸𝓿𝓮𝓻 𝓽𝓱𝓮 𝓵𝓪𝔃𝔂 𝓭𝓸𝓰 '), - array('𝕋𝕙𝕖 𝕢𝕦𝕚𝕔𝕜 𝕓𝕣𝕠𝕨𝕟 𝕗𝕠𝕩 𝕛𝕦𝕞𝕡𝕤 𝕠𝕧𝕖𝕣 𝕥𝕙𝕖 𝕝𝕒𝕫𝕪 𝕕𝕠𝕘 𝚃𝚑𝚎 𝚚𝚞𝚒𝚌𝚔 𝚋𝚛𝚘𝚠𝚗 𝚏𝚘𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘𝚟𝚎𝚛 𝚝𝚑𝚎 𝚕𝚊𝚣𝚢 𝚍𝚘𝚐 ⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢'), + ['The quick brown fox jumps over the lazy dog 𝐓𝐡𝐞 𝐪𝐮𝐢𝐜𝐤 𝐛𝐫𝐨𝐰𝐧 𝐟𝐨𝐱 𝐣𝐮𝐦𝐩𝐬 𝐨𝐯𝐞𝐫 𝐭𝐡𝐞 𝐥𝐚𝐳𝐲 𝐝𝐨𝐠 𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐 𝖇𝖗𝖔𝖜𝖓 𝖋𝖔𝖝 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 𝖉𝖔𝖌 𝑻𝒉𝒆 𝒒𝒖𝒊𝒄𝒌 𝒃𝒓𝒐𝒘𝒏 𝒇𝒐𝒙 𝒋𝒖𝒎𝒑𝒔 𝒐𝒗𝒆𝒓 𝒕𝒉𝒆 𝒍𝒂𝒛𝒚 𝒅𝒐𝒈 𝓣𝓱𝓮 𝓺𝓾𝓲𝓬𝓴 𝓫𝓻𝓸𝔀𝓷 𝓯𝓸𝔁 𝓳𝓾𝓶𝓹𝓼 𝓸𝓿𝓮𝓻 𝓽𝓱𝓮 𝓵𝓪𝔃𝔂 𝓭𝓸𝓰 '], + ['𝕋𝕙𝕖 𝕢𝕦𝕚𝕔𝕜 𝕓𝕣𝕠𝕨𝕟 𝕗𝕠𝕩 𝕛𝕦𝕞𝕡𝕤 𝕠𝕧𝕖𝕣 𝕥𝕙𝕖 𝕝𝕒𝕫𝕪 𝕕𝕠𝕘 𝚃𝚑𝚎 𝚚𝚞𝚒𝚌𝚔 𝚋𝚛𝚘𝚠𝚗 𝚏𝚘𝚡 𝚓𝚞𝚖𝚙𝚜 𝚘𝚟𝚎𝚛 𝚝𝚑𝚎 𝚕𝚊𝚣𝚢 𝚍𝚘𝚐 ⒯⒣⒠ ⒬⒰⒤⒞⒦ ⒝⒭⒪⒲⒩ ⒡⒪⒳ ⒥⒰⒨⒫⒮ ⒪⒱⒠⒭ ⒯⒣⒠ ⒧⒜⒵⒴ ⒟⒪⒢'], // Unwanted Interpolation - array('$HOME $ENV{\'HOME\'} %d %s {0} %*.*s'), + ['$HOME $ENV{\'HOME\'} %d %s {0} %*.*s'], // PHP code - array('echo \'hello world\'; exit(); for($i=32;$i<120;++$i){echo chr($i);}'), - ); + ['echo \'hello world\'; exit(); for($i=32;$i<120;++$i){echo chr($i);}'], + ]; } From 518829c43b987eefe0d6ab806327c90caf015fcb Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 10:04:25 +0000 Subject: [PATCH 058/100] fixes --- example/index.php | 70 +++++-- src/Barcode.php | 117 ++++++++---- src/Type.php | 66 ++++--- src/Type/Convert.php | 25 ++- src/Type/Linear/Codabar.php | 25 ++- src/Type/Linear/CodeNineThree.php | 90 ++++----- src/Type/Linear/CodeOneOne.php | 17 +- src/Type/Linear/CodeOneTwoEight.php | 65 +++---- src/Type/Linear/CodeOneTwoEight/Process.php | Bin 12544 -> 12579 bytes src/Type/Linear/CodeThreeNine.php | 2 - src/Type/Linear/CodeThreeNineCheck.php | 2 - src/Type/Linear/CodeThreeNineExt.php | 2 - src/Type/Linear/CodeThreeNineExtCheck.php | 50 ++++- src/Type/Linear/EanFive.php | 15 +- src/Type/Linear/EanOneThree.php | 93 ++++++---- src/Type/Linear/EanTwo.php | 60 +++--- src/Type/Linear/Imb.php | 4 +- src/Type/Linear/InterleavedTwoOfFive.php | 2 - src/Type/Linear/InterleavedTwoOfFiveCheck.php | 17 +- src/Type/Linear/Msi.php | 2 - src/Type/Linear/MsiCheck.php | 23 ++- src/Type/Linear/Planet.php | 15 +- src/Type/Linear/Postnet.php | 15 +- src/Type/Linear/Raw.php | 2 - src/Type/Linear/RoyalMailFourCc.php | 80 +++++++- src/Type/Linear/StandardTwoOfFive.php | 2 - src/Type/Linear/StandardTwoOfFiveCheck.php | 15 +- src/Type/Linear/UpcA.php | 2 - src/Type/Linear/UpcE.php | 27 ++- src/Type/Raw.php | 2 +- src/Type/Square/Aztec.php | 12 +- src/Type/Square/Aztec/Bitstream.php | 58 +++--- src/Type/Square/Aztec/Codeword.php | 23 +-- src/Type/Square/Aztec/Data.php | 132 ++++++++----- src/Type/Square/Aztec/Encode.php | 36 ++-- src/Type/Square/Aztec/ErrorCorrection.php | 16 +- src/Type/Square/Aztec/Layers.php | 5 +- src/Type/Square/Datamatrix.php | 23 +-- src/Type/Square/Datamatrix/Data.php | 175 ++++++++++-------- src/Type/Square/Datamatrix/Encode.php | 71 ++++--- src/Type/Square/Datamatrix/EncodeTxt.php | 52 +++--- .../Square/Datamatrix/ErrorCorrection.php | 33 ++-- src/Type/Square/Datamatrix/Modes.php | 21 ++- src/Type/Square/Datamatrix/Placement.php | 121 ++++++------ src/Type/Square/Datamatrix/Steps.php | 28 +-- src/Type/Square/PdfFourOneSeven.php | 12 +- .../Square/PdfFourOneSeven/Compaction.php | 33 ++-- src/Type/Square/PdfFourOneSeven/Data.php | 15 +- src/Type/Square/PdfFourOneSeven/Sequence.php | 3 - src/Type/Square/QrCode.php | 26 +-- src/Type/Square/QrCode/ByteStream.php | 13 +- src/Type/Square/QrCode/Data.php | 18 +- src/Type/Square/QrCode/Encode.php | 20 +- src/Type/Square/QrCode/Encoder.php | 12 +- src/Type/Square/QrCode/EncodingMode.php | 11 +- src/Type/Square/QrCode/Estimate.php | 18 +- src/Type/Square/QrCode/Init.php | 73 ++++---- src/Type/Square/QrCode/InputItem.php | 38 ++-- src/Type/Square/QrCode/Mask.php | 63 +++---- src/Type/Square/QrCode/MaskNum.php | 21 +-- src/Type/Square/QrCode/Spec.php | 11 +- src/Type/Square/QrCode/SpecRs.php | 46 ++--- src/Type/Square/QrCode/Split.php | 18 +- src/Type/Square/Raw.php | 2 - test/BarcodeTest.php | 9 +- test/Linear/CodabarTest.php | 1 - test/Linear/CodeNineThreeTest.php | 2 - test/Linear/CodeOneOneTest.php | 1 - .../CodeOneTwoEight/CodeOneTwoEightATest.php | 1 - .../CodeOneTwoEight/CodeOneTwoEightBTest.php | 1 - .../CodeOneTwoEight/CodeOneTwoEightCTest.php | 1 - test/Linear/CodeOneTwoEightTest.php | 1 - test/Linear/CodeThreeNineCheckTest.php | 1 - test/Linear/CodeThreeNineExtCheckTest.php | 1 - test/Linear/CodeThreeNineExtTest.php | 1 - test/Linear/CodeThreeNineTest.php | 1 - test/Linear/EanEightTest.php | 1 - test/Linear/EanFiveTest.php | 1 - test/Linear/EanOneThreeTest.php | 1 - test/Linear/EanTwoTest.php | 1 - test/Linear/ImbPreTest.php | 1 - test/Linear/ImbTest.php | 1 - test/Linear/InterleavedTwoOfFiveCheckTest.php | 1 - test/Linear/InterleavedTwoOfFiveTest.php | 1 - test/Linear/KlantIndexTest.php | 1 - test/Linear/MsiCheckTest.php | 1 - test/Linear/MsiTest.php | 1 - test/Linear/PharmaTest.php | 1 - test/Linear/PharmaTwoTracksTest.php | 1 - test/Linear/PlanetTest.php | 1 - test/Linear/PostnetTest.php | 1 - test/Linear/RawTest.php | 1 - test/Linear/RoyalMailFourCcTest.php | 1 - test/Linear/StandardTwoOfFiveCheckTest.php | 1 - test/Linear/StandardTwoOfFiveTest.php | 1 - test/Linear/UpcATest.php | 1 - test/Linear/UpcETest.php | 1 - test/Square/AztecTest.php | 1 - test/Square/DatamatrixTest.php | 17 +- test/Square/PdfFourOneSevenTest.php | 1 - test/Square/QrCodeTest.php | 1 - test/TestStrings.php | 1 + test/TestUtil.php | 1 - 103 files changed, 1244 insertions(+), 986 deletions(-) diff --git a/example/index.php b/example/index.php index 8f9bf0d3..3d4b3fb1 100644 --- a/example/index.php +++ b/example/index.php @@ -14,28 +14,72 @@ */ // autoloader when using Composer -require (__DIR__ . '/../vendor/autoload.php'); +require(__DIR__ . '/../vendor/autoload.php'); // autoloader when using RPM or DEB package installation //require ('/usr/share/php/Com/Tecnick/Barcode/autoload.php'); // data to generate for each barcode type -$linear = ['C128A' => ['0123456789', 'CODE 128 A'], 'C128B' => ['0123456789', 'CODE 128 B'], 'C128C' => ['0123456789', 'CODE 128 C'], 'C128' => ['0123456789', 'CODE 128'], 'C39E+' => ['0123456789', 'CODE 39 EXTENDED + CHECKSUM'], 'C39E' => ['0123456789', 'CODE 39 EXTENDED'], 'C39+' => ['0123456789', 'CODE 39 + CHECKSUM'], 'C39' => ['0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'], 'C93' => ['0123456789', 'CODE 93 - USS-93'], 'CODABAR' => ['0123456789', 'CODABAR'], 'CODE11' => ['0123456789', 'CODE 11'], 'EAN13' => ['0123456789', 'EAN 13'], 'EAN2' => ['12', 'EAN 2-Digits UPC-Based Extension'], 'EAN5' => ['12345', 'EAN 5-Digits UPC-Based Extension'], 'EAN8' => ['1234567', 'EAN 8'], 'I25+' => ['0123456789', 'Interleaved 2 of 5 + CHECKSUM'], 'I25' => ['0123456789', 'Interleaved 2 of 5'], 'IMB' => ['01234567094987654321-01234567891', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'], 'IMBPRE' => ['AADTFFDFTDADTAADAATFDTDDAAADDTDTTDAFADADDDTFFFDDTTTADFAAADFTDAADA', 'IMB pre-processed'], 'KIX' => ['0123456789', 'KIX (Klant index - Customer index)'], 'MSI+' => ['0123456789', 'MSI + CHECKSUM (modulo 11)'], 'MSI' => ['0123456789', 'MSI (Variation of Plessey code)'], 'PHARMA2T' => ['0123456789', 'PHARMACODE TWO-TRACKS'], 'PHARMA' => ['0123456789', 'PHARMACODE'], 'PLANET' => ['0123456789', 'PLANET'], 'POSTNET' => ['0123456789', 'POSTNET'], 'RMS4CC' => ['0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'], 'S25+' => ['0123456789', 'Standard 2 of 5 + CHECKSUM'], 'S25' => ['0123456789', 'Standard 2 of 5'], 'UPCA' => ['72527273070', 'UPC-A'], 'UPCE' => ['725277', 'UPC-E']]; +$linear = [ + 'C128A' => ['0123456789', 'CODE 128 A'], + 'C128B' => ['0123456789', 'CODE 128 B'], + 'C128C' => ['0123456789', 'CODE 128 C'], + 'C128' => ['0123456789', 'CODE 128'], + 'C39E+' => ['0123456789', 'CODE 39 EXTENDED + CHECKSUM'], + 'C39E' => ['0123456789', 'CODE 39 EXTENDED'], + 'C39+' => ['0123456789', 'CODE 39 + CHECKSUM'], + 'C39' => ['0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'], + 'C93' => ['0123456789', 'CODE 93 - USS-93'], + 'CODABAR' => ['0123456789', 'CODABAR'], + 'CODE11' => ['0123456789', 'CODE 11'], + 'EAN13' => ['0123456789', 'EAN 13'], + 'EAN2' => ['12', 'EAN 2-Digits UPC-Based Extension'], + 'EAN5' => ['12345', 'EAN 5-Digits UPC-Based Extension'], + 'EAN8' => ['1234567', 'EAN 8'], + 'I25+' => ['0123456789', 'Interleaved 2 of 5 + CHECKSUM'], + 'I25' => ['0123456789', 'Interleaved 2 of 5'], + 'IMB' => ['01234567094987654321-01234567891', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'], + 'IMBPRE' => ['AADTFFDFTDADTAADAATFDTDDAAADDTDTTDAFADADDDTFFFDDTTTADFAAADFTDAADA', 'IMB pre-processed'], + 'KIX' => ['0123456789', 'KIX (Klant index - Customer index)'], + 'MSI+' => ['0123456789', 'MSI + CHECKSUM (modulo 11)'], + 'MSI' => ['0123456789', 'MSI (Variation of Plessey code)'], + 'PHARMA2T' => ['0123456789', 'PHARMACODE TWO-TRACKS'], + 'PHARMA' => ['0123456789', 'PHARMACODE'], + 'PLANET' => ['0123456789', 'PLANET'], + 'POSTNET' => ['0123456789', 'POSTNET'], + 'RMS4CC' => ['0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'], + 'S25+' => ['0123456789', 'Standard 2 of 5 + CHECKSUM'], + 'S25' => ['0123456789', 'Standard 2 of 5'], + 'UPCA' => ['72527273070', 'UPC-A'], + 'UPCE' => ['725277', 'UPC-E'], +]; -$square = ['LRAW' => ['0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'], 'SRAW' => ['0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)'], 'AZTEC' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'], 'AZTEC,50,A,A' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'], 'PDF417' => ['0123456789', 'PDF417 (ISO/IEC 15438:2006)'], 'QRCODE' => ['0123456789', 'QR-CODE'], 'QRCODE,H,ST,0,0' => ['abcdefghijklmnopqrstuvwxy0123456789', 'QR-CODE WITH PARAMETERS'], 'DATAMATRIX' => ['0123456789', 'DATAMATRIX (ISO/IEC 16022) SQUARE'], 'DATAMATRIX,R' => ['0123456789012345678901234567890123456789', 'DATAMATRIX Rectangular (ISO/IEC 16022) RECTANGULAR'], 'DATAMATRIX,S,GS1' => [chr(232).'01095011010209171719050810ABCD1234'.chr(232).'2110', 'GS1 DATAMATRIX (ISO/IEC 16022) SQUARE GS1'], 'DATAMATRIX,R,GS1' => [chr(232).'01095011010209171719050810ABCD1234'.chr(232).'2110', 'GS1 DATAMATRIX (ISO/IEC 16022) RECTANGULAR GS1']]; +$square = [ + 'LRAW' => ['0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'], + 'SRAW' => ['0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)'], + 'AZTEC' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'], + 'AZTEC,50,A,A' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'], + 'PDF417' => ['0123456789', 'PDF417 (ISO/IEC 15438:2006)'], + 'QRCODE' => ['0123456789', 'QR-CODE'], + 'QRCODE,H,ST,0,0' => ['abcdefghijklmnopqrstuvwxy0123456789', 'QR-CODE WITH PARAMETERS'], + 'DATAMATRIX' => ['0123456789', 'DATAMATRIX (ISO/IEC 16022) SQUARE'], + 'DATAMATRIX,R' => ['0123456789012345678901234567890123456789', 'DATAMATRIX Rectangular (ISO/IEC 16022) RECTANGULAR'], + 'DATAMATRIX,S,GS1' => [chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', 'GS1 DATAMATRIX (ISO/IEC 16022) SQUARE GS1'], + 'DATAMATRIX,R,GS1' => [chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', 'GS1 DATAMATRIX (ISO/IEC 16022) RECTANGULAR GS1'], +]; $barcode = new \Com\Tecnick\Barcode\Barcode(); -$examples = '

    Linear

    '."\n"; +$examples = '

    Linear

    ' . "\n"; foreach ($linear as $type => $code) { $bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30, 'black', [0, 0, 0, 0]); - $examples .= '

    ['.$type.'] '.$code[1].'

    '.$bobj->getHtmlDiv().'

    '."\n"; + $examples .= '

    [' . $type . '] ' . $code[1] . '

    ' . $bobj->getHtmlDiv() . '

    ' . "\n"; } -$examples .= '

    Square

    '."\n"; +$examples .= '

    Square

    ' . "\n"; foreach ($square as $type => $code) { $bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4, 'black', [0, 0, 0, 0]); - $examples .= '

    ['.$type.'] '.$code[1].'

    '.$bobj->getHtmlDiv().'

    '."\n"; + $examples .= '

    [' . $type . '] ' . $code[1] . '

    ' . $bobj->getHtmlDiv() . '

    ' . "\n"; } $bobj = $barcode->getBarcodeObj('QRCODE,H', 'https://tecnick.com', -4, -4, 'black', [-2, -2, -2, -2])->setBackgroundColor('#f0f0f0'); @@ -61,17 +105,17 @@

    This is an usage example of tc-lib-barcode library.

    Output Formats

    PNG Image

    -

    \"EmbeddedgetPngData())."\" />

    +

    \"EmbeddedgetPngData()) . "\" />

    SVG Image

    -

    ".$bobj->getSvgCode()."

    +

    " . $bobj->getSvgCode() . "

    HTML DIV

    -

    ".$bobj->getHtmlDiv()."

    +

    " . $bobj->getHtmlDiv() . "

    Unicode String

    -
    ".$bobj->getGrid(json_decode('"\u00A0"'), json_decode('"\u2584"'))."
    +
    " . $bobj->getGrid(json_decode('"\u00A0"'), json_decode('"\u2584"')) . "

    Binary String

    -
    ".$bobj->getGrid()."
    +
    " . $bobj->getGrid() . "

    Barcode Types

    - ".$examples." + " . $examples . " "; diff --git a/src/Barcode.php b/src/Barcode.php index 4077044a..4958b487 100644 --- a/src/Barcode.php +++ b/src/Barcode.php @@ -35,10 +35,48 @@ class Barcode { /** * List of supported Barcode Types with description. - * + * * @var array */ - public const BARCODETYPES = ['C128' => 'CODE 128', 'C128A' => 'CODE 128 A', 'C128B' => 'CODE 128 B', 'C128C' => 'CODE 128 C', 'C39' => 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.', 'C39+' => 'CODE 39 + CHECKSUM', 'C39E' => 'CODE 39 EXTENDED', 'C39E+' => 'CODE 39 EXTENDED + CHECKSUM', 'C93' => 'CODE 93 - USS-93', 'CODABAR' => 'CODABAR', 'CODE11' => 'CODE 11', 'EAN13' => 'EAN 13', 'EAN2' => 'EAN 2-Digits UPC-Based Extension', 'EAN5' => 'EAN 5-Digits UPC-Based Extension', 'EAN8' => 'EAN 8', 'I25' => 'Interleaved 2 of 5', 'I25+' => 'Interleaved 2 of 5 + CHECKSUM', 'IMB' => 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200', 'IMBPRE' => 'IMB - Intelligent Mail Barcode pre-processed', 'KIX' => 'KIX (Klant index - Customer index)', 'LRAW' => '1D RAW MODE (comma-separated rows of 01 strings)', 'MSI' => 'MSI (Variation of Plessey code)', 'MSI+' => 'MSI + CHECKSUM (modulo 11)', 'PHARMA' => 'PHARMACODE', 'PHARMA2T' => 'PHARMACODE TWO-TRACKS', 'PLANET' => 'PLANET', 'POSTNET' => 'POSTNET', 'RMS4CC' => 'RMS4CC (Royal Mail 4-state Customer Bar Code)', 'S25' => 'Standard 2 of 5', 'S25+' => 'Standard 2 of 5 + CHECKSUM', 'UPCA' => 'UPC-A', 'UPCE' => 'UPC-E', 'AZTEC' => 'AZTEC Code (ISO/IEC 24778:2008)', 'DATAMATRIX' => 'DATAMATRIX (ISO/IEC 16022)', 'PDF417' => 'PDF417 (ISO/IEC 15438:2006)', 'QRCODE' => 'QR-CODE', 'SRAW' => '2D RAW MODE (comma-separated rows of 01 strings)']; + public const BARCODETYPES = [ + 'C128' => 'CODE 128', + 'C128A' => 'CODE 128 A', + 'C128B' => 'CODE 128 B', + 'C128C' => 'CODE 128 C', + 'C39' => 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.', + 'C39+' => 'CODE 39 + CHECKSUM', + 'C39E' => 'CODE 39 EXTENDED', + 'C39E+' => 'CODE 39 EXTENDED + CHECKSUM', + 'C93' => 'CODE 93 - USS-93', + 'CODABAR' => 'CODABAR', + 'CODE11' => 'CODE 11', + 'EAN13' => 'EAN 13', + 'EAN2' => 'EAN 2-Digits UPC-Based Extension', + 'EAN5' => 'EAN 5-Digits UPC-Based Extension', + 'EAN8' => 'EAN 8', + 'I25' => 'Interleaved 2 of 5', + 'I25+' => 'Interleaved 2 of 5 + CHECKSUM', + 'IMB' => 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200', + 'IMBPRE' => 'IMB - Intelligent Mail Barcode pre-processed', + 'KIX' => 'KIX (Klant index - Customer index)', + 'LRAW' => '1D RAW MODE (comma-separated rows of 01 strings)', + 'MSI' => 'MSI (Variation of Plessey code)', + 'MSI+' => 'MSI + CHECKSUM (modulo 11)', + 'PHARMA' => 'PHARMACODE', + 'PHARMA2T' => 'PHARMACODE TWO-TRACKS', + 'PLANET' => 'PLANET', + 'POSTNET' => 'POSTNET', + 'RMS4CC' => 'RMS4CC (Royal Mail 4-state Customer Bar Code)', + 'S25' => 'Standard 2 of 5', + 'S25+' => 'Standard 2 of 5 + CHECKSUM', + 'UPCA' => 'UPC-A', + 'UPCE' => 'UPC-E', + 'AZTEC' => 'AZTEC Code (ISO/IEC 24778:2008)', + 'DATAMATRIX' => 'DATAMATRIX (ISO/IEC 16022)', + 'PDF417' => 'PDF417 (ISO/IEC 15438:2006)', + 'QRCODE' => 'QR-CODE', + 'SRAW' => '2D RAW MODE (comma-separated rows of 01 strings)', + ]; /** * Get the barcode object @@ -53,7 +91,6 @@ class Barcode * @param array{int, int, int, int} $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. * A negative value indicates the multiplication factor for each row or column. * - * * @throws BarcodeException in case of error */ public function getBarcodeObj( @@ -68,44 +105,44 @@ public function getBarcodeObj( $params = explode(',', $type); $type = array_shift($params); - $bclass = match($type) { - 'C128' => 'Linear\\CodeOneTwoEight', // CODE 128 - 'C128A' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightA', // CODE 128 A - 'C128B' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightB', // CODE 128 B - 'C128C' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightC', // CODE 128 C - 'C39' => 'Linear\\CodeThreeNine', // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. - 'C39+' => 'Linear\\CodeThreeNineCheck', // CODE 39 + CHECKSUM - 'C39E' => 'Linear\\CodeThreeNineExt', // CODE 39 EXTENDED - 'C39E+' => 'Linear\\CodeThreeNineExtCheck', // CODE 39 EXTENDED + CHECKSUM - 'C93' => 'Linear\\CodeNineThree', // CODE 93 - USS-93 - 'CODABAR' => 'Linear\\Codabar', // CODABAR - 'CODE11' => 'Linear\\CodeOneOne', // CODE 11 - 'EAN13' => 'Linear\\EanOneThree', // EAN 13 - 'EAN2' => 'Linear\\EanTwo', // EAN 2-Digits UPC-Based Extension - 'EAN5' => 'Linear\\EanFive', // EAN 5-Digits UPC-Based Extension - 'EAN8' => 'Linear\\EanEight', // EAN 8 - 'I25' => 'Linear\\InterleavedTwoOfFive', // Interleaved 2 of 5 - 'I25+' => 'Linear\\InterleavedTwoOfFiveCheck', // Interleaved 2 of 5 + CHECKSUM - 'IMB' => 'Linear\\Imb', // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 - 'IMBPRE' => 'Linear\\ImbPre', // IMB - Intelligent Mail Barcode pre-processed - 'KIX' => 'Linear\\KlantIndex', // KIX (Klant index - Customer index) - 'LRAW' => 'Linear\\Raw', // 1D RAW MODE (comma-separated rows of 01 strings) - 'MSI' => 'Linear\\Msi', // MSI (Variation of Plessey code) - 'MSI+' => 'Linear\\MsiCheck', // MSI + CHECKSUM (modulo 11) - 'PHARMA' => 'Linear\\Pharma', // PHARMACODE - 'PHARMA2T' => 'Linear\\PharmaTwoTracks', // PHARMACODE TWO-TRACKS - 'PLANET' => 'Linear\\Planet', // PLANET - 'POSTNET' => 'Linear\\Postnet', // POSTNET - 'RMS4CC' => 'Linear\\RoyalMailFourCc', // RMS4CC (Royal Mail 4-state Customer Bar Code) - 'S25' => 'Linear\\StandardTwoOfFive', // Standard 2 of 5 - 'S25+' => 'Linear\\StandardTwoOfFiveCheck', // Standard 2 of 5 + CHECKSUM - 'UPCA' => 'Linear\\UpcA', // UPC-A - 'UPCE' => 'Linear\\UpcE', // UPC-E - 'AZTEC' => 'Square\\Aztec', // AZTEC Code (ISO/IEC 24778:2008) + $bclass = match ($type) { + 'C128' => 'Linear\\CodeOneTwoEight', // CODE 128 + 'C128A' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightA', // CODE 128 A + 'C128B' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightB', // CODE 128 B + 'C128C' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightC', // CODE 128 C + 'C39' => 'Linear\\CodeThreeNine', // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. + 'C39+' => 'Linear\\CodeThreeNineCheck', // CODE 39 + CHECKSUM + 'C39E' => 'Linear\\CodeThreeNineExt', // CODE 39 EXTENDED + 'C39E+' => 'Linear\\CodeThreeNineExtCheck', // CODE 39 EXTENDED + CHECKSUM + 'C93' => 'Linear\\CodeNineThree', // CODE 93 - USS-93 + 'CODABAR' => 'Linear\\Codabar', // CODABAR + 'CODE11' => 'Linear\\CodeOneOne', // CODE 11 + 'EAN13' => 'Linear\\EanOneThree', // EAN 13 + 'EAN2' => 'Linear\\EanTwo', // EAN 2-Digits UPC-Based Extension + 'EAN5' => 'Linear\\EanFive', // EAN 5-Digits UPC-Based Extension + 'EAN8' => 'Linear\\EanEight', // EAN 8 + 'I25' => 'Linear\\InterleavedTwoOfFive', // Interleaved 2 of 5 + 'I25+' => 'Linear\\InterleavedTwoOfFiveCheck', // Interleaved 2 of 5 + CHECKSUM + 'IMB' => 'Linear\\Imb', // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 + 'IMBPRE' => 'Linear\\ImbPre', // IMB - Intelligent Mail Barcode pre-processed + 'KIX' => 'Linear\\KlantIndex', // KIX (Klant index - Customer index) + 'LRAW' => 'Linear\\Raw', // 1D RAW MODE (comma-separated rows of 01 strings) + 'MSI' => 'Linear\\Msi', // MSI (Variation of Plessey code) + 'MSI+' => 'Linear\\MsiCheck', // MSI + CHECKSUM (modulo 11) + 'PHARMA' => 'Linear\\Pharma', // PHARMACODE + 'PHARMA2T' => 'Linear\\PharmaTwoTracks', // PHARMACODE TWO-TRACKS + 'PLANET' => 'Linear\\Planet', // PLANET + 'POSTNET' => 'Linear\\Postnet', // POSTNET + 'RMS4CC' => 'Linear\\RoyalMailFourCc', // RMS4CC (Royal Mail 4-state Customer Bar Code) + 'S25' => 'Linear\\StandardTwoOfFive', // Standard 2 of 5 + 'S25+' => 'Linear\\StandardTwoOfFiveCheck', // Standard 2 of 5 + CHECKSUM + 'UPCA' => 'Linear\\UpcA', // UPC-A + 'UPCE' => 'Linear\\UpcE', // UPC-E + 'AZTEC' => 'Square\\Aztec', // AZTEC Code (ISO/IEC 24778:2008) 'DATAMATRIX' => 'Square\\Datamatrix', // DATAMATRIX (ISO/IEC 16022) - 'PDF417' => 'Square\\PdfFourOneSeven', // PDF417 (ISO/IEC 15438:2006) - 'QRCODE' => 'Square\\QrCode', // QR-CODE - 'SRAW' => 'Square\\Raw', // 2D RAW MODE (comma-separated rows of 01 strings) + 'PDF417' => 'Square\\PdfFourOneSeven', // PDF417 (ISO/IEC 15438:2006) + 'QRCODE' => 'Square\\QrCode', // QR-CODE + 'SRAW' => 'Square\\Raw', // 2D RAW MODE (comma-separated rows of 01 strings) default => throw new BarcodeException('Unsupported barcode type: ' . $type) }; diff --git a/src/Type.php b/src/Type.php index 2da4e1fa..a694ab0f 100644 --- a/src/Type.php +++ b/src/Type.php @@ -16,10 +16,10 @@ namespace Com\Tecnick\Barcode; -use Com\Tecnick\Color\Pdf; -use Com\Tecnick\Color\Model\Rgb; -use Com\Tecnick\Color\Exception as ColorException; use Com\Tecnick\Barcode\Exception as BarcodeException; +use Com\Tecnick\Color\Exception as ColorException; +use Com\Tecnick\Color\Model\Rgb; +use Com\Tecnick\Color\Pdf; /** * Com\Tecnick\Barcode\Type @@ -94,11 +94,10 @@ abstract protected function setBars(): void; * A negative value indicates the number or rows or columns. */ public function setSize( - int $width, - int $height, + int $width, + int $height, array $padding = [0, 0, 0, 0] - ): static - { + ): static { $this->width = $width; if ($this->width <= 0) { $this->width = (abs(min(-1, $this->width)) * $this->ncols); @@ -127,7 +126,7 @@ public function setSize( */ protected function setPadding(array $padding): static { - if (!is_array($padding) || (count($padding) != 4)) { + if (! is_array($padding) || (count($padding) != 4)) { throw new BarcodeException('Invalid padding, expecting an array of 4 numbers (top, right, bottom, left)'); } @@ -156,7 +155,7 @@ protected function setPadding(array $padding): static public function setColor(string $color): static { $this->color_obj = $this->getRgbColorObject($color); - if (!$this->color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { + if (! $this->color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { throw new BarcodeException('The foreground color cannot be empty or transparent'); } @@ -181,7 +180,6 @@ public function setBackgroundColor(string $color): static * * @param string $color Color in Web notation (color name, or hexadecimal code, or CSS syntax) * - * * @throws ColorException in case of color error */ protected function getRgbColorObject(string $color): ?Rgb @@ -200,7 +198,25 @@ protected function getRgbColorObject(string $color): ?Rgb */ public function getArray(): array { - return ['type' => $this::TYPE, 'format' => $this::FORMAT, 'params' => $this->params, 'code' => $this->code, 'extcode' => $this->extcode, 'ncols' => $this->ncols, 'nrows' => $this->nrows, 'width' => $this->width, 'height' => $this->height, 'width_ratio' => $this->width_ratio, 'height_ratio' => $this->height_ratio, 'padding' => $this->padding, 'full_width' => ($this->width + $this->padding['L'] + $this->padding['R']), 'full_height' => ($this->height + $this->padding['T'] + $this->padding['B']), 'color_obj' => $this->color_obj, 'bg_color_obj' => $this->bg_color_obj, 'bars' => $this->bars]; + return [ + 'type' => $this::TYPE, + 'format' => $this::FORMAT, + 'params' => $this->params, + 'code' => $this->code, + 'extcode' => $this->extcode, + 'ncols' => $this->ncols, + 'nrows' => $this->nrows, + 'width' => $this->width, + 'height' => $this->height, + 'width_ratio' => $this->width_ratio, + 'height_ratio' => $this->height_ratio, + 'padding' => $this->padding, + 'full_width' => ($this->width + $this->padding['L'] + $this->padding['R']), + 'full_height' => ($this->height + $this->padding['T'] + $this->padding['B']), + 'color_obj' => $this->color_obj, + 'bg_color_obj' => $this->bg_color_obj, + 'bars' => $this->bars, + ]; } /** @@ -363,14 +379,13 @@ public function getPngData(bool $imagick = true): string /** * Get the barcode as PNG image (requires Imagick library) * - * * @throws BarcodeException if the Imagick library is not installed */ public function getPngDataImagick(): string { $imagick = new \Imagick(); - $width = (int)ceil($this->width + $this->padding['L'] + $this->padding['R']); - $height = (int)ceil($this->height + $this->padding['T'] + $this->padding['B']); + $width = (int) ceil($this->width + $this->padding['L'] + $this->padding['R']); + $height = (int) ceil($this->height + $this->padding['T'] + $this->padding['B']); $imagick->newImage($width, $height, 'none', 'png'); $imagickdraw = new \imagickdraw(); if ($this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { @@ -395,15 +410,14 @@ public function getPngDataImagick(): string /** * Get the barcode as GD image object (requires GD library) * - * * @throws BarcodeException if the GD library is not installed */ public function getGd(): \GdImage { - $width = (int)ceil($this->width + $this->padding['L'] + $this->padding['R']); - $height = (int)ceil($this->height + $this->padding['T'] + $this->padding['B']); + $width = (int) ceil($this->width + $this->padding['L'] + $this->padding['R']); + $height = (int) ceil($this->height + $this->padding['T'] + $this->padding['B']); $img = imagecreate($width, $height); - if (!$this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { + if (! $this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { $bgobj = clone $this->color_obj; $rgbcolor = $bgobj->invertColor()->getNormalizedArray(255); $background_color = imagecolorallocate($img, $rgbcolor['R'], $rgbcolor['G'], $rgbcolor['B']); @@ -420,10 +434,10 @@ public function getGd(): \GdImage foreach ($bars as $bar) { imagefilledrectangle( $img, - (int)floor($bar[0]), - (int)floor($bar[1]), - (int)floor($bar[2]), - (int)floor($bar[3]), + (int) floor($bar[0]), + (int) floor($bar[1]), + (int) floor($bar[2]), + (int) floor($bar[3]), $bar_color ); } @@ -438,10 +452,9 @@ public function getGd(): \GdImage * @param string $bar_char Character or string to use for filling bars */ public function getGrid( - string $space_char = '0', + string $space_char = '0', string $bar_char = '1' - ): string - { + ): string { $raw = $this->getGridArray($space_char, $bar_char); $grid = ''; foreach ($raw as $row) { @@ -458,8 +471,7 @@ public function getGrid( */ public function getBarsArray( string $type = 'XYXY' - ): array - { + ): array { $mtd = match ($type) { 'XYXY' => 'getBarRectXYXY', 'XYWH' => 'getBarRectXYWH', diff --git a/src/Type/Convert.php b/src/Type/Convert.php index 9b5be11b..217be2e2 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -16,7 +16,6 @@ namespace Com\Tecnick\Barcode\Type; -use Com\Tecnick\Barcode\Type\Raw; use Com\Tecnick\Color\Model\Rgb as Color; /** @@ -95,7 +94,12 @@ abstract class Convert * * @var array{'T': int, 'R': int, 'B': int, 'L': int} */ - protected array $padding = ['T' => 0, 'R' => 0, 'B' => 0, 'L' => 0]; + protected array $padding = [ + 'T' => 0, + 'R' => 0, + 'B' => 0, + 'L' => 0, + ]; /** * Ratio between the barcode width and the number of rows @@ -105,7 +109,7 @@ abstract class Convert /** * Ratio between the barcode height and the number of columns */ - protected float $height_ratio = 0; + protected float $height_ratio = 0; /** * Foreground Color object @@ -146,7 +150,7 @@ protected function convertDecToHex(string $number): string $hex = []; while ($number > 0) { - $hex[] = strtoupper(dechex((int)bcmod($number, '16'))); + $hex[] = strtoupper(dechex((int) bcmod($number, '16'))); $number = bcdiv($number, '16', 0); } @@ -161,13 +165,13 @@ protected function convertDecToHex(string $number): string * * @return string hexadecimal representation */ - protected function convertHexToDec(string $hex): string + protected function convertHexToDec(string $hex): string { $dec = '0'; $bitval = '1'; $len = strlen($hex); for ($pos = ($len - 1); $pos >= 0; --$pos) { - $dec = bcadd($dec, bcmul((string)hexdec($hex[$pos]), $bitval)); + $dec = bcadd($dec, bcmul((string) hexdec($hex[$pos]), $bitval)); $bitval = bcmul($bitval, '16'); } @@ -181,10 +185,9 @@ protected function convertHexToDec(string $hex): string * @param string $bar_char Character or string to use for filling bars */ public function getGridArray( - string $space_char = '0', + string $space_char = '0', string $bar_char = '1' - ): array - { + ): array { $raw = array_fill(0, $this->nrows, array_fill(0, $this->ncols, $space_char)); foreach ($this->bars as $bar) { if ($bar[2] <= 0) { @@ -211,7 +214,9 @@ public function getGridArray( protected function getRotatedBarArray(): array { $grid = $this->getGridArray(); - $cols = array_map(...[-1 => null] + $grid); + $cols = array_map(...[ + -1 => null, + ] + $grid); $bars = []; foreach ($cols as $posx => $col) { $prevrow = ''; diff --git a/src/Type/Linear/Codabar.php b/src/Type/Linear/Codabar.php index 2e5daac2..b146dd85 100644 --- a/src/Type/Linear/Codabar.php +++ b/src/Type/Linear/Codabar.php @@ -45,7 +45,28 @@ class Codabar extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = ['0' => '11111221', '1' => '11112211', '2' => '11121121', '3' => '22111111', '4' => '11211211', '5' => '21111211', '6' => '12111121', '7' => '12112111', '8' => '12211111', '9' => '21121111', '-' => '11122111', '$' => '11221111', ':' => '21112121', '/' => '21211121', '.' => '21212111', '+' => '11222221', 'A' => '11221211', 'B' => '12121121', 'C' => '11121221', 'D' => '11122211']; + protected const CHBAR = [ + '0' => '11111221', + '1' => '11112211', + '2' => '11121121', + '3' => '22111111', + '4' => '11211211', + '5' => '21111211', + '6' => '12111121', + '7' => '12112111', + '8' => '12211111', + '9' => '21121111', + '-' => '11122111', + '$' => '11221111', + ':' => '21112121', + '/' => '21211121', + '.' => '21212111', + '+' => '11222221', + 'A' => '11221211', + 'B' => '12121121', + 'C' => '11121221', + 'D' => '11122211', + ]; /** * Format code @@ -69,7 +90,7 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset($this::CHBAR[$char])) { + if (! isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index 739d9397..da50aa9f 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -47,54 +47,54 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * @var array */ protected const CHBAR = [ - 32 => '311211', // space - 36 => '321111', // $ - 37 => '211131', // % - 42 => '111141', // start-stop - 43 => '113121', // + - 45 => '121131', // - - 46 => '311112', // . - 47 => '112131', // / - 48 => '131112', // 0 - 49 => '111213', // 1 - 50 => '111312', // 2 - 51 => '111411', // 3 - 52 => '121113', // 4 - 53 => '121212', // 5 - 54 => '121311', // 6 - 55 => '111114', // 7 - 56 => '131211', // 8 - 57 => '141111', // 9 - 65 => '211113', // A - 66 => '211212', // B - 67 => '211311', // C - 68 => '221112', // D - 69 => '221211', // E - 70 => '231111', // F - 71 => '112113', // G - 72 => '112212', // H - 73 => '112311', // I - 74 => '122112', // J - 75 => '132111', // K - 76 => '111123', // L - 77 => '111222', // M - 78 => '111321', // N - 79 => '121122', // O - 80 => '131121', // P - 81 => '212112', // Q - 82 => '212211', // R - 83 => '211122', // S - 84 => '211221', // T - 85 => '221121', // U - 86 => '222111', // V - 87 => '112122', // W - 88 => '112221', // X - 89 => '122121', // Y - 90 => '123111', // Z + 32 => '311211', // space + 36 => '321111', // $ + 37 => '211131', // % + 42 => '111141', // start-stop + 43 => '113121', // + + 45 => '121131', // - + 46 => '311112', // . + 47 => '112131', // / + 48 => '131112', // 0 + 49 => '111213', // 1 + 50 => '111312', // 2 + 51 => '111411', // 3 + 52 => '121113', // 4 + 53 => '121212', // 5 + 54 => '121311', // 6 + 55 => '111114', // 7 + 56 => '131211', // 8 + 57 => '141111', // 9 + 65 => '211113', // A + 66 => '211212', // B + 67 => '211311', // C + 68 => '221112', // D + 69 => '221211', // E + 70 => '231111', // F + 71 => '112113', // G + 72 => '112212', // H + 73 => '112311', // I + 74 => '122112', // J + 75 => '132111', // K + 76 => '111123', // L + 77 => '111222', // M + 78 => '111321', // N + 79 => '121122', // O + 80 => '131121', // P + 81 => '212112', // Q + 82 => '212211', // R + 83 => '211122', // S + 84 => '211221', // T + 85 => '221121', // U + 86 => '222111', // V + 87 => '112122', // W + 88 => '112221', // X + 89 => '122121', // Y + 90 => '123111', // Z 128 => '121221', // ($) 129 => '311121', // (/) 130 => '122211', // (+) - 131 => '312111' // (%) + 131 => '312111', // (%) ]; /** diff --git a/src/Type/Linear/CodeOneOne.php b/src/Type/Linear/CodeOneOne.php index 5dc10413..c73b21a2 100644 --- a/src/Type/Linear/CodeOneOne.php +++ b/src/Type/Linear/CodeOneOne.php @@ -46,7 +46,20 @@ class CodeOneOne extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = ['0' => '111121', '1' => '211121', '2' => '121121', '3' => '221111', '4' => '112121', '5' => '212111', '6' => '122111', '7' => '111221', '8' => '211211', '9' => '211111', '-' => '112111', 'S' => '112211']; + protected const CHBAR = [ + '0' => '111121', + '1' => '211121', + '2' => '121121', + '3' => '221111', + '4' => '112121', + '5' => '212111', + '6' => '122111', + '7' => '111221', + '8' => '211211', + '9' => '211111', + '-' => '112111', + 'S' => '112211', + ]; /** * Calculate the checksum. @@ -122,7 +135,7 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset($this::CHBAR[$char])) { + if (! isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index 7af06aff..05846eaa 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -68,13 +68,12 @@ protected function getCodeData(): array * @throws BarcodeException in case of error */ protected function processSequenceA( - array &$sequence, - array &$code_data, - int &$startid, - int $key, + array &$sequence, + array &$code_data, + int &$startid, + int $key, array $seq - ): void - { + ): void { if ($key == 0) { $startid = 103; } elseif ($sequence[($key - 1)][0] != 'A') { @@ -82,18 +81,18 @@ protected function processSequenceA( ($seq[2] == 1) && ($key > 0) && ($sequence[($key - 1)][0] == 'B') - && (!isset($sequence[($key - 1)][3])) + && (! isset($sequence[($key - 1)][3])) ) { // single character shift $code_data[] = 98; // mark shift $sequence[$key][3] = true; - } elseif (!isset($sequence[($key - 1)][3])) { + } elseif (! isset($sequence[($key - 1)][3])) { $code_data[] = 101; } } - $this->getCodeDataA($code_data, $seq[1], (int)$seq[2]); + $this->getCodeDataA($code_data, $seq[1], (int) $seq[2]); } /** @@ -108,20 +107,19 @@ protected function processSequenceA( * @throws BarcodeException in case of error */ protected function processSequenceB( - array &$sequence, - array &$code_data, - int &$startid, - int $key, + array &$sequence, + array &$code_data, + int &$startid, + int $key, array $seq - ): void - { + ): void { if ($key == 0) { $this->processSequenceBA($sequence, $code_data, $startid, $key, $seq); } elseif ($sequence[($key - 1)][0] != 'B') { $this->processSequenceBB($sequence, $code_data, $key, $seq); } - $this->getCodeDataB($code_data, $seq[1], (int)$seq[2]); + $this->getCodeDataB($code_data, $seq[1], (int) $seq[2]); } /** @@ -136,13 +134,12 @@ protected function processSequenceB( * @throws BarcodeException in case of error */ protected function processSequenceBA( - array &$sequence, - array &$code_data, - int &$startid, - int $key, + array &$sequence, + array &$code_data, + int &$startid, + int $key, array $seq - ): void - { + ): void { $tmpchr = ord($seq[1][0]); if ( ($seq[2] == 1) @@ -179,23 +176,22 @@ protected function processSequenceBA( * @throws BarcodeException in case of error */ protected function processSequenceBB( - array &$sequence, - array &$code_data, - int $key, + array &$sequence, + array &$code_data, + int $key, array $seq - ): void - { + ): void { if ( ($seq[2] == 1) && ($key > 0) && ($sequence[($key - 1)][0] == 'A') - && (!isset($sequence[($key - 1)][3])) + && (! isset($sequence[($key - 1)][3])) ) { // single character shift $code_data[] = 98; // mark shift $sequence[$key][3] = true; - } elseif (!isset($sequence[($key - 1)][3])) { + } elseif (! isset($sequence[($key - 1)][3])) { $code_data[] = 100; } } @@ -212,13 +208,12 @@ protected function processSequenceBB( * @throws BarcodeException in case of error */ protected function processSequenceC( - array &$sequence, - array &$code_data, - int &$startid, - int $key, + array &$sequence, + array &$code_data, + int &$startid, + int $key, array $seq - ): void - { + ): void { if ($key == 0) { $startid = 105; } elseif ($sequence[($key - 1)][0] != 'C') { diff --git a/src/Type/Linear/CodeOneTwoEight/Process.php b/src/Type/Linear/CodeOneTwoEight/Process.php index 612faddb271fe44a3481eec0cd121896b83e135d..0391e6cc5c66adea649ae80ff54f87f99a3d2695 100644 GIT binary patch delta 327 zcmZojTAZ|Dho~=?0u&gT7%JG>DHs|U=^%+2fy6A$k%f%GLT1Q9CJ>#5lV=LaPW~-g z9E@ZF#iklSY??evtZ1@@y6@x!@t=$enmP@`7_LuuV{*I{;lN6IQg@ds2svw znRz7&DmkfnV8>`$DU{`BrfhCh(PSn<-Q-4G|FiIXPzvhFU0{ANGvK! LtlaFTzl#w7I-^ZV delta 307 zcmZ3S)R44chp3K`iJ^k6or0l(k&c3qi4llxX%1o)1%g;;!DcihXMU$B%9h3K~+}!*{! */ - protected const CHBAR = ['0' => '111331311', '1' => '311311113', '2' => '113311113', '3' => '313311111', '4' => '111331113', '5' => '311331111', '6' => '113331111', '7' => '111311313', '8' => '311311311', '9' => '113311311', 'A' => '311113113', 'B' => '113113113', 'C' => '313113111', 'D' => '111133113', 'E' => '311133111', 'F' => '113133111', 'G' => '111113313', 'H' => '311113311', 'I' => '113113311', 'J' => '111133311', 'K' => '311111133', 'L' => '113111133', 'M' => '313111131', 'N' => '111131133', 'O' => '311131131', 'P' => '113131131', 'Q' => '111111333', 'R' => '311111331', 'S' => '113111331', 'T' => '111131331', 'U' => '331111113', 'V' => '133111113', 'W' => '333111111', 'X' => '131131113', 'Y' => '331131111', 'Z' => '133131111', '-' => '131111313', '.' => '331111311', ' ' => '133111311', '$' => '131313111', '/' => '131311131', '+' => '131113131', '%' => '111313131', '*' => '131131311']; + protected const CHBAR = [ + '0' => '111331311', + '1' => '311311113', + '2' => '113311113', + '3' => '313311111', + '4' => '111331113', + '5' => '311331111', + '6' => '113331111', + '7' => '111311313', + '8' => '311311311', + '9' => '113311311', + 'A' => '311113113', + 'B' => '113113113', + 'C' => '313113111', + 'D' => '111133113', + 'E' => '311133111', + 'F' => '113133111', + 'G' => '111113313', + 'H' => '311113311', + 'I' => '113113311', + 'J' => '111133311', + 'K' => '311111133', + 'L' => '113111133', + 'M' => '313111131', + 'N' => '111131133', + 'O' => '311131131', + 'P' => '113131131', + 'Q' => '111111333', + 'R' => '311111331', + 'S' => '113111331', + 'T' => '111131331', + 'U' => '331111113', + 'V' => '133111113', + 'W' => '333111111', + 'X' => '131131113', + 'Y' => '331131111', + 'Z' => '133131111', + '-' => '131111313', + '.' => '331111311', + ' ' => '133111311', + '$' => '131313111', + '/' => '131311131', + '+' => '131113131', + '%' => '111313131', + '*' => '131131311', + ]; /** * Map for extended characters @@ -67,7 +112,6 @@ class CodeThreeNineExtCheck extends \Com\Tecnick\Barcode\Type\Linear * * @param string $code Code to extend * - * * @throws BarcodeException in case of error */ protected function getExtendCode(string $code): string @@ -129,7 +173,7 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset($this::CHBAR[$char])) { + if (! isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } diff --git a/src/Type/Linear/EanFive.php b/src/Type/Linear/EanFive.php index 6aaec5de..0b4aad5c 100644 --- a/src/Type/Linear/EanFive.php +++ b/src/Type/Linear/EanFive.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Linear; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Linear\EanFive; * @@ -51,7 +49,18 @@ class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo * * @var array> */ - protected const PARITIES = ['0' => ['B', 'B', 'A', 'A', 'A'], '1' => ['B', 'A', 'B', 'A', 'A'], '2' => ['B', 'A', 'A', 'B', 'A'], '3' => ['B', 'A', 'A', 'A', 'B'], '4' => ['A', 'B', 'B', 'A', 'A'], '5' => ['A', 'A', 'B', 'B', 'A'], '6' => ['A', 'A', 'A', 'B', 'B'], '7' => ['A', 'B', 'A', 'B', 'A'], '8' => ['A', 'B', 'A', 'A', 'B'], '9' => ['A', 'A', 'B', 'A', 'B']]; + protected const PARITIES = [ + '0' => ['B', 'B', 'A', 'A', 'A'], + '1' => ['B', 'A', 'B', 'A', 'A'], + '2' => ['B', 'A', 'A', 'B', 'A'], + '3' => ['B', 'A', 'A', 'A', 'B'], + '4' => ['A', 'B', 'B', 'A', 'A'], + '5' => ['A', 'A', 'B', 'B', 'A'], + '6' => ['A', 'A', 'A', 'B', 'B'], + '7' => ['A', 'B', 'A', 'B', 'A'], + '8' => ['A', 'B', 'A', 'A', 'B'], + '9' => ['A', 'A', 'B', 'A', 'B'], + ]; /** * Calculate checksum diff --git a/src/Type/Linear/EanOneThree.php b/src/Type/Linear/EanOneThree.php index a16f0708..67bb7cdb 100644 --- a/src/Type/Linear/EanOneThree.php +++ b/src/Type/Linear/EanOneThree.php @@ -56,50 +56,65 @@ class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear * * @var array> */ - protected const CHBAR = ['A' => [ - // left odd parity - '0' => '0001101', - '1' => '0011001', - '2' => '0010011', - '3' => '0111101', - '4' => '0100011', - '5' => '0110001', - '6' => '0101111', - '7' => '0111011', - '8' => '0110111', - '9' => '0001011', - ], 'B' => [ - // left even parity - '0' => '0100111', - '1' => '0110011', - '2' => '0011011', - '3' => '0100001', - '4' => '0011101', - '5' => '0111001', - '6' => '0000101', - '7' => '0010001', - '8' => '0001001', - '9' => '0010111', - ], 'C' => [ - // right - '0' => '1110010', - '1' => '1100110', - '2' => '1101100', - '3' => '1000010', - '4' => '1011100', - '5' => '1001110', - '6' => '1010000', - '7' => '1000100', - '8' => '1001000', - '9' => '1110100', - ]]; + protected const CHBAR = [ + 'A' => [ + // left odd parity + '0' => '0001101', + '1' => '0011001', + '2' => '0010011', + '3' => '0111101', + '4' => '0100011', + '5' => '0110001', + '6' => '0101111', + '7' => '0111011', + '8' => '0110111', + '9' => '0001011', + ], + 'B' => [ + // left even parity + '0' => '0100111', + '1' => '0110011', + '2' => '0011011', + '3' => '0100001', + '4' => '0011101', + '5' => '0111001', + '6' => '0000101', + '7' => '0010001', + '8' => '0001001', + '9' => '0010111', + ], + 'C' => [ + // right + '0' => '1110010', + '1' => '1100110', + '2' => '1101100', + '3' => '1000010', + '4' => '1011100', + '5' => '1001110', + '6' => '1010000', + '7' => '1000100', + '8' => '1001000', + '9' => '1110100', + ], + ]; /** * Map parities * * @var array */ - protected const PARITIES = ['0' => 'AAAAAA', '1' => 'AABABB', '2' => 'AABBAB', '3' => 'AABBBA', '4' => 'ABAABB', '5' => 'ABBAAB', '6' => 'ABBBAA', '7' => 'ABABAB', '8' => 'ABABBA', '9' => 'ABBABA']; + protected const PARITIES = [ + '0' => 'AAAAAA', + '1' => 'AABABB', + '2' => 'AABBAB', + '3' => 'AABBBA', + '4' => 'ABAABB', + '5' => 'ABBAAB', + '6' => 'ABBBAA', + '7' => 'ABABAB', + '8' => 'ABABBA', + '9' => 'ABBABA', + ]; /** * Calculate checksum @@ -166,7 +181,7 @@ protected function formatCode(): void */ protected function setBars(): void { - if (!is_numeric($this->code)) { + if (! is_numeric($this->code)) { throw new BarcodeException('Input code must be a number'); } diff --git a/src/Type/Linear/EanTwo.php b/src/Type/Linear/EanTwo.php index a95ba4b8..d2328e01 100644 --- a/src/Type/Linear/EanTwo.php +++ b/src/Type/Linear/EanTwo.php @@ -51,38 +51,46 @@ class EanTwo extends \Com\Tecnick\Barcode\Type\Linear * * @var array> */ - protected const CHBAR = ['A' => [ - // left odd parity - '0' => '0001101', - '1' => '0011001', - '2' => '0010011', - '3' => '0111101', - '4' => '0100011', - '5' => '0110001', - '6' => '0101111', - '7' => '0111011', - '8' => '0110111', - '9' => '0001011', - ], 'B' => [ - // left even parity - '0' => '0100111', - '1' => '0110011', - '2' => '0011011', - '3' => '0100001', - '4' => '0011101', - '5' => '0111001', - '6' => '0000101', - '7' => '0010001', - '8' => '0001001', - '9' => '0010111', - ]]; + protected const CHBAR = [ + 'A' => [ + // left odd parity + '0' => '0001101', + '1' => '0011001', + '2' => '0010011', + '3' => '0111101', + '4' => '0100011', + '5' => '0110001', + '6' => '0101111', + '7' => '0111011', + '8' => '0110111', + '9' => '0001011', + ], + 'B' => [ + // left even parity + '0' => '0100111', + '1' => '0110011', + '2' => '0011011', + '3' => '0100001', + '4' => '0011101', + '5' => '0111001', + '6' => '0000101', + '7' => '0010001', + '8' => '0001001', + '9' => '0010111', + ], + ]; /** * Map parities * * @var array> */ - protected const PARITIES = ['0' => ['A', 'A'], '1' => ['A', 'B'], '2' => ['B', 'A'], '3' => ['B', 'B']]; + protected const PARITIES = [ + '0' => ['A', 'A'], + '1' => ['A', 'B'], + '2' => ['B', 'A'], + '3' => ['B', 'B'], + ]; /** * Calculate checksum diff --git a/src/Type/Linear/Imb.php b/src/Type/Linear/Imb.php index ad71b615..e74c8aeb 100644 --- a/src/Type/Linear/Imb.php +++ b/src/Type/Linear/Imb.php @@ -191,7 +191,6 @@ protected function getTables(int $type, int $size): array * * @param string $routing_code the routing code * - * * @throws BarcodeException in case of error */ protected function getRoutingCode(string $routing_code): string @@ -209,7 +208,6 @@ protected function getRoutingCode(string $routing_code): string /** * Get the processed array of characters * - * * @throws BarcodeException in case of error */ protected function getCharsArray(): array @@ -268,7 +266,7 @@ protected function getCharsArray(): array if (($fcs & $bitmask) > 0) { // bitwise invert - $chrcode = ((~(int)$chrcode) & 8191); + $chrcode = ((~(int) $chrcode) & 8191); } $characters[] = $chrcode; diff --git a/src/Type/Linear/InterleavedTwoOfFive.php b/src/Type/Linear/InterleavedTwoOfFive.php index 0c76e0e1..346d2e08 100644 --- a/src/Type/Linear/InterleavedTwoOfFive.php +++ b/src/Type/Linear/InterleavedTwoOfFive.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Linear; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Linear\InterleavedTwoOfFive; * diff --git a/src/Type/Linear/InterleavedTwoOfFiveCheck.php b/src/Type/Linear/InterleavedTwoOfFiveCheck.php index de2a2c36..c52eadb3 100644 --- a/src/Type/Linear/InterleavedTwoOfFiveCheck.php +++ b/src/Type/Linear/InterleavedTwoOfFiveCheck.php @@ -46,7 +46,20 @@ class InterleavedTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear\Standar * * @var array */ - protected const CHBAR= ['0' => '11221', '1' => '21112', '2' => '12112', '3' => '22111', '4' => '11212', '5' => '21211', '6' => '12211', '7' => '11122', '8' => '21121', '9' => '12121', 'A' => '11', 'Z' => '21']; + protected const CHBAR = [ + '0' => '11221', + '1' => '21112', + '2' => '12112', + '3' => '22111', + '4' => '11212', + '5' => '21211', + '6' => '12211', + '7' => '11122', + '8' => '21121', + '9' => '12121', + 'A' => '11', + 'Z' => '21', + ]; /** * Format code @@ -78,7 +91,7 @@ protected function setBars(): void for ($idx = 0; $idx < $clen; $idx += 2) { $char_bar = $this->extcode[$idx]; $char_space = $this->extcode[($idx + 1)]; - if ((!isset($this::CHBAR[$char_bar])) || (!isset($this::CHBAR[$char_space]))) { + if ((! isset($this::CHBAR[$char_bar])) || (! isset($this::CHBAR[$char_space]))) { throw new BarcodeException('Invalid character sequence: ' . $char_bar . $char_space); } diff --git a/src/Type/Linear/Msi.php b/src/Type/Linear/Msi.php index 0f3fc9e4..335f251d 100644 --- a/src/Type/Linear/Msi.php +++ b/src/Type/Linear/Msi.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Linear; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Linear\Msi; * diff --git a/src/Type/Linear/MsiCheck.php b/src/Type/Linear/MsiCheck.php index 2068da5c..733e956f 100644 --- a/src/Type/Linear/MsiCheck.php +++ b/src/Type/Linear/MsiCheck.php @@ -46,7 +46,24 @@ class MsiCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = ['0' => '100100100100', '1' => '100100100110', '2' => '100100110100', '3' => '100100110110', '4' => '100110100100', '5' => '100110100110', '6' => '100110110100', '7' => '100110110110', '8' => '110100100100', '9' => '110100100110', 'A' => '110100110100', 'B' => '110100110110', 'C' => '110110100100', 'D' => '110110100110', 'E' => '110110110100', 'F' => '110110110110']; + protected const CHBAR = [ + '0' => '100100100100', + '1' => '100100100110', + '2' => '100100110100', + '3' => '100100110110', + '4' => '100110100100', + '5' => '100110100110', + '6' => '100110110100', + '7' => '100110110110', + '8' => '110100100100', + '9' => '110100100110', + 'A' => '110100110100', + 'B' => '110100110110', + 'C' => '110110100100', + 'D' => '110110100110', + 'E' => '110110110100', + 'F' => '110110110110', + ]; /** * Calculate the checksum @@ -62,7 +79,7 @@ protected function getChecksum(string $code): int $check = 0; for ($pos = ($clen - 1); $pos >= 0; --$pos) { $hex = $code[$pos]; - if (!ctype_xdigit($hex)) { + if (! ctype_xdigit($hex)) { continue; } @@ -101,7 +118,7 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($pos = 0; $pos < $clen; ++$pos) { $digit = $this->extcode[$pos]; - if (!isset($this::CHBAR[$digit])) { + if (! isset($this::CHBAR[$digit])) { throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')'); } diff --git a/src/Type/Linear/Planet.php b/src/Type/Linear/Planet.php index 3f46d420..f7eaaf85 100644 --- a/src/Type/Linear/Planet.php +++ b/src/Type/Linear/Planet.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Linear; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Linear\Planet; * @@ -46,5 +44,16 @@ class Planet extends \Com\Tecnick\Barcode\Type\Linear\Postnet * * @var array */ - protected const CHBAR = ['0' => '11222', '1' => '22211', '2' => '22121', '3' => '22112', '4' => '21221', '5' => '21212', '6' => '21122', '7' => '12221', '8' => '12212', '9' => '12122']; + protected const CHBAR = [ + '0' => '11222', + '1' => '22211', + '2' => '22121', + '3' => '22112', + '4' => '21221', + '5' => '21212', + '6' => '21122', + '7' => '12221', + '8' => '12212', + '9' => '12122', + ]; } diff --git a/src/Type/Linear/Postnet.php b/src/Type/Linear/Postnet.php index 0e5592da..045cc0a9 100644 --- a/src/Type/Linear/Postnet.php +++ b/src/Type/Linear/Postnet.php @@ -46,7 +46,18 @@ class Postnet extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = ['0' => '22111', '1' => '11122', '2' => '11212', '3' => '11221', '4' => '12112', '5' => '12121', '6' => '12211', '7' => '21112', '8' => '21121', '9' => '21211']; + protected const CHBAR = [ + '0' => '22111', + '1' => '11122', + '2' => '11212', + '3' => '11221', + '4' => '12112', + '5' => '12121', + '6' => '12211', + '7' => '21112', + '8' => '21121', + '9' => '21211', + ]; /** * Calculate the checksum. @@ -97,7 +108,7 @@ protected function setBars(): void $this->ncols += 2; for ($chr = 0; $chr < $clen; ++$chr) { $char = $this->extcode[$chr]; - if (!isset($this::CHBAR[$char])) { + if (! isset($this::CHBAR[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } diff --git a/src/Type/Linear/Raw.php b/src/Type/Linear/Raw.php index f89b3b0c..d6da6642 100644 --- a/src/Type/Linear/Raw.php +++ b/src/Type/Linear/Raw.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Linear; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Linear\Raw * diff --git a/src/Type/Linear/RoyalMailFourCc.php b/src/Type/Linear/RoyalMailFourCc.php index 0bb0d7ce..88bef0dd 100644 --- a/src/Type/Linear/RoyalMailFourCc.php +++ b/src/Type/Linear/RoyalMailFourCc.php @@ -46,14 +46,88 @@ class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = ['0' => '3322', '1' => '3412', '2' => '3421', '3' => '4312', '4' => '4321', '5' => '4411', '6' => '3142', '7' => '3232', '8' => '3241', '9' => '4132', 'A' => '4141', 'B' => '4231', 'C' => '3124', 'D' => '3214', 'E' => '3223', 'F' => '4114', 'G' => '4123', 'H' => '4213', 'I' => '1342', 'J' => '1432', 'K' => '1441', 'L' => '2332', 'M' => '2341', 'N' => '2431', 'O' => '1324', 'P' => '1414', 'Q' => '1423', 'R' => '2314', 'S' => '2323', 'T' => '2413', 'U' => '1144', 'V' => '1234', 'W' => '1243', 'X' => '2134', 'Y' => '2143', 'Z' => '2233']; + protected const CHBAR = [ + '0' => '3322', + '1' => '3412', + '2' => '3421', + '3' => '4312', + '4' => '4321', + '5' => '4411', + '6' => '3142', + '7' => '3232', + '8' => '3241', + '9' => '4132', + 'A' => '4141', + 'B' => '4231', + 'C' => '3124', + 'D' => '3214', + 'E' => '3223', + 'F' => '4114', + 'G' => '4123', + 'H' => '4213', + 'I' => '1342', + 'J' => '1432', + 'K' => '1441', + 'L' => '2332', + 'M' => '2341', + 'N' => '2431', + 'O' => '1324', + 'P' => '1414', + 'Q' => '1423', + 'R' => '2314', + 'S' => '2323', + 'T' => '2413', + 'U' => '1144', + 'V' => '1234', + 'W' => '1243', + 'X' => '2134', + 'Y' => '2143', + 'Z' => '2233', + ]; /** * Characters used for checksum * * @var array */ - protected const CHKSUM= ['0' => '11', '1' => '12', '2' => '13', '3' => '14', '4' => '15', '5' => '10', '6' => '21', '7' => '22', '8' => '23', '9' => '24', 'A' => '25', 'B' => '20', 'C' => '31', 'D' => '32', 'E' => '33', 'F' => '34', 'G' => '35', 'H' => '30', 'I' => '41', 'J' => '42', 'K' => '43', 'L' => '44', 'M' => '45', 'N' => '40', 'O' => '51', 'P' => '52', 'Q' => '53', 'R' => '54', 'S' => '55', 'T' => '50', 'U' => '01', 'V' => '02', 'W' => '03', 'X' => '04', 'Y' => '05', 'Z' => '00']; + protected const CHKSUM = [ + '0' => '11', + '1' => '12', + '2' => '13', + '3' => '14', + '4' => '15', + '5' => '10', + '6' => '21', + '7' => '22', + '8' => '23', + '9' => '24', + 'A' => '25', + 'B' => '20', + 'C' => '31', + 'D' => '32', + 'E' => '33', + 'F' => '34', + 'G' => '35', + 'H' => '30', + 'I' => '41', + 'J' => '42', + 'K' => '43', + 'L' => '44', + 'M' => '45', + 'N' => '40', + 'O' => '51', + 'P' => '52', + 'Q' => '53', + 'R' => '54', + 'S' => '55', + 'T' => '50', + 'U' => '01', + 'V' => '02', + 'W' => '03', + 'X' => '04', + 'Y' => '05', + 'Z' => '00', + ]; /** * Calculate the checksum. @@ -71,7 +145,7 @@ protected function getChecksum(string $code): int $len = strlen($code); for ($pos = 0; $pos < $len; ++$pos) { $char = $code[$pos]; - if (!isset($this::CHKSUM[$char])) { + if (! isset($this::CHKSUM[$char])) { throw new BarcodeException('Invalid character: chr(' . ord($char) . ')'); } diff --git a/src/Type/Linear/StandardTwoOfFive.php b/src/Type/Linear/StandardTwoOfFive.php index 2e0e8213..9ce9d02f 100644 --- a/src/Type/Linear/StandardTwoOfFive.php +++ b/src/Type/Linear/StandardTwoOfFive.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Linear; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFive; * diff --git a/src/Type/Linear/StandardTwoOfFiveCheck.php b/src/Type/Linear/StandardTwoOfFiveCheck.php index 91628baf..0b836902 100644 --- a/src/Type/Linear/StandardTwoOfFiveCheck.php +++ b/src/Type/Linear/StandardTwoOfFiveCheck.php @@ -46,7 +46,18 @@ class StandardTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const CHBAR = ['0' => '10101110111010', '1' => '11101010101110', '2' => '10111010101110', '3' => '11101110101010', '4' => '10101110101110', '5' => '11101011101010', '6' => '10111011101010', '7' => '10101011101110', '8' => '11101010111010', '9' => '10111010111010']; + protected const CHBAR = [ + '0' => '10101110111010', + '1' => '11101010101110', + '2' => '10111010101110', + '3' => '11101110101010', + '4' => '10101110101110', + '5' => '11101011101010', + '6' => '10111011101010', + '7' => '10101011101110', + '8' => '11101010111010', + '9' => '10111010111010', + ]; /** * Calculate the checksum @@ -101,7 +112,7 @@ protected function setBars(): void $clen = strlen($this->extcode); for ($idx = 0; $idx < $clen; ++$idx) { $digit = $this->extcode[$idx]; - if (!isset($this::CHBAR[$digit])) { + if (! isset($this::CHBAR[$digit])) { throw new BarcodeException('Invalid character: chr(' . ord($digit) . ')'); } diff --git a/src/Type/Linear/UpcA.php b/src/Type/Linear/UpcA.php index 2f886469..fae3e8fb 100644 --- a/src/Type/Linear/UpcA.php +++ b/src/Type/Linear/UpcA.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Linear; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Linear\UpcA; * diff --git a/src/Type/Linear/UpcE.php b/src/Type/Linear/UpcE.php index 12d8e42e..ebad535f 100644 --- a/src/Type/Linear/UpcE.php +++ b/src/Type/Linear/UpcE.php @@ -55,7 +55,32 @@ class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA * * @var array>> */ - protected const PARITIES = [0 => ['0' => ['B', 'B', 'B', 'A', 'A', 'A'], '1' => ['B', 'B', 'A', 'B', 'A', 'A'], '2' => ['B', 'B', 'A', 'A', 'B', 'A'], '3' => ['B', 'B', 'A', 'A', 'A', 'B'], '4' => ['B', 'A', 'B', 'B', 'A', 'A'], '5' => ['B', 'A', 'A', 'B', 'B', 'A'], '6' => ['B', 'A', 'A', 'A', 'B', 'B'], '7' => ['B', 'A', 'B', 'A', 'B', 'A'], '8' => ['B', 'A', 'B', 'A', 'A', 'B'], '9' => ['B', 'A', 'A', 'B', 'A', 'B']], 1 => ['0' => ['A', 'A', 'A', 'B', 'B', 'B'], '1' => ['A', 'A', 'B', 'A', 'B', 'B'], '2' => ['A', 'A', 'B', 'B', 'A', 'B'], '3' => ['A', 'A', 'B', 'B', 'B', 'A'], '4' => ['A', 'B', 'A', 'A', 'B', 'B'], '5' => ['A', 'B', 'B', 'A', 'A', 'B'], '6' => ['A', 'B', 'B', 'B', 'A', 'A'], '7' => ['A', 'B', 'A', 'B', 'A', 'B'], '8' => ['A', 'B', 'A', 'B', 'B', 'A'], '9' => ['A', 'B', 'B', 'A', 'B', 'A']]]; + protected const PARITIES = [ + 0 => [ + '0' => ['B', 'B', 'B', 'A', 'A', 'A'], + '1' => ['B', 'B', 'A', 'B', 'A', 'A'], + '2' => ['B', 'B', 'A', 'A', 'B', 'A'], + '3' => ['B', 'B', 'A', 'A', 'A', 'B'], + '4' => ['B', 'A', 'B', 'B', 'A', 'A'], + '5' => ['B', 'A', 'A', 'B', 'B', 'A'], + '6' => ['B', 'A', 'A', 'A', 'B', 'B'], + '7' => ['B', 'A', 'B', 'A', 'B', 'A'], + '8' => ['B', 'A', 'B', 'A', 'A', 'B'], + '9' => ['B', 'A', 'A', 'B', 'A', 'B'], + ], + 1 => [ + '0' => ['A', 'A', 'A', 'B', 'B', 'B'], + '1' => ['A', 'A', 'B', 'A', 'B', 'B'], + '2' => ['A', 'A', 'B', 'B', 'A', 'B'], + '3' => ['A', 'A', 'B', 'B', 'B', 'A'], + '4' => ['A', 'B', 'A', 'A', 'B', 'B'], + '5' => ['A', 'B', 'B', 'A', 'A', 'B'], + '6' => ['A', 'B', 'B', 'B', 'A', 'A'], + '7' => ['A', 'B', 'A', 'B', 'A', 'B'], + '8' => ['A', 'B', 'A', 'B', 'B', 'A'], + '9' => ['A', 'B', 'B', 'A', 'B', 'A'], + ], + ]; /** * Convert UPC-E code to UPC-A diff --git a/src/Type/Raw.php b/src/Type/Raw.php index 9f4b7227..80f3bc75 100644 --- a/src/Type/Raw.php +++ b/src/Type/Raw.php @@ -74,7 +74,7 @@ protected function setBars(): void $this->bars = []; foreach ($rows as $posy => $row) { - if (!is_array($row)) { + if (! is_array($row)) { $row = str_split($row, 1); } diff --git a/src/Type/Square/Aztec.php b/src/Type/Square/Aztec.php index 5da98d56..4f6359d0 100644 --- a/src/Type/Square/Aztec.php +++ b/src/Type/Square/Aztec.php @@ -16,9 +16,9 @@ namespace Com\Tecnick\Barcode\Type\Square; +use Com\Tecnick\Barcode\Exception as BarcodeException; use Com\Tecnick\Barcode\Type\Square\Aztec\Data; use Com\Tecnick\Barcode\Type\Square\Aztec\Encode; -use Com\Tecnick\Barcode\Exception as BarcodeException; /** * Com\Tecnick\Barcode\Type\Square\Aztec @@ -81,28 +81,28 @@ protected function setParameters(): void parent::setParameters(); // ecc percentage - if (!isset($this->params[0]) || !in_array($this->params[0], range(1, 100))) { + if (! isset($this->params[0]) || ! in_array($this->params[0], range(1, 100))) { $this->params[0] = 33; } $this->ecc = (int) $this->params[0]; // hint - if (!isset($this->params[1]) || !in_array($this->params[1], ['A', 'B'])) { + if (! isset($this->params[1]) || ! in_array($this->params[1], ['A', 'B'])) { $this->params[1] = 'A'; } $this->hint = $this->params[1]; // mode - if (!isset($this->params[2]) || !in_array($this->params[2], ['A', 'F'])) { + if (! isset($this->params[2]) || ! in_array($this->params[2], ['A', 'F'])) { $this->params[2] = 'A'; } $this->mode = $this->params[2]; // eci code. Used to set the charset encoding. See $this->eci. - if (!isset($this->params[3]) || !array_key_exists($this->params[3], Data::ECI)) { + if (! isset($this->params[3]) || ! array_key_exists($this->params[3], Data::ECI)) { $this->params[3] = -1; } @@ -116,7 +116,7 @@ protected function setParameters(): void */ protected function setBars(): void { - if (strlen((string)$this->code) == 0) { + if (strlen((string) $this->code) == 0) { throw new BarcodeException('Empty input'); } diff --git a/src/Type/Square/Aztec/Bitstream.php b/src/Type/Square/Aztec/Bitstream.php index adeb4207..4083992e 100644 --- a/src/Type/Square/Aztec/Bitstream.php +++ b/src/Type/Square/Aztec/Bitstream.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Aztec; -use Com\Tecnick\Barcode\Type\Square\Aztec\Data; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream * @@ -36,7 +33,7 @@ */ abstract class Bitstream extends \Com\Tecnick\Barcode\Type\Square\Aztec\Layers { - /** + /** * Performs the high-level encoding for the given code and ECI mode. * * @param string $code The code to encode. @@ -44,11 +41,10 @@ abstract class Bitstream extends \Com\Tecnick\Barcode\Type\Square\Aztec\Layers * @param string $hint The mode to use. */ protected function highLevelEncoding( - string $code, - int $eci = 0, + string $code, + int $eci = 0, string $hint = 'A' - ): void - { + ): void { $this->addFLG($eci); $chars = array_values(unpack('C*', $code)); $chrlen = count($chars); @@ -157,19 +153,18 @@ protected function processModeChars(array &$chars, int &$idx, int $chrlen): void * @param int $mode The current mode. */ protected function countModeChars( - array &$chars, - int $idx, - int $chrlen, + array &$chars, + int $idx, + int $chrlen, int $mode - ): int - { + ): int { $this->tmpCdws = []; $nbits = Data::MODE_BITS[$mode]; $count = 0; do { $ord = $chars[$idx]; if ( - (!$this->isSameMode($mode, $ord)) + (! $this->isSameMode($mode, $ord)) || (($idx < ($chrlen - 1)) && ($this->punctPairMode($ord, $chars[($idx + 1)]) > 0)) ) { return $count; @@ -193,11 +188,10 @@ protected function countModeChars( * @return bool True if binary characters have been found and processed. */ protected function processBinaryChars( - array &$chars, - int &$idx, + array &$chars, + int &$idx, int $chrlen - ): bool - { + ): bool { $binchrs = $this->countBinaryChars($chars, $idx, $chrlen); if ($binchrs == 0) { return false; @@ -246,15 +240,13 @@ protected function processBinaryChars( * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. * - * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function countBinaryChars( - array &$chars, - int $idx, + array &$chars, + int $idx, int $chrlen - ): int - { + ): int { $this->tmpCdws = []; $count = 0; $nbits = Data::MODE_BITS[Data::MODE_BINARY]; @@ -284,12 +276,10 @@ protected function countBinaryChars( * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function processPunctPairs( - array &$chars, - int &$idx, + array &$chars, + int &$idx, int $chrlen - ): bool - { - + ): bool { $ppairs = $this->countPunctPairs($chars, $idx, $chrlen); if ($ppairs == 0) { return false; @@ -338,11 +328,10 @@ protected function processPunctPairs( * @param int $chrlen The total number of characters to process. */ protected function countPunctPairs( - array &$chars, - int $idx, + array &$chars, + int $idx, int $chrlen - ): int - { + ): int { $this->tmpCdws = []; $pairs = 0; $maxidx = $chrlen - 1; @@ -372,12 +361,11 @@ protected function countPunctAndDigitChars( array &$chars, int $idx, int $chrlen - ): array - { + ): array { $words = []; while ($idx < $chrlen) { $ord = $chars[$idx]; - if (!$this->isPunctAndDigitChar($ord)) { + if (! $this->isPunctAndDigitChar($ord)) { return $words; } diff --git a/src/Type/Square/Aztec/Codeword.php b/src/Type/Square/Aztec/Codeword.php index 2ce0c0d0..73097917 100644 --- a/src/Type/Square/Aztec/Codeword.php +++ b/src/Type/Square/Aztec/Codeword.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Aztec; -use Com\Tecnick\Barcode\Type\Square\Aztec\Data; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\Aztec\Codeword * @@ -140,12 +137,11 @@ protected function punctPairMode(int $ord, int $next): int * @param int $value The value of the codeword. */ protected function appendWordToBitstream( - array &$bitstream, - int &$totbits, - int $wsize, + array &$bitstream, + int &$totbits, + int $wsize, int $value - ): VOID - { + ): void { for ($idx = ($wsize - 1); $idx >= 0; --$idx) { $bitstream[] = (($value >> $idx) & 1); } @@ -161,18 +157,17 @@ protected function appendWordToBitstream( * @param int $wsize The word size. */ protected function bitstreamToWords( - array $bitstream, - int $totbits, + array $bitstream, + int $totbits, int $wsize - ): array - { + ): array { $words = []; $numwords = (int) ceil($totbits / $wsize); for ($idx = 0; $idx < $numwords; ++$idx) { $wrd = 0; for ($bit = 0; $bit < $wsize; ++$bit) { $pos = (($idx * $wsize) + $bit); - if (!empty($bitstream[$pos]) || !isset($bitstream[$pos])) { + if (! empty($bitstream[$pos]) || ! isset($bitstream[$pos])) { $wrd |= (1 << ($wsize - $bit - 1)); // reverse order } } @@ -293,7 +288,7 @@ protected function addFLG(int $eci): void return; } - $seci = (string)$eci; + $seci = (string) $eci; $digits = strlen($seci); $this->addRawCwd(3, $digits); // 1–6 digits for ($idx = 0; $idx < $digits; ++$idx) { diff --git a/src/Type/Square/Aztec/Data.php b/src/Type/Square/Aztec/Data.php index 70aa111a..e03289a4 100644 --- a/src/Type/Square/Aztec/Data.php +++ b/src/Type/Square/Aztec/Data.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Aztec; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\Aztec\Data * @@ -86,23 +84,23 @@ class Data public const CHAR_ENC = [ // MODE_UPPER (initial mode) 0 => [ - 32 => 1, + 32 => 1, // ' ' (SP) - 65 => 2, + 65 => 2, // 'A' - 66 => 3, + 66 => 3, // 'B' - 67 => 4, + 67 => 4, // 'C' - 68 => 5, + 68 => 5, // 'D' - 69 => 6, + 69 => 6, // 'E' - 70 => 7, + 70 => 7, // 'F' - 71 => 8, + 71 => 8, // 'G' - 72 => 9, + 72 => 9, // 'H' 73 => 10, // 'I' @@ -142,23 +140,23 @@ class Data ], // MODE_LOWER 1 => [ - 32 => 1, + 32 => 1, // ' ' (SP) - 97 => 2, + 97 => 2, // 'a' - 98 => 3, + 98 => 3, // 'b' - 99 => 4, + 99 => 4, // 'c' - 100 => 5, + 100 => 5, // 'd' - 101 => 6, + 101 => 6, // 'e' - 102 => 7, + 102 => 7, // 'f' - 103 => 8, + 103 => 8, // 'g' - 104 => 9, + 104 => 9, // 'h' 105 => 10, // 'i' @@ -198,27 +196,27 @@ class Data ], // MODE_DIGIT 2 => [ - 32 => 1, + 32 => 1, // ' ' (SP) 44 => 12, // ',' 46 => 13, // '.' - 48 => 2, + 48 => 2, // '0' - 49 => 3, + 49 => 3, // '1' - 50 => 4, + 50 => 4, // '2' - 51 => 5, + 51 => 5, // '3' - 52 => 6, + 52 => 6, // '4' - 53 => 7, + 53 => 7, // '5' - 54 => 8, + 54 => 8, // '6' - 55 => 9, + 55 => 9, // '7' 56 => 10, // '8' @@ -226,21 +224,21 @@ class Data ], // MODE_MIXED 3 => [ - 1 => 2, + 1 => 2, // '^A' (SOH) - 2 => 3, + 2 => 3, // '^B' (STX) - 3 => 4, + 3 => 4, // '^C' (ETX) - 4 => 5, + 4 => 5, // '^D' (EOT) - 5 => 6, + 5 => 6, // '^E' (ENQ) - 6 => 7, + 6 => 7, // '^F' (ACK) - 7 => 8, + 7 => 8, // '^G' (BEL) - 8 => 9, + 8 => 9, // '^H' (BS) 9 => 10, // '^I' (HT) @@ -280,15 +278,15 @@ class Data ], // MODE_PUNCT 4 => [ - 13 => 1, + 13 => 1, // '\r' (CR) - 33 => 6, + 33 => 6, // '!' - 34 => 7, + 34 => 7, // '"' - 35 => 8, + 35 => 8, // '#' - 36 => 9, + 36 => 9, // '$' 37 => 10, // '%' @@ -674,7 +672,13 @@ class Data 5 => [[5, 31]], ], // MODE_PUNCT - 4 => [0 => [], 1 => [], 2 => [], 3 => [], 5 => [[5, 31], [5, 31]]], + 4 => [ + 0 => [], + 1 => [], + 2 => [], + 3 => [], + 5 => [[5, 31], [5, 31]], + ], ]; /** @@ -749,7 +753,12 @@ class Data * - 5: symbol data text capacity; * - 6: symbol data bytes capacity. */ - public const SIZE_COMPACT = [1 => [15, 17, 6, 102, 13, 12, 6], 2 => [19, 40, 6, 240, 40, 33, 19], 3 => [23, 51, 8, 408, 70, 57, 33], 4 => [27, 76, 8, 608, 110, 89, 53]]; + public const SIZE_COMPACT = [ + 1 => [15, 17, 6, 102, 13, 12, 6], + 2 => [19, 40, 6, 240, 40, 33, 19], + 3 => [23, 51, 8, 408, 70, 57, 33], + 4 => [27, 76, 8, 608, 110, 89, 53], + ]; /** * Size and capacities of Aztec Full-range Code symbols by number of layers. @@ -762,5 +771,38 @@ class Data * - 5: symbol data text capacity; * - 6: symbol data bytes capacity. */ - public const SIZE_FULL = [1 => [19, 21, 6, 126, 18, 15, 8], 2 => [23, 48, 6, 288, 49, 40, 24], 3 => [27, 60, 8, 480, 84, 68, 40], 4 => [31, 88, 8, 704, 128, 104, 62], 5 => [37, 120, 8, 960, 178, 144, 87], 6 => [41, 156, 8, 1248, 232, 187, 114], 7 => [45, 196, 8, 1568, 294, 236, 145], 8 => [49, 240, 8, 1920, 362, 291, 179], 9 => [53, 230, 10, 2300, 433, 348, 214], 10 => [57, 272, 10, 2720, 516, 414, 256], 11 => [61, 316, 10, 3160, 601, 482, 298], 12 => [67, 364, 10, 3640, 691, 554, 343], 13 => [71, 416, 10, 4160, 793, 636, 394], 14 => [75, 470, 10, 4700, 896, 718, 446], 15 => [79, 528, 10, 5280, 1008, 808, 502], 16 => [83, 588, 10, 5880, 1123, 900, 559], 17 => [87, 652, 10, 6520, 1246, 998, 621], 18 => [91, 720, 10, 7200, 1378, 1104, 687], 19 => [95, 790, 10, 7900, 1511, 1210, 753], 20 => [101, 864, 10, 8640, 1653, 1324, 824], 21 => [105, 940, 10, 9400, 1801, 1442, 898], 22 => [109, 1020, 10, 10200, 1956, 1566, 976], 23 => [113, 920, 12, 11040, 2116, 1694, 1056], 24 => [117, 992, 12, 11904, 2281, 1826, 1138], 25 => [121, 1066, 12, 12792, 2452, 1963, 1224], 26 => [125, 1144, 12, 13728, 2632, 2107, 1314], 27 => [131, 1224, 12, 14688, 2818, 2256, 1407], 28 => [135, 1306, 12, 15672, 3007, 2407, 1501], 29 => [139, 1392, 12, 16704, 3205, 2565, 1600], 30 => [143, 1480, 12, 17760, 3409, 2728, 1702], 31 => [147, 1570, 12, 18840, 3616, 2894, 1806], 32 => [151, 1664, 12, 19968, 3832, 3067, 1914]]; + public const SIZE_FULL = [ + 1 => [19, 21, 6, 126, 18, 15, 8], + 2 => [23, 48, 6, 288, 49, 40, 24], + 3 => [27, 60, 8, 480, 84, 68, 40], + 4 => [31, 88, 8, 704, 128, 104, 62], + 5 => [37, 120, 8, 960, 178, 144, 87], + 6 => [41, 156, 8, 1248, 232, 187, 114], + 7 => [45, 196, 8, 1568, 294, 236, 145], + 8 => [49, 240, 8, 1920, 362, 291, 179], + 9 => [53, 230, 10, 2300, 433, 348, 214], + 10 => [57, 272, 10, 2720, 516, 414, 256], + 11 => [61, 316, 10, 3160, 601, 482, 298], + 12 => [67, 364, 10, 3640, 691, 554, 343], + 13 => [71, 416, 10, 4160, 793, 636, 394], + 14 => [75, 470, 10, 4700, 896, 718, 446], + 15 => [79, 528, 10, 5280, 1008, 808, 502], + 16 => [83, 588, 10, 5880, 1123, 900, 559], + 17 => [87, 652, 10, 6520, 1246, 998, 621], + 18 => [91, 720, 10, 7200, 1378, 1104, 687], + 19 => [95, 790, 10, 7900, 1511, 1210, 753], + 20 => [101, 864, 10, 8640, 1653, 1324, 824], + 21 => [105, 940, 10, 9400, 1801, 1442, 898], + 22 => [109, 1020, 10, 10200, 1956, 1566, 976], + 23 => [113, 920, 12, 11040, 2116, 1694, 1056], + 24 => [117, 992, 12, 11904, 2281, 1826, 1138], + 25 => [121, 1066, 12, 12792, 2452, 1963, 1224], + 26 => [125, 1144, 12, 13728, 2632, 2107, 1314], + 27 => [131, 1224, 12, 14688, 2818, 2256, 1407], + 28 => [135, 1306, 12, 15672, 3007, 2407, 1501], + 29 => [139, 1392, 12, 16704, 3205, 2565, 1600], + 30 => [143, 1480, 12, 17760, 3409, 2728, 1702], + 31 => [147, 1570, 12, 18840, 3616, 2894, 1806], + 32 => [151, 1664, 12, 19968, 3832, 3067, 1914], + ]; } diff --git a/src/Type/Square/Aztec/Encode.php b/src/Type/Square/Aztec/Encode.php index ed7e1af9..5ccdb0a3 100644 --- a/src/Type/Square/Aztec/Encode.php +++ b/src/Type/Square/Aztec/Encode.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Aztec; -use Com\Tecnick\Barcode\Type\Square\Aztec\Data; -use Com\Tecnick\Barcode\Type\Square\Aztec\ErrorCorrection; use Com\Tecnick\Barcode\Exception as BarcodeException; /** @@ -45,7 +43,7 @@ class Encode extends \Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream */ protected int $gridcenter = 0; - /** + /** * Aztec main encoder. * * @param string $code The code to encode. @@ -55,16 +53,15 @@ class Encode extends \Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream * @param string $mode The mode to use (A = Automatic; F = Full Range mode). */ public function __construct( - string $code, - int $ecc = 33, - int $eci = 0, - string $hint = 'A', + string $code, + int $ecc = 33, + int $eci = 0, + string $hint = 'A', string $mode = 'A' - ) - { + ) { $this->highLevelEncoding($code, $eci, $hint); - if (!$this->sizeAndBitStuffing($ecc, $mode)) { - throw new BarcodeException('Data too long'); + if (! $this->sizeAndBitStuffing($ecc, $mode)) { + throw new BarcodeException('Data too long'); } $wsize = $this->layer[2]; @@ -94,12 +91,11 @@ public function getGrid(): array * @return int The number of data codewords. */ protected function addCheckWords( - array &$bitstream, - int &$totbits, - int $nbits, + array &$bitstream, + int &$totbits, + int $nbits, int $wsize - ): int - { + ): int { $cdw = $this->bitstreamToWords($bitstream, $totbits, $wsize); $numcdw = count($cdw); $totwords = (int) ($nbits / $wsize); @@ -108,7 +104,7 @@ protected function addCheckWords( $checkwords = $errorCorrection->checkwords($cdw, $eccwords); // append check codewords foreach ($checkwords as $checkword) { - $this->appendWordToBitstream($bitstream, $totbits, $wsize, $checkword); + $this->appendWordToBitstream($bitstream, $totbits, $wsize, $checkword); } return $numcdw; @@ -275,7 +271,6 @@ protected function popBit(int &$bit): int return (empty($this->bitstream[$bit--]) ? 0 : 1); } - /** * Returns 1 if the current position must be skipped in Full mode. * @@ -283,10 +278,9 @@ protected function popBit(int &$bit): int */ protected function skipModeRefGrid(int $pos): int { - return (int) ((!$this->compact) && ($pos == 5)); + return (int) ((! $this->compact) && ($pos == 5)); } - /** * Returns the offset for the specified position to skip the reference grid. * @@ -294,7 +288,7 @@ protected function skipModeRefGrid(int $pos): int */ protected function skipRefGrid(int $pos): int { - return (int) ((!$this->compact) && (($pos % 16) == 0)); + return (int) ((! $this->compact) && (($pos % 16) == 0)); } /** diff --git a/src/Type/Square/Aztec/ErrorCorrection.php b/src/Type/Square/Aztec/ErrorCorrection.php index 2b8d1d02..bd172e9b 100644 --- a/src/Type/Square/Aztec/ErrorCorrection.php +++ b/src/Type/Square/Aztec/ErrorCorrection.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Aztec; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\Aztec\ErrorCorrection * @@ -37,11 +35,11 @@ class ErrorCorrection * Galois Field primitive by word size. */ protected const GF = [ - 4 => 19, + 4 => 19, // 10011 GF(16) (x^4 + x + 1) Mode message - 6 => 67, + 6 => 67, // 1000011 GF(64) (x^6 + x + 1) 01–02 layers - 8 => 301, + 8 => 301, // 100101101 GF(256) (x^8 + x^5 + x^3 + x^2 + 1) 03–08 layers 10 => 1033, // 10000001001 GF(1024) (x^10 + x^3 + 1) 09–22 layers @@ -52,7 +50,13 @@ class ErrorCorrection * Map the log and exp (inverse log) tables by word size. * NOTE: It is equal to 2^word_size. */ - protected const TSIZE = [4 => 16, 6 => 64, 8 => 256, 10 => 1024, 12 => 4096]; + protected const TSIZE = [ + 4 => 16, + 6 => 64, + 8 => 256, + 10 => 1024, + 12 => 4096, + ]; /** * Log table. diff --git a/src/Type/Square/Aztec/Layers.php b/src/Type/Square/Aztec/Layers.php index 1447aa32..6bf5347d 100644 --- a/src/Type/Square/Aztec/Layers.php +++ b/src/Type/Square/Aztec/Layers.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Aztec; -use Com\Tecnick\Barcode\Type\Square\Aztec\Data; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\Aztec\Layers * @@ -110,7 +107,7 @@ protected function sizeAndBitStuffing(int $ecc, string $mode = 'A'): bool $nsbits = 0; $eccbits = (11 + (int) (($this->totbits * $ecc) / 100)); do { - if (!$this->setLayerByBits(($this->totbits + $nsbits + $eccbits), $mode)) { + if (! $this->setLayerByBits(($this->totbits + $nsbits + $eccbits), $mode)) { return false; } diff --git a/src/Type/Square/Datamatrix.php b/src/Type/Square/Datamatrix.php index 23fc431a..aca80ade 100644 --- a/src/Type/Square/Datamatrix.php +++ b/src/Type/Square/Datamatrix.php @@ -83,7 +83,7 @@ protected function setParameters(): void } // mode - if (!isset($this->params[1])) { + if (! isset($this->params[1])) { return; } @@ -135,7 +135,7 @@ protected function addPadding(int $size, int $ncw): void */ protected function getCodewords(): array { - if (strlen((string)$this->code) == 0) { + if (strlen((string) $this->code) == 0) { throw new BarcodeException('Empty input'); } @@ -164,16 +164,15 @@ protected function getCodewords(): array * Set the grid */ protected function setGrid( - int &$idx, - array &$places, - int &$row, - int &$col, - int &$rdx, - int &$cdx, - int &$rdri, + int &$idx, + array &$places, + int &$row, + int &$col, + int &$rdx, + int &$cdx, + int &$rdri, int &$rdci - ): void - { + ): void { // braw bits by case if ($rdx == 0) { // top finder pattern @@ -284,13 +283,11 @@ protected function setBars(): void for ($hr = 0; $hr < $params[8]; ++$hr) { // for each row on region for ($rdx = 0; $rdx < $params[4]; ++$rdx) { - // get row $row = (($hr * $params[4]) + $rdx); // for each vertical region for ($vr = 0; $vr < $params[9]; ++$vr) { // for each column on region for ($cdx = 0; $cdx < $params[5]; ++$cdx) { - // get column $col = (($vr * $params[5]) + $cdx); $this->setGrid($idx, $places, $row, $col, $rdx, $cdx, $rdri, $rdci); } diff --git a/src/Type/Square/Datamatrix/Data.php b/src/Type/Square/Datamatrix/Data.php index 99facf52..990a3529 100644 --- a/src/Type/Square/Datamatrix/Data.php +++ b/src/Type/Square/Datamatrix/Data.php @@ -94,81 +94,89 @@ class Data *
  • error codewords per block
  • * */ - public const SYMBATTR = ['S' => [ - // square form - // 10x10 - [0x00a, 0x00a, 0x008, 0x008, 0x00a, 0x00a, 0x008, 0x008, 0x001, 0x001, 0x001, 0x003, 0x005, 0x001, 0x003, 0x005], - // 12x12 - [0x00c, 0x00c, 0x00a, 0x00a, 0x00c, 0x00c, 0x00a, 0x00a, 0x001, 0x001, 0x001, 0x005, 0x007, 0x001, 0x005, 0x007], - // 14x14 - [0x00e, 0x00e, 0x00c, 0x00c, 0x00e, 0x00e, 0x00c, 0x00c, 0x001, 0x001, 0x001, 0x008, 0x00a, 0x001, 0x008, 0x00a], - // 16x16 - [0x010, 0x010, 0x00e, 0x00e, 0x010, 0x010, 0x00e, 0x00e, 0x001, 0x001, 0x001, 0x00c, 0x00c, 0x001, 0x00c, 0x00c], - // 18x18 - [0x012, 0x012, 0x010, 0x010, 0x012, 0x012, 0x010, 0x010, 0x001, 0x001, 0x001, 0x012, 0x00e, 0x001, 0x012, 0x00e], - // 20x20 - [0x014, 0x014, 0x012, 0x012, 0x014, 0x014, 0x012, 0x012, 0x001, 0x001, 0x001, 0x016, 0x012, 0x001, 0x016, 0x012], - // 22x22 - [0x016, 0x016, 0x014, 0x014, 0x016, 0x016, 0x014, 0x014, 0x001, 0x001, 0x001, 0x01e, 0x014, 0x001, 0x01e, 0x014], - // 24x24 - [0x018, 0x018, 0x016, 0x016, 0x018, 0x018, 0x016, 0x016, 0x001, 0x001, 0x001, 0x024, 0x018, 0x001, 0x024, 0x018], - // 26x26 - [0x01a, 0x01a, 0x018, 0x018, 0x01a, 0x01a, 0x018, 0x018, 0x001, 0x001, 0x001, 0x02c, 0x01c, 0x001, 0x02c, 0x01c], - // 32x32 - [0x020, 0x020, 0x01c, 0x01c, 0x010, 0x010, 0x00e, 0x00e, 0x002, 0x002, 0x004, 0x03e, 0x024, 0x001, 0x03e, 0x024], - // 36x36 - [0x024, 0x024, 0x020, 0x020, 0x012, 0x012, 0x010, 0x010, 0x002, 0x002, 0x004, 0x056, 0x02a, 0x001, 0x056, 0x02a], - // 40x40 - [0x028, 0x028, 0x024, 0x024, 0x014, 0x014, 0x012, 0x012, 0x002, 0x002, 0x004, 0x072, 0x030, 0x001, 0x072, 0x030], - // 44x44 - [0x02c, 0x02c, 0x028, 0x028, 0x016, 0x016, 0x014, 0x014, 0x002, 0x002, 0x004, 0x090, 0x038, 0x001, 0x090, 0x038], - // 48x48 - [0x030, 0x030, 0x02c, 0x02c, 0x018, 0x018, 0x016, 0x016, 0x002, 0x002, 0x004, 0x0ae, 0x044, 0x001, 0x0ae, 0x044], - // 52x52 - [0x034, 0x034, 0x030, 0x030, 0x01a, 0x01a, 0x018, 0x018, 0x002, 0x002, 0x004, 0x0cc, 0x054, 0x002, 0x066, 0x02a], - // 64x64 - [0x040, 0x040, 0x038, 0x038, 0x010, 0x010, 0x00e, 0x00e, 0x004, 0x004, 0x010, 0x118, 0x070, 0x002, 0x08c, 0x038], - // 72x72 - [0x048, 0x048, 0x040, 0x040, 0x012, 0x012, 0x010, 0x010, 0x004, 0x004, 0x010, 0x170, 0x090, 0x004, 0x05c, 0x024], - // 80x80 - [0x050, 0x050, 0x048, 0x048, 0x014, 0x014, 0x012, 0x012, 0x004, 0x004, 0x010, 0x1c8, 0x0c0, 0x004, 0x072, 0x030], - // 88x88 - [0x058, 0x058, 0x050, 0x050, 0x016, 0x016, 0x014, 0x014, 0x004, 0x004, 0x010, 0x240, 0x0e0, 0x004, 0x090, 0x038], - // 96x96 - [0x060, 0x060, 0x058, 0x058, 0x018, 0x018, 0x016, 0x016, 0x004, 0x004, 0x010, 0x2b8, 0x110, 0x004, 0x0ae, 0x044], - // 104x104 - [0x068, 0x068, 0x060, 0x060, 0x01a, 0x01a, 0x018, 0x018, 0x004, 0x004, 0x010, 0x330, 0x150, 0x006, 0x088, 0x038], - // 120x120 - [0x078, 0x078, 0x06c, 0x06c, 0x014, 0x014, 0x012, 0x012, 0x006, 0x006, 0x024, 0x41a, 0x198, 0x006, 0x0af, 0x044], - // 132x132 - [0x084, 0x084, 0x078, 0x078, 0x016, 0x016, 0x014, 0x014, 0x006, 0x006, 0x024, 0x518, 0x1f0, 0x008, 0x0a3, 0x03e], - // 144x144 - [0x090, 0x090, 0x084, 0x084, 0x018, 0x018, 0x016, 0x016, 0x006, 0x006, 0x024, 0x618, 0x26c, 0x00a, 0x09c, 0x03e], - ], 'R' => [ - // rectangular form - // 8x18 - [0x008, 0x012, 0x006, 0x010, 0x008, 0x012, 0x006, 0x010, 0x001, 0x001, 0x001, 0x005, 0x007, 0x001, 0x005, 0x007], - // 8x32 - [0x008, 0x020, 0x006, 0x01c, 0x008, 0x010, 0x006, 0x00e, 0x001, 0x002, 0x002, 0x00a, 0x00b, 0x001, 0x00a, 0x00b], - // 12x26 - [0x00c, 0x01a, 0x00a, 0x018, 0x00c, 0x01a, 0x00a, 0x018, 0x001, 0x001, 0x001, 0x010, 0x00e, 0x001, 0x010, 0x00e], - // 12x36 - [0x00c, 0x024, 0x00a, 0x020, 0x00c, 0x012, 0x00a, 0x010, 0x001, 0x002, 0x002, 0x00c, 0x012, 0x001, 0x00c, 0x012], - // 16x36 - [0x010, 0x024, 0x00e, 0x020, 0x010, 0x012, 0x00e, 0x010, 0x001, 0x002, 0x002, 0x020, 0x018, 0x001, 0x020, 0x018], - // 16x48 - [0x010, 0x030, 0x00e, 0x02c, 0x010, 0x018, 0x00e, 0x016, 0x001, 0x002, 0x002, 0x031, 0x01c, 0x001, 0x031, 0x01c], - ]]; + public const SYMBATTR = [ + 'S' => [ + // square form + // 10x10 + [0x00a, 0x00a, 0x008, 0x008, 0x00a, 0x00a, 0x008, 0x008, 0x001, 0x001, 0x001, 0x003, 0x005, 0x001, 0x003, 0x005], + // 12x12 + [0x00c, 0x00c, 0x00a, 0x00a, 0x00c, 0x00c, 0x00a, 0x00a, 0x001, 0x001, 0x001, 0x005, 0x007, 0x001, 0x005, 0x007], + // 14x14 + [0x00e, 0x00e, 0x00c, 0x00c, 0x00e, 0x00e, 0x00c, 0x00c, 0x001, 0x001, 0x001, 0x008, 0x00a, 0x001, 0x008, 0x00a], + // 16x16 + [0x010, 0x010, 0x00e, 0x00e, 0x010, 0x010, 0x00e, 0x00e, 0x001, 0x001, 0x001, 0x00c, 0x00c, 0x001, 0x00c, 0x00c], + // 18x18 + [0x012, 0x012, 0x010, 0x010, 0x012, 0x012, 0x010, 0x010, 0x001, 0x001, 0x001, 0x012, 0x00e, 0x001, 0x012, 0x00e], + // 20x20 + [0x014, 0x014, 0x012, 0x012, 0x014, 0x014, 0x012, 0x012, 0x001, 0x001, 0x001, 0x016, 0x012, 0x001, 0x016, 0x012], + // 22x22 + [0x016, 0x016, 0x014, 0x014, 0x016, 0x016, 0x014, 0x014, 0x001, 0x001, 0x001, 0x01e, 0x014, 0x001, 0x01e, 0x014], + // 24x24 + [0x018, 0x018, 0x016, 0x016, 0x018, 0x018, 0x016, 0x016, 0x001, 0x001, 0x001, 0x024, 0x018, 0x001, 0x024, 0x018], + // 26x26 + [0x01a, 0x01a, 0x018, 0x018, 0x01a, 0x01a, 0x018, 0x018, 0x001, 0x001, 0x001, 0x02c, 0x01c, 0x001, 0x02c, 0x01c], + // 32x32 + [0x020, 0x020, 0x01c, 0x01c, 0x010, 0x010, 0x00e, 0x00e, 0x002, 0x002, 0x004, 0x03e, 0x024, 0x001, 0x03e, 0x024], + // 36x36 + [0x024, 0x024, 0x020, 0x020, 0x012, 0x012, 0x010, 0x010, 0x002, 0x002, 0x004, 0x056, 0x02a, 0x001, 0x056, 0x02a], + // 40x40 + [0x028, 0x028, 0x024, 0x024, 0x014, 0x014, 0x012, 0x012, 0x002, 0x002, 0x004, 0x072, 0x030, 0x001, 0x072, 0x030], + // 44x44 + [0x02c, 0x02c, 0x028, 0x028, 0x016, 0x016, 0x014, 0x014, 0x002, 0x002, 0x004, 0x090, 0x038, 0x001, 0x090, 0x038], + // 48x48 + [0x030, 0x030, 0x02c, 0x02c, 0x018, 0x018, 0x016, 0x016, 0x002, 0x002, 0x004, 0x0ae, 0x044, 0x001, 0x0ae, 0x044], + // 52x52 + [0x034, 0x034, 0x030, 0x030, 0x01a, 0x01a, 0x018, 0x018, 0x002, 0x002, 0x004, 0x0cc, 0x054, 0x002, 0x066, 0x02a], + // 64x64 + [0x040, 0x040, 0x038, 0x038, 0x010, 0x010, 0x00e, 0x00e, 0x004, 0x004, 0x010, 0x118, 0x070, 0x002, 0x08c, 0x038], + // 72x72 + [0x048, 0x048, 0x040, 0x040, 0x012, 0x012, 0x010, 0x010, 0x004, 0x004, 0x010, 0x170, 0x090, 0x004, 0x05c, 0x024], + // 80x80 + [0x050, 0x050, 0x048, 0x048, 0x014, 0x014, 0x012, 0x012, 0x004, 0x004, 0x010, 0x1c8, 0x0c0, 0x004, 0x072, 0x030], + // 88x88 + [0x058, 0x058, 0x050, 0x050, 0x016, 0x016, 0x014, 0x014, 0x004, 0x004, 0x010, 0x240, 0x0e0, 0x004, 0x090, 0x038], + // 96x96 + [0x060, 0x060, 0x058, 0x058, 0x018, 0x018, 0x016, 0x016, 0x004, 0x004, 0x010, 0x2b8, 0x110, 0x004, 0x0ae, 0x044], + // 104x104 + [0x068, 0x068, 0x060, 0x060, 0x01a, 0x01a, 0x018, 0x018, 0x004, 0x004, 0x010, 0x330, 0x150, 0x006, 0x088, 0x038], + // 120x120 + [0x078, 0x078, 0x06c, 0x06c, 0x014, 0x014, 0x012, 0x012, 0x006, 0x006, 0x024, 0x41a, 0x198, 0x006, 0x0af, 0x044], + // 132x132 + [0x084, 0x084, 0x078, 0x078, 0x016, 0x016, 0x014, 0x014, 0x006, 0x006, 0x024, 0x518, 0x1f0, 0x008, 0x0a3, 0x03e], + // 144x144 + [0x090, 0x090, 0x084, 0x084, 0x018, 0x018, 0x016, 0x016, 0x006, 0x006, 0x024, 0x618, 0x26c, 0x00a, 0x09c, 0x03e], + ], + 'R' => [ + // rectangular form + // 8x18 + [0x008, 0x012, 0x006, 0x010, 0x008, 0x012, 0x006, 0x010, 0x001, 0x001, 0x001, 0x005, 0x007, 0x001, 0x005, 0x007], + // 8x32 + [0x008, 0x020, 0x006, 0x01c, 0x008, 0x010, 0x006, 0x00e, 0x001, 0x002, 0x002, 0x00a, 0x00b, 0x001, 0x00a, 0x00b], + // 12x26 + [0x00c, 0x01a, 0x00a, 0x018, 0x00c, 0x01a, 0x00a, 0x018, 0x001, 0x001, 0x001, 0x010, 0x00e, 0x001, 0x010, 0x00e], + // 12x36 + [0x00c, 0x024, 0x00a, 0x020, 0x00c, 0x012, 0x00a, 0x010, 0x001, 0x002, 0x002, 0x00c, 0x012, 0x001, 0x00c, 0x012], + // 16x36 + [0x010, 0x024, 0x00e, 0x020, 0x010, 0x012, 0x00e, 0x010, 0x001, 0x002, 0x002, 0x020, 0x018, 0x001, 0x020, 0x018], + // 16x48 + [0x010, 0x030, 0x00e, 0x02c, 0x010, 0x018, 0x00e, 0x016, 0x001, 0x002, 0x002, 0x031, 0x01c, 0x001, 0x031, 0x01c], + ], + ]; - /** - * Map encodation modes whit character sets. - */ - public const CHSET_ID = [self::ENC_C40 => 'C40', self::ENC_TXT => 'TXT', self::ENC_X12 => 'X12']; + /** + * Map encodation modes whit character sets. + */ + public const CHSET_ID = [ + self::ENC_C40 => 'C40', + self::ENC_TXT => 'TXT', + self::ENC_X12 => 'X12', + ]; - /** - * Basic set of characters for each encodation mode. - */ - public const CHSET = ['C40' => [ + /** + * Basic set of characters for each encodation mode. + */ + public const CHSET = [ + 'C40' => [ // Basic set for C40 'S1' => 0x00, 'S2' => 0x01, @@ -210,7 +218,8 @@ class Data 0x58 => 0x25, 0x59 => 0x26, 0x5a => 0x27, - ], 'TXT' => [ + ], + 'TXT' => [ // Basic set for TEXT 'S1' => 0x00, 'S2' => 0x01, @@ -252,7 +261,8 @@ class Data 0x78 => 0x25, 0x79 => 0x26, 0x7a => 0x27, - ], 'SH1' => [ + ], + 'SH1' => [ // Shift 1 set 0x00 => 0x00, 0x01 => 0x01, @@ -286,7 +296,8 @@ class Data 0x1d => 0x1d, 0x1e => 0x1e, 0x1f => 0x1f, - ], 'SH2' => [ + ], + 'SH2' => [ // Shift 2 set 0x21 => 0x00, 0x22 => 0x01, @@ -317,7 +328,8 @@ class Data 0x5f => 0x1a, 'F1' => 0x1b, 'US' => 0x1e, - ], 'S3C' => [ + ], + 'S3C' => [ // Shift 3 set for C40 0x60 => 0x00, 0x61 => 0x01, @@ -351,7 +363,8 @@ class Data 0x7d => 0x1d, 0x7e => 0x1e, 0x7f => 0x1f, - ], 'S3T' => [ + ], + 'S3T' => [ // Shift 3 set for TEXT 0x60 => 0x00, 0x41 => 0x01, @@ -385,7 +398,8 @@ class Data 0x7d => 0x1d, 0x7e => 0x1e, 0x7f => 0x1f, - ], 'X12' => [ + ], + 'X12' => [ // Set for X12 0x0d => 0x00, 0x2a => 0x01, @@ -427,7 +441,8 @@ class Data 0x58 => 0x25, 0x59 => 0x26, 0x5a => 0x27, - ]]; + ], + ]; /** * Get the required codewords padding size diff --git a/src/Type/Square/Datamatrix/Encode.php b/src/Type/Square/Datamatrix/Encode.php index 077b698a..c7a91d0c 100644 --- a/src/Type/Square/Datamatrix/Encode.php +++ b/src/Type/Square/Datamatrix/Encode.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Datamatrix; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\Datamatrix\Data; - /** * Com\Tecnick\Barcode\Type\Square\Datamatrix\Encode * @@ -49,18 +46,18 @@ public function __construct(string $shape = 'S') * Encode ASCII */ public function encodeASCII( - array &$cdw, - int &$cdw_num, - int &$pos, - int &$data_length, - string &$data, + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + string &$data, int &$enc - ): void - { + ): void { if ( ($data_length > 1) && ($pos < ($data_length - 1)) - && ($this->isCharMode(ord($data[$pos]), Data::ENC_ASCII_NUM) + && ( + $this->isCharMode(ord($data[$pos]), Data::ENC_ASCII_NUM) && $this->isCharMode(ord($data[$pos + 1]), Data::ENC_ASCII_NUM) ) ) { @@ -99,20 +96,18 @@ public function encodeASCII( /** * Encode EDF4 * - * * @return bool true to break the loop */ public function encodeEDFfour( - int $epos, - array &$cdw, - int &$cdw_num, - int &$pos, - int &$data_length, - int &$field_length, - int &$enc, + int $epos, + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + int &$field_length, + int &$enc, array &$temp_cw - ): bool - { + ): bool { if (($epos === $data_length)) { $enc = Data::ENC_ASCII; $params = Data::getPaddingSize($this->shape, ($cdw_num + $field_length)); @@ -168,15 +163,14 @@ public function encodeEDFfour( * Encode EDF */ public function encodeEDF( - array &$cdw, - int &$cdw_num, - int &$pos, - int &$data_length, - int &$field_length, - string &$data, + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + int &$field_length, + string &$data, int &$enc - ): void - { + ): void { // initialize temporary array with 0 length $temp_cw = []; $epos = $pos; @@ -192,7 +186,7 @@ public function encodeEDF( if ( (($field_length == 4) - || ($epos == $data_length) || !$this->isCharMode($chr, Data::ENC_EDF)) && $this->encodeEDFfour($epos, $cdw, $cdw_num, $pos, $data_length, $field_length, $enc, $temp_cw) + || ($epos == $data_length) || ! $this->isCharMode($chr, Data::ENC_EDF)) && $this->encodeEDFfour($epos, $cdw, $cdw_num, $pos, $data_length, $field_length, $enc, $temp_cw) ) { break; } @@ -203,15 +197,14 @@ public function encodeEDF( * Encode Base256 */ public function encodeBase256( - array &$cdw, - int &$cdw_num, - int &$pos, - int &$data_length, - int &$field_length, - string &$data, + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + int &$field_length, + string &$data, int &$enc - ): void - { + ): void { // initialize temporary array with 0 length $temp_cw = []; $field_length = 0; @@ -236,7 +229,7 @@ public function encodeBase256( $cdw[] = $this->get255StateCodeword($field_length, ($cdw_num + 1)); ++$cdw_num; } else { - $cdw[] = $this->get255StateCodeword(((int)floor($field_length / 250) + 249), ($cdw_num + 1)); + $cdw[] = $this->get255StateCodeword(((int) floor($field_length / 250) + 249), ($cdw_num + 1)); $cdw[] = $this->get255StateCodeword(($field_length % 250), ($cdw_num + 2)); $cdw_num += 2; } diff --git a/src/Type/Square/Datamatrix/EncodeTxt.php b/src/Type/Square/Datamatrix/EncodeTxt.php index 46e764a9..9061a365 100644 --- a/src/Type/Square/Datamatrix/EncodeTxt.php +++ b/src/Type/Square/Datamatrix/EncodeTxt.php @@ -17,7 +17,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Datamatrix; use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\Datamatrix\Data; /** * Com\Tecnick\Barcode\Type\Square\Datamatrix\Encodetxt @@ -40,11 +39,10 @@ class EncodeTxt extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Steps */ public function encodeTXTC40shift( int &$chr, - int &$enc, - array &$temp_cw, + int &$enc, + array &$temp_cw, int &$ptr - ): void - { + ): void { if (array_key_exists($chr, Data::CHSET['SH1'])) { $temp_cw[] = 0; // shift 1 $shiftset = Data::CHSET['SH1']; @@ -68,18 +66,16 @@ public function encodeTXTC40shift( /** * Encode TXTC40 * - * * @return int Curent character code */ public function encodeTXTC40( - string &$data, - int &$enc, - array &$temp_cw, - int &$ptr, - int &$epos, - array &$charset - ): int - { + string &$data, + int &$enc, + array &$temp_cw, + int &$ptr, + int &$epos, + array &$charset + ): int { // 2. process the next character in C40 encodation. $chr = ord($data[$epos]); ++$epos; @@ -111,15 +107,14 @@ public function encodeTXTC40( * before the start of the error correction codewords. */ public function encodeTXTC40last( - int $chr, - array &$cdw, - int &$cdw_num, - int &$enc, - array &$temp_cw, - int &$ptr, + int $chr, + array &$cdw, + int &$cdw_num, + int &$enc, + array &$temp_cw, + int &$ptr, int &$epos - ): void - { + ): void { // get remaining number of data symbols $cdwr = ($this->getMaxDataCodewords($cdw_num + $ptr) - $cdw_num); if (($cdwr == 1) && ($ptr == 1)) { @@ -162,14 +157,13 @@ public function encodeTXTC40last( * Encode TXT */ public function encodeTXT( - array &$cdw, - int &$cdw_num, - int &$pos, - int &$data_length, - string &$data, + array &$cdw, + int &$cdw_num, + int &$pos, + int &$data_length, + string &$data, int &$enc - ): void - { + ): void { $temp_cw = []; $ptr = 0; $epos = $pos; diff --git a/src/Type/Square/Datamatrix/ErrorCorrection.php b/src/Type/Square/Datamatrix/ErrorCorrection.php index 4ccada8c..2b0a6526 100644 --- a/src/Type/Square/Datamatrix/ErrorCorrection.php +++ b/src/Type/Square/Datamatrix/ErrorCorrection.php @@ -43,13 +43,12 @@ class ErrorCorrection * @return int product */ protected function getGFProduct( - int $numa, - int $numb, - array $log, - array $alog, + int $numa, + int $numb, + array $log, + array $alog, int $ngf - ): int - { + ): int { if (($numa == 0) || ($numb == 0)) { return 0; } @@ -70,14 +69,13 @@ protected function getGFProduct( * @return array data codewords + error codewords */ public function getErrorCorrection( - array $wdc, - int $nbk, - int $ncw, - int $ncc, - int $ngf = 256, + array $wdc, + int $nbk, + int $ncw, + int $ncc, + int $ngf = 256, int $vpp = 301 - ): array - { + ): array { // generate the log ($log) and antilog ($alog) tables $log = [0]; $alog = [1]; @@ -141,12 +139,11 @@ public function getErrorCorrection( * @param int $vpp The value of its prime modulus polynomial (301 for ECC200). */ protected function genLogs( - array &$log, - array &$alog, - int $ngf, + array &$log, + array &$alog, + int $ngf, int $vpp - ): void - { + ): void { for ($i = 1; $i < $ngf; ++$i) { $alog[$i] = ($alog[($i - 1)] * 2); if ($alog[$i] >= $ngf) { diff --git a/src/Type/Square/Datamatrix/Modes.php b/src/Type/Square/Datamatrix/Modes.php index 17d998cd..523e133e 100644 --- a/src/Type/Square/Datamatrix/Modes.php +++ b/src/Type/Square/Datamatrix/Modes.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Datamatrix; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\Datamatrix\Modes * @@ -89,11 +87,11 @@ protected function isCharMode(int $chr, int $mode): bool { $map = [ //Data::ENC_ASCII => 'isASCIIMode', - Data::ENC_C40 => 'isC40Mode', - Data::ENC_TXT => 'isTXTMode', - Data::ENC_X12 => 'isX12Mode', - Data::ENC_EDF => 'isEDFMode', - Data::ENC_BASE256 => 'isBASE256Mode', + Data::ENC_C40 => 'isC40Mode', + Data::ENC_TXT => 'isTXTMode', + Data::ENC_X12 => 'isX12Mode', + Data::ENC_EDF => 'isEDFMode', + Data::ENC_BASE256 => 'isBASE256Mode', Data::ENC_ASCII_EXT => 'isASCIIEXTMode', Data::ENC_ASCII_NUM => 'isASCIINUMMode', ]; @@ -210,7 +208,14 @@ protected function getMaxDataCodewords(int $numcw): int */ protected function getSwitchEncodingCodeword(int $mode): int { - $map = [Data::ENC_ASCII => 254, Data::ENC_C40 => 230, Data::ENC_TXT => 239, Data::ENC_X12 => 238, Data::ENC_EDF => 240, Data::ENC_BASE256 => 231]; + $map = [ + Data::ENC_ASCII => 254, + Data::ENC_C40 => 230, + Data::ENC_TXT => 239, + Data::ENC_X12 => 238, + Data::ENC_EDF => 240, + Data::ENC_BASE256 => 231, + ]; $cdw = $map[$mode]; if ($cdw != 254) { return $cdw; diff --git a/src/Type/Square/Datamatrix/Placement.php b/src/Type/Square/Datamatrix/Placement.php index 09a8a26e..bf5277cf 100644 --- a/src/Type/Square/Datamatrix/Placement.php +++ b/src/Type/Square/Datamatrix/Placement.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Datamatrix; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\Datamatrix\Placement * @@ -46,15 +44,14 @@ abstract class Placement * @param int $bit Bit. */ protected function placeModule( - array $marr, - int $nrow, - int $ncol, - int $row, - int $col, - int $chr, + array $marr, + int $nrow, + int $ncol, + int $row, + int $col, + int $chr, int $bit - ): array - { + ): array { if ($row < 0) { $row += $nrow; $col += (4 - (($nrow + 4) % 8)); @@ -81,14 +78,13 @@ protected function placeModule( * @param int $chr Char byte. */ protected function placeUtah( - array $marr, - int $nrow, - int $ncol, - int $row, - int $col, + array $marr, + int $nrow, + int $ncol, + int $row, + int $col, int $chr - ): array - { + ): array { $marr = $this->placeModule($marr, $nrow, $ncol, $row - 2, $col - 2, $chr, 1); $marr = $this->placeModule($marr, $nrow, $ncol, $row - 2, $col - 1, $chr, 2); $marr = $this->placeModule($marr, $nrow, $ncol, $row - 1, $col - 2, $chr, 3); @@ -111,14 +107,13 @@ protected function placeUtah( * @param int $col Current column */ protected function placeCornerA( - array $marr, - int $nrow, - int $ncol, - int &$chr, - int $row, + array $marr, + int $nrow, + int $ncol, + int &$chr, + int $row, int $col - ): array - { + ): array { if (($row !== $nrow) || ($col != 0)) { return $marr; } @@ -147,14 +142,13 @@ protected function placeCornerA( * @param int $col Current column */ protected function placeCornerB( - array $marr, - int $nrow, - int $ncol, - int &$chr, - int $row, + array $marr, + int $nrow, + int $ncol, + int &$chr, + int $row, int $col - ): array - { + ): array { if (($row !== $nrow - 2) || ($col != 0) || (($ncol % 4) == 0)) { return $marr; } @@ -183,14 +177,13 @@ protected function placeCornerB( * @param int $col Current column */ protected function placeCornerC( - array $marr, - int $nrow, - int $ncol, - int &$chr, - int $row, + array $marr, + int $nrow, + int $ncol, + int &$chr, + int $row, int $col - ): array - { + ): array { if (($row !== $nrow - 2) || ($col != 0) || ($ncol % 8 != 4)) { return $marr; } @@ -219,14 +212,13 @@ protected function placeCornerC( * @param int $col Current column */ protected function placeCornerD( - array $marr, - int $nrow, - int $ncol, - int &$chr, - int $row, + array $marr, + int $nrow, + int $ncol, + int &$chr, + int $row, int $col - ): array - { + ): array { if (($row !== $nrow + 4) || ($col != 2) || ($ncol % 8)) { return $marr; } @@ -243,8 +235,6 @@ protected function placeCornerD( return $marr; } - - /** * Sweep upward diagonally, inserting successive characters, * (Annex F - ECC 200 symbol character placement) @@ -257,16 +247,15 @@ protected function placeCornerD( * @param int $col Current column */ protected function placeSweepUpward( - array $marr, - int $nrow, - int $ncol, - int &$chr, - int &$row, + array $marr, + int $nrow, + int $ncol, + int &$chr, + int &$row, int &$col - ): array - { + ): array { do { - if (($row < $nrow) && ($col >= 0) && (!$marr[(($row * $ncol) + $col)])) { + if (($row < $nrow) && ($col >= 0) && (! $marr[(($row * $ncol) + $col)])) { $marr = $this->placeUtah($marr, $nrow, $ncol, $row, $col, $chr); ++$chr; } @@ -292,16 +281,15 @@ protected function placeSweepUpward( * @param int $col Current column */ protected function placeSweepDownward( - array $marr, - int $nrow, - int $ncol, - int &$chr, - int &$row, + array $marr, + int $nrow, + int $ncol, + int &$chr, + int &$row, int &$col - ): array - { + ): array { do { - if (($row >= 0) && ($col < $ncol) && (!$marr[(($row * $ncol) + $col)])) { + if (($row >= 0) && ($col < $ncol) && (! $marr[(($row * $ncol) + $col)])) { $marr = $this->placeUtah($marr, $nrow, $ncol, $row, $col, $chr); ++$chr; } @@ -323,10 +311,9 @@ protected function placeSweepDownward( * @param int $ncol Number of columns. */ public function getPlacementMap( - int $nrow, + int $nrow, int $ncol - ): array - { + ): array { // initialize array with zeros $marr = array_fill(0, ($nrow * $ncol), 0); // set starting values @@ -347,7 +334,7 @@ public function getPlacementMap( } while (($row < $nrow) || ($col < $ncol)); // lastly, if the lower righthand corner is untouched, fill in fixed pattern - if (!$marr[(($nrow * $ncol) - 1)]) { + if (! $marr[(($nrow * $ncol) - 1)]) { $marr[(($nrow * $ncol) - 1)] = 1; $marr[(($nrow * $ncol) - $ncol - 2)] = 1; } diff --git a/src/Type/Square/Datamatrix/Steps.php b/src/Type/Square/Datamatrix/Steps.php index 72a6abb5..b4095ac4 100644 --- a/src/Type/Square/Datamatrix/Steps.php +++ b/src/Type/Square/Datamatrix/Steps.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\Datamatrix; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\Datamatrix\Data; - /** * Com\Tecnick\Barcode\Type\Square\Datamatrix\Steps * @@ -83,8 +80,6 @@ public function lookAheadTest(string $data, int $pos, int $mode): int /** * Step K - * - * */ protected function stepK(array $numch): int { @@ -238,17 +233,15 @@ protected function stepQ(int $chr, array &$numch): void /** * Step R-f * - * * @return int Encoding mode */ protected function stepRf( - array $numch, - int $pos, - int $data_length, - int $charscount, + array $numch, + int $pos, + int $data_length, + int $charscount, string $data - ): int - { + ): int { if ( ($numch[Data::ENC_C40] + 1) < min( $numch[Data::ENC_ASCII], @@ -287,13 +280,12 @@ protected function stepRf( * Step R */ protected function stepR( - array $numch, - int $pos, - int $data_length, - int $charscount, + array $numch, + int $pos, + int $data_length, + int $charscount, string $data - ): int - { + ): int { if ( ($numch[Data::ENC_ASCII] + 1) <= min( $numch[Data::ENC_C40], diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index dc9df4e5..657ba093 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -93,7 +93,7 @@ protected function setParameters(): void parent::setParameters(); // aspect ratio - if (!empty($this->params[0]) && (($aspectratio = (float) $this->params[0]) >= 1)) { + if (! empty($this->params[0]) && (($aspectratio = (float) $this->params[0]) >= 1)) { $this->aspectratio = $aspectratio; } @@ -136,7 +136,7 @@ protected function setMacroBlockParam(): void */ protected function setBars(): void { - if (strlen((string)$this->code) == 0) { + if (strlen((string) $this->code) == 0) { throw new BarcodeException('Empty input'); } @@ -199,15 +199,13 @@ protected function getMacroBlock(int &$numcw): array * @param int $cols number of columns * @param int $ecl eroor correction level * - * * @throws BarcodeException in case of error */ public function getCodewords( - int &$rows, - int &$cols, + int &$rows, + int &$cols, int &$ecl - ): array - { + ): array { $codewords = []; // array of code-words // get the input sequence array $sequence = $this->getInputSequences($this->code); diff --git a/src/Type/Square/PdfFourOneSeven/Compaction.php b/src/Type/Square/PdfFourOneSeven/Compaction.php index ebc96b60..f7aa4b2c 100644 --- a/src/Type/Square/PdfFourOneSeven/Compaction.php +++ b/src/Type/Square/PdfFourOneSeven/Compaction.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\Data; - /** * Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\Compaction * @@ -38,19 +35,20 @@ abstract class Compaction extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSev * Process Sub Text Compaction */ protected function processTextCompactionSub( - array &$txtarr, - int &$submode, - int $sub, - string $code, - int $key, - int $idx, + array &$txtarr, + int &$submode, + int $sub, + string $code, + int $key, + int $idx, int $codelen - ): void - { + ): void { // $sub is the new submode - if ((($idx + 1 === $codelen) || ((($idx + 1) < $codelen) - && (in_array(ord($code[($idx + 1)]), Data::TEXT_SUB_MODES[$submode])))) - && (($sub == 3) || (($sub == 0) && ($submode == 1)))) { + if ( + (($idx + 1 === $codelen) || ((($idx + 1) < $codelen) + && (in_array(ord($code[($idx + 1)]), Data::TEXT_SUB_MODES[$submode])))) + && (($sub == 3) || (($sub == 0) && ($submode == 1))) + ) { // shift (temporary change only for this char) $txtarr[] = $sub == 3 ? 29 : 27; } else { @@ -187,11 +185,10 @@ protected function processNumericCompaction(string $code, array &$codewords): vo * @return array of codewords */ protected function getCompaction( - int $mode, - string $code, + int $mode, + string $code, bool $addmode = true - ): array - { + ): array { $codewords = []; // array of codewords to return switch ($mode) { case 900: diff --git a/src/Type/Square/PdfFourOneSeven/Data.php b/src/Type/Square/PdfFourOneSeven/Data.php index 846c8cc1..4b760bae 100644 --- a/src/Type/Square/PdfFourOneSeven/Data.php +++ b/src/Type/Square/PdfFourOneSeven/Data.php @@ -177,7 +177,20 @@ abstract class Data /** * Array of switching codes for Text Compaction Sub-Modes */ - public const TEXT_LATCH = ['01' => [27], '02' => [28], '03' => [28, 25], '10' => [28, 28], '12' => [28], '13' => [28, 25], '20' => [28], '21' => [27], '23' => [25], '30' => [29], '31' => [29, 27], '32' => [29, 28]]; + public const TEXT_LATCH = [ + '01' => [27], + '02' => [28], + '03' => [28, 25], + '10' => [28, 28], + '12' => [28], + '13' => [28, 25], + '20' => [28], + '21' => [27], + '23' => [25], + '30' => [29], + '31' => [29, 27], + '32' => [29, 28], + ]; /** * Clusters of codewords (0, 3, 6). diff --git a/src/Type/Square/PdfFourOneSeven/Sequence.php b/src/Type/Square/PdfFourOneSeven/Sequence.php index 7fa55d0a..a55cf685 100644 --- a/src/Type/Square/PdfFourOneSeven/Sequence.php +++ b/src/Type/Square/PdfFourOneSeven/Sequence.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\Data; - /** * Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\Sequence * diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 8adea37e..61822bf1 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -17,10 +17,10 @@ namespace Com\Tecnick\Barcode\Type\Square; use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; use Com\Tecnick\Barcode\Type\Square\QrCode\ByteStream; -use Com\Tecnick\Barcode\Type\Square\QrCode\Split; +use Com\Tecnick\Barcode\Type\Square\QrCode\Data; use Com\Tecnick\Barcode\Type\Square\QrCode\Encoder; +use Com\Tecnick\Barcode\Type\Square\QrCode\Split; /** * Com\Tecnick\Barcode\Type\Square\QrCode @@ -107,47 +107,47 @@ protected function setParameters(): void parent::setParameters(); // level - if (!isset($this->params[0]) || !array_key_exists($this->params[0], Data::ECC_LEVELS)) { + if (! isset($this->params[0]) || ! array_key_exists($this->params[0], Data::ECC_LEVELS)) { $this->params[0] = 'L'; } $this->level = Data::ECC_LEVELS[$this->params[0]]; // hint - if (!isset($this->params[1]) || !array_key_exists($this->params[1], Data::ENC_MODES)) { + if (! isset($this->params[1]) || ! array_key_exists($this->params[1], Data::ENC_MODES)) { $this->params[1] = '8B'; } $this->hint = Data::ENC_MODES[$this->params[1]]; // version - if (!isset($this->params[2]) || ($this->params[2] < 0) || ($this->params[2] > Data::QRSPEC_VERSION_MAX)) { + if (! isset($this->params[2]) || ($this->params[2] < 0) || ($this->params[2] > Data::QRSPEC_VERSION_MAX)) { $this->params[2] = 0; } $this->version = (int) $this->params[2]; // case sensitive - if (!isset($this->params[3])) { + if (! isset($this->params[3])) { $this->params[3] = 1; } - $this->case_sensitive = (bool)$this->params[3]; + $this->case_sensitive = (bool) $this->params[3]; // random mask mode - number of masks to be checked - if (!empty($this->params[4])) { + if (! empty($this->params[4])) { $this->random_mask = (int) $this->params[4]; } // find best mask - if (!isset($this->params[5])) { + if (! isset($this->params[5])) { $this->params[5] = 1; } - $this->best_mask = (bool)$this->params[5]; + $this->best_mask = (bool) $this->params[5]; // default mask - if (!isset($this->params[6])) { + if (! isset($this->params[6])) { $this->params[6] = 2; } @@ -161,7 +161,7 @@ protected function setParameters(): void */ protected function setBars(): void { - if (strlen((string)$this->code) == 0) { + if (strlen((string) $this->code) == 0) { throw new BarcodeException('Empty input'); } @@ -201,7 +201,7 @@ protected function binarize(array $frame): array */ protected function encodeString(string $data): array { - if (!$this->case_sensitive) { + if (! $this->case_sensitive) { $data = $this->toUpper($data); } diff --git a/src/Type/Square/QrCode/ByteStream.php b/src/Type/Square/QrCode/ByteStream.php index 5c987448..e409bbb9 100644 --- a/src/Type/Square/QrCode/ByteStream.php +++ b/src/Type/Square/QrCode/ByteStream.php @@ -17,9 +17,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; -use Com\Tecnick\Barcode\Type\Square\QrCode\Estimate; -use Com\Tecnick\Barcode\Type\Square\QrCode\Spec; /** * Com\Tecnick\Barcode\Type\Square\QrCode\ByteStream @@ -78,8 +75,8 @@ protected function bitstreamToByte(array $bstream): array return []; } - $data = array_fill(0, (int)(($size + 7) / 8), 0); - $bytes = (int)($size / 8); + $data = array_fill(0, (int) (($size + 7) / 8), 0); + $bytes = (int) ($size / 8); $pos = 0; for ($idx = 0; $idx < $bytes; ++$idx) { $val = 0; @@ -146,7 +143,7 @@ protected function convertData(array $items): array throw new BarcodeException('Negative Bits value'); } - $ver = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level); + $ver = $this->getMinimumVersion((int) (($bits + 7) / 8), $this->level); if ($ver > $this->version) { $this->version = $ver; } else { @@ -160,7 +157,6 @@ protected function convertData(array $items): array /** * Create BitStream * - * * @return array of items and total bits */ protected function createBitStream(array $items): array @@ -178,7 +174,6 @@ protected function createBitStream(array $items): array /** * Encode BitStream * - * * @return array input item */ public function encodeBitStream(array $inputitem, int $version): array @@ -247,7 +242,7 @@ protected function appendPaddingBit(array $bstream): array } $bits += 4; - $words = (int)(($bits + 7) / 8); + $words = (int) (($bits + 7) / 8); $padding = []; $padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0); diff --git a/src/Type/Square/QrCode/Data.php b/src/Type/Square/QrCode/Data.php index 41b4c782..f96a3aef 100644 --- a/src/Type/Square/QrCode/Data.php +++ b/src/Type/Square/QrCode/Data.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\QrCode\Data * @@ -114,7 +112,14 @@ class Data * KJ : Encoding mode KANJI. A KANJI character (multibyte character) is encoded to 13bit length. * ST : Encoding mode STRUCTURED */ - public const ENC_MODES = ['NL' => -1, 'NM' => 0, 'AN' => 1, '8B' => 2, 'KJ' => 3, 'ST' => 4]; + public const ENC_MODES = [ + 'NL' => -1, + 'NM' => 0, + 'AN' => 1, + '8B' => 2, + 'KJ' => 3, + 'ST' => 4, + ]; /** * Array of valid error correction levels @@ -125,7 +130,12 @@ class Data * Q : About 25% or less errors can be corrected. * H : About 30% or less errors can be corrected. */ - public const ECC_LEVELS = ['L' => 0, 'M' => 1, 'Q' => 2, 'H' => 3]; + public const ECC_LEVELS = [ + 'L' => 0, + 'M' => 1, + 'Q' => 2, + 'H' => 3, + ]; /** * Alphabet-numeric conversion table. diff --git a/src/Type/Square/QrCode/Encode.php b/src/Type/Square/QrCode/Encode.php index e146fdde..f58c48fc 100644 --- a/src/Type/Square/QrCode/Encode.php +++ b/src/Type/Square/QrCode/Encode.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; - /** * Com\Tecnick\Barcode\Type\Square\QrCode\Encode * @@ -35,12 +32,11 @@ abstract class Encode extends \Com\Tecnick\Barcode\Type\Square\QrCode\EncodingMo /** * encode Mode Num * - * * @return array input item */ protected function encodeModeNum(array $inputitem, int $version): array { - $words = (int)($inputitem['size'] / 3); + $words = (int) ($inputitem['size'] / 3); $inputitem['bstream'] = []; $val = 0x1; $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); @@ -50,7 +46,7 @@ protected function encodeModeNum(array $inputitem, int $version): array $inputitem['size'] ); for ($i = 0; $i < $words; ++$i) { - $val = (ord($inputitem['data'][$i * 3 ]) - ord('0')) * 100; + $val = (ord($inputitem['data'][$i * 3]) - ord('0')) * 100; $val += (ord($inputitem['data'][$i * 3 + 1]) - ord('0')) * 10; $val += (ord($inputitem['data'][$i * 3 + 2]) - ord('0')); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val); @@ -60,7 +56,7 @@ protected function encodeModeNum(array $inputitem, int $version): array $val = ord($inputitem['data'][$words * 3]) - ord('0'); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val); } elseif (($inputitem['size'] - ($words * 3)) == 2) { - $val = (ord($inputitem['data'][$words * 3 ]) - ord('0')) * 10; + $val = (ord($inputitem['data'][$words * 3]) - ord('0')) * 10; $val += (ord($inputitem['data'][$words * 3 + 1]) - ord('0')); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val); } @@ -71,12 +67,11 @@ protected function encodeModeNum(array $inputitem, int $version): array /** * encode Mode An * - * * @return array input item */ protected function encodeModeAn(array $inputitem, int $version): array { - $words = (int)($inputitem['size'] / 2); + $words = (int) ($inputitem['size'] / 2); $inputitem['bstream'] = []; $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02); $inputitem['bstream'] = $this->appendNum( @@ -85,7 +80,7 @@ protected function encodeModeAn(array $inputitem, int $version): array $inputitem['size'] ); for ($idx = 0; $idx < $words; ++$idx) { - $val = $this->lookAnTable(ord($inputitem['data'][($idx * 2)])) * 45; + $val = $this->lookAnTable(ord($inputitem['data'][($idx * 2)])) * 45; $val += $this->lookAnTable(ord($inputitem['data'][($idx * 2) + 1])); $inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val); } @@ -101,7 +96,6 @@ protected function encodeModeAn(array $inputitem, int $version): array /** * encode Mode 8 * - * * @return array input item */ protected function encodeMode8(array $inputitem, int $version): array @@ -123,7 +117,6 @@ protected function encodeMode8(array $inputitem, int $version): array /** * encode Mode Kanji * - * * @return array input item */ protected function encodeModeKanji(array $inputitem, int $version): array @@ -133,7 +126,7 @@ protected function encodeModeKanji(array $inputitem, int $version): array $inputitem['bstream'] = $this->appendNum( $inputitem['bstream'], $this->getLengthIndicator(Data::ENC_MODES['KJ'], $version), - (int)($inputitem['size'] / 2) + (int) ($inputitem['size'] / 2) ); for ($idx = 0; $idx < $inputitem['size']; $idx += 2) { $val = (ord($inputitem['data'][$idx]) << 8) | ord($inputitem['data'][($idx + 1)]); @@ -153,7 +146,6 @@ protected function encodeModeKanji(array $inputitem, int $version): array /** * encode Mode Structure * - * * @return array input item */ protected function encodeModeStructure(array $inputitem): array diff --git a/src/Type/Square/QrCode/Encoder.php b/src/Type/Square/QrCode/Encoder.php index a3ed9633..7b225871 100644 --- a/src/Type/Square/QrCode/Encoder.php +++ b/src/Type/Square/QrCode/Encoder.php @@ -17,8 +17,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; -use Com\Tecnick\Barcode\Type\Square\QrCode\Spec; /** * Com\Tecnick\Barcode\Type\Square\QrCode\Encoder @@ -145,7 +143,10 @@ protected function getNextPosition(): array do { if ($this->bit == -1) { $this->bit = 0; - return ['x' => $this->xpos, 'y' => $this->ypos]; + return [ + 'x' => $this->xpos, + 'y' => $this->ypos, + ]; } $xpos = $this->xpos; @@ -160,7 +161,10 @@ protected function getNextPosition(): array $this->ypos = $ypos; } while (ord($this->frame[$ypos][$xpos]) & 0x80); - return ['x' => $xpos, 'y' => $ypos]; + return [ + 'x' => $xpos, + 'y' => $ypos, + ]; } /** diff --git a/src/Type/Square/QrCode/EncodingMode.php b/src/Type/Square/QrCode/EncodingMode.php index fc72b946..36abf0c7 100644 --- a/src/Type/Square/QrCode/EncodingMode.php +++ b/src/Type/Square/QrCode/EncodingMode.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; - /** * Com\Tecnick\Barcode\Type\Square\QrCode\EncodingMode * @@ -42,7 +39,7 @@ abstract class EncodingMode extends \Com\Tecnick\Barcode\Type\Square\QrCode\Inpu */ public function getEncodingMode(string $data, int $pos): int { - if (!isset($data[$pos])) { + if (! isset($data[$pos])) { return Data::ENC_MODES['NL']; } @@ -85,7 +82,7 @@ protected function getEncodingModeKj(string $data, int $pos): int */ public function isDigitAt(string $str, int $pos): bool { - if (!isset($str[$pos])) { + if (! isset($str[$pos])) { return false; } @@ -100,7 +97,7 @@ public function isDigitAt(string $str, int $pos): bool */ public function isAlphanumericAt(string $str, int $pos): bool { - if (!isset($str[$pos])) { + if (! isset($str[$pos])) { return false; } @@ -117,7 +114,7 @@ public function isAlphanumericAt(string $str, int $pos): bool */ protected function appendBitstream(array $bitstream, array $append): array { - if ((!is_array($append)) || (count($append) == 0)) { + if ((! is_array($append)) || (count($append) == 0)) { return $bitstream; } diff --git a/src/Type/Square/QrCode/Estimate.php b/src/Type/Square/QrCode/Estimate.php index 494580ea..b55ab36c 100644 --- a/src/Type/Square/QrCode/Estimate.php +++ b/src/Type/Square/QrCode/Estimate.php @@ -17,7 +17,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; /** * Com\Tecnick\Barcode\Type\Square\QrCode\Estimate @@ -50,7 +49,6 @@ abstract class Estimate */ protected int $level = 0; - /** * Return the size of length indicator for the mode and version * @@ -79,12 +77,11 @@ public function getLengthIndicator(int $mode, int $version): int /** * estimateBitsModeNum * - * * @return int number of bits */ public function estimateBitsModeNum(int $size): int { - $wdt = (int)($size / 3); + $wdt = (int) ($size / 3); $bits = ($wdt * 10); match ($size - ($wdt * 3)) { 1 => $bits += 4, @@ -97,12 +94,11 @@ public function estimateBitsModeNum(int $size): int /** * estimateBitsModeAn * - * * @return int number of bits */ public function estimateBitsModeAn(int $size): int { - $bits = (int)($size * 5.5); // (size / 2 ) * 11 + $bits = (int) ($size * 5.5); // (size / 2 ) * 11 if (($size & 1) !== 0) { $bits += 6; } @@ -113,7 +109,6 @@ public function estimateBitsModeAn(int $size): int /** * estimateBitsMode8 * - * * @return int number of bits */ public function estimateBitsMode8(int $size): int @@ -124,18 +119,16 @@ public function estimateBitsMode8(int $size): int /** * estimateBitsModeKanji * - * * @return int number of bits */ public function estimateBitsModeKanji(int $size): int { - return (int)($size * 6.5); // (size / 2 ) * 13 + return (int) ($size * 6.5); // (size / 2 ) * 13 } /** * Estimate version * - * * @return int version */ public function estimateVersion(array $items, int $level): int @@ -145,7 +138,7 @@ public function estimateVersion(array $items, int $level): int do { $prev = $version; $bits = $this->estimateBitStreamSize($items, $prev); - $version = $this->getMinimumVersion((int)(($bits + 7) / 8), $level); + $version = $this->getMinimumVersion((int) (($bits + 7) / 8), $level); if ($version < 0) { return -1; } @@ -181,7 +174,6 @@ protected function getMinimumVersion(int $size, int $level): int /** * estimateBitStreamSize * - * * @return int bits */ protected function estimateBitStreamSize(array $items, int $version): int @@ -213,7 +205,7 @@ protected function estimateBitStreamSize(array $items, int $version): int $len = $this->getLengthIndicator($item['mode'], $version); $mod = 1 << $len; - $num = (int)(($item['size'] + $mod - 1) / $mod); + $num = (int) (($item['size'] + $mod - 1) / $mod); $bits += $num * (4 + $len); } diff --git a/src/Type/Square/QrCode/Init.php b/src/Type/Square/QrCode/Init.php index d4b6c842..03a7009c 100644 --- a/src/Type/Square/QrCode/Init.php +++ b/src/Type/Square/QrCode/Init.php @@ -17,8 +17,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; -use Com\Tecnick\Barcode\Type\Square\QrCode\Spec; /** * Com\Tecnick\Barcode\Type\Square\QrCode\Init @@ -52,6 +50,7 @@ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask * Reed-Solomon blocks */ protected array $rsblocks = []; //of RSblock + /** * Counter */ @@ -144,16 +143,15 @@ protected function init(array $spec): void * Internal loop for init */ protected function initLoop( - int $endfor, - int $dlv, - int $elv, - array $rsv, - int &$eccPos, - int &$blockNo, - int &$dataPos, + int $endfor, + int $dlv, + int $elv, + array $rsv, + int &$eccPos, + int &$blockNo, + int &$dataPos, array &$ecc - ): void - { + ): void { for ($idx = 0; $idx < $endfor; ++$idx) { $ecc = array_slice($this->ecccode, $eccPos); $this->rsblocks[$blockNo] = []; @@ -194,14 +192,13 @@ protected function initLoop( * gfpoly. */ protected function initRs( - int $symsize, - int $gfpoly, - int $fcr, - int $prim, - int $nroots, + int $symsize, + int $gfpoly, + int $fcr, + int $prim, + int $nroots, int $pad - ): array - { + ): array { foreach ($this->rsitems as $rsv) { if ($rsv['pad'] != $pad) { continue; @@ -324,14 +321,13 @@ protected function checkRsCharParamsB(int $symsize, int $nroots, int $pad): void * gfpoly. */ protected function initRsChar( - int $symsize, - int $gfpoly, - int $fcr, - int $prim, - int $nroots, + int $symsize, + int $gfpoly, + int $fcr, + int $prim, + int $nroots, int $pad - ): array - { + ): array { $this->checkRsCharParamsA($symsize, $fcr, $prim); $this->checkRsCharParamsB($symsize, $nroots, $pad); $rsv = []; @@ -341,8 +337,8 @@ protected function initRsChar( $rsv['alpha_to'] = array_fill(0, ($rsv['nn'] + 1), 0); $rsv['index_of'] = array_fill(0, ($rsv['nn'] + 1), 0); // PHP style macro replacement - $nnv =& $rsv['nn']; - $azv =& $nnv; + $nnv = &$rsv['nn']; + $azv = &$nnv; // Generate Galois field lookup tables $rsv['index_of'][0] = $azv; // log(zero) = -inf $rsv['alpha_to'][$azv] = 0; // alpha**-inf = 0 @@ -373,7 +369,7 @@ protected function initRsChar( ; // intentional empty-body loop! } - $rsv['iprim'] = (int)($iprim / $prim); + $rsv['iprim'] = (int) ($iprim / $prim); $rsv['genpoly'][0] = 1; for ($idx = 0, $root = ($fcr * $prim); $idx < $nroots; ++$idx, $root += $prim) { $rsv['genpoly'][($idx + 1)] = 1; @@ -409,27 +405,26 @@ protected function initRsChar( * @return array Parity array */ protected function encodeRsChar( - array $rsv, - array $data, + array $rsv, + array $data, array $parity - ): array - { + ): array { // the total number of symbols in a RS block - $nnv =& $rsv['nn']; + $nnv = &$rsv['nn']; // the address of an array of NN elements to convert Galois field elements // in index (log) form to polynomial form - $alphato =& $rsv['alpha_to']; + $alphato = &$rsv['alpha_to']; // the address of an array of NN elements to convert Galois field elements // in polynomial form to index (log) form - $indexof =& $rsv['index_of']; + $indexof = &$rsv['index_of']; // an array of NROOTS+1 elements containing the generator polynomial in index form - $genpoly =& $rsv['genpoly']; + $genpoly = &$rsv['genpoly']; // the number of roots in the RS code generator polynomial, // which is the same as the number of parity symbols in a block - $nroots =& $rsv['nroots']; + $nroots = &$rsv['nroots']; // the number of pad symbols in a block - $pad =& $rsv['pad']; - $azv =& $nnv; + $pad = &$rsv['pad']; + $azv = &$nnv; $parity = array_fill(0, $nroots, 0); for ($idx = 0; $idx < ($nnv - $nroots - $pad); ++$idx) { $feedback = $indexof[$data[$idx] ^ $parity[0]]; diff --git a/src/Type/Square/QrCode/InputItem.php b/src/Type/Square/QrCode/InputItem.php index 6501b6f2..82fc7e7b 100644 --- a/src/Type/Square/QrCode/InputItem.php +++ b/src/Type/Square/QrCode/InputItem.php @@ -17,7 +17,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; /** * Com\Tecnick\Barcode\Type\Square\QrCode\InputItem @@ -54,12 +53,11 @@ public function lookAnTable(int $chr): int * @return array items */ public function appendNewInputItem( - array $items, - int $mode, - int $size, + array $items, + int $mode, + int $size, array $data - ): array - { + ): array { $newitem = $this->newInputItem($mode, $size, $data); if ($newitem !== []) { $items[] = $newitem; @@ -79,22 +77,26 @@ public function appendNewInputItem( * @return array input item */ protected function newInputItem( - int $mode, - int $size, - array $data, + int $mode, + int $size, + array $data, array $bstream = [] - ): array - { + ): array { $setData = array_slice($data, 0, $size); if (count($setData) < $size) { $setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0)); } - if (!$this->check($mode, $size, $setData)) { + if (! $this->check($mode, $size, $setData)) { throw new BarcodeException('Invalid input item'); } - return ['mode' => $mode, 'size' => $size, 'data' => $setData, 'bstream' => $bstream]; + return [ + 'mode' => $mode, + 'size' => $size, + 'data' => $setData, + 'bstream' => $bstream, + ]; } /** @@ -107,11 +109,10 @@ protected function newInputItem( * @return bool true in case of valid data, false otherwise */ protected function check( - int $mode, - int $size, + int $mode, + int $size, array $data - ): bool - { + ): bool { if ($size <= 0) { return false; } @@ -129,7 +130,6 @@ protected function check( /** * checkModeNum * - * * @return bool true or false */ protected function checkModeNum(int $size, array $data): bool @@ -146,7 +146,6 @@ protected function checkModeNum(int $size, array $data): bool /** * checkModeAn * - * * @return bool true or false */ protected function checkModeAn(int $size, array $data): bool @@ -163,7 +162,6 @@ protected function checkModeAn(int $size, array $data): bool /** * checkModeKanji * - * * @return bool true or false */ protected function checkModeKanji(int $size, array $data): bool diff --git a/src/Type/Square/QrCode/Mask.php b/src/Type/Square/QrCode/Mask.php index fc65d864..8c1df935 100644 --- a/src/Type/Square/QrCode/Mask.php +++ b/src/Type/Square/QrCode/Mask.php @@ -16,10 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; -use Com\Tecnick\Barcode\Type\Square\QrCode\Spec; - /** * Com\Tecnick\Barcode\Type\Square\QrCode\Mask * @@ -60,16 +56,15 @@ public function __construct( * Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. * So version 40 is 177*177 matrix. */ - public int $version, + public int $version, /** * Error correction level */ - protected int $level, - protected bool $qr_find_from_random = false, - protected bool $qr_find_best_mask = true, + protected int $level, + protected bool $qr_find_from_random = false, + protected bool $qr_find_best_mask = true, protected int $qr_default_mask = 2 - ) - { + ) { $this->spc = new Spec(); } @@ -83,17 +78,16 @@ public function __construct( * @return array best mask */ protected function mask( - int $width, - array $frame, + int $width, + array $frame, int $level - ): array - { + ): array { $minDemerit = PHP_INT_MAX; $bestMask = []; $checked_masks = [0, 1, 2, 3, 4, 5, 6, 7]; if ($this->qr_find_from_random) { $howManuOut = (8 - ($this->qr_find_from_random % 9)); - for ($idx = 0; $idx < $howManuOut; ++$idx) { + for ($idx = 0; $idx < $howManuOut; ++$idx) { $remPos = random_int(0, (count($checked_masks) - 1)); unset($checked_masks[$remPos]); $checked_masks = array_values($checked_masks); @@ -104,10 +98,10 @@ protected function mask( foreach ($checked_masks as $checked_mask) { $mask = array_fill(0, $width, str_repeat("\0", $width)); $demerit = 0; - $blacks = $this->makeMaskNo($checked_mask, $width, $frame, $mask); + $blacks = $this->makeMaskNo($checked_mask, $width, $frame, $mask); $blacks += $this->writeFormatInformation($width, $mask, $checked_mask, $level); - $blacks = (int)(100 * $blacks / ($width * $width)); - $demerit = (int)(abs($blacks - 50) / 5) * Data::N4; + $blacks = (int) (100 * $blacks / ($width * $width)); + $demerit = (int) (abs($blacks - 50) / 5) * Data::N4; $demerit += $this->evaluateSymbol($width, $mask); if ($demerit < $minDemerit) { $minDemerit = $demerit; @@ -129,12 +123,11 @@ protected function mask( * @return array mask */ protected function makeMask( - int $width, - array $frame, - int $maskNo, + int $width, + array $frame, + int $maskNo, int $level - ): array - { + ): array { $this->makeMaskNo($maskNo, $width, $frame, $mask); $this->writeFormatInformation($width, $mask, $maskNo, $level); return $mask; @@ -151,15 +144,14 @@ protected function makeMask( * @return int blacks */ protected function writeFormatInformation( - int $width, - array &$frame, - int $maskNo, + int $width, + array &$frame, + int $maskNo, int $level - ): int - { + ): int { $blacks = 0; $spec = new Spec(); - $format = $spec->getFormatInfo($maskNo, $level); + $format = $spec->getFormatInfo($maskNo, $level); for ($idx = 0; $idx < 8; ++$idx) { if (($format & 1) !== 0) { $blacks += 2; @@ -248,12 +240,11 @@ protected function evaluateSymbol(int $width, array $frame): int * @return int demerit */ protected function evaluateSymbolB( - int $ypos, - int $width, - string $frameY, + int $ypos, + int $width, + string $frameY, string $frameYM - ): int - { + ): int { $head = 0; $demerit = 0; $this->runLength[0] = 1; @@ -292,7 +283,6 @@ protected function evaluateSymbolB( /** * Calc N1 N3 * - * * @return int demerit */ protected function calcN1N3(int $length): int @@ -314,12 +304,11 @@ protected function calcN1N3(int $length): int /** * Calc N1 N3 delta * - * * @return int demerit delta */ protected function calcN1N3delta(int $length, int $idx): int { - $fact = (int)($this->runLength[$idx] / 3); + $fact = (int) ($this->runLength[$idx] / 3); if ( ($this->runLength[($idx - 2)] == $fact) && ($this->runLength[($idx - 1)] == $fact) diff --git a/src/Type/Square/QrCode/MaskNum.php b/src/Type/Square/QrCode/MaskNum.php index b623536f..367c67a1 100644 --- a/src/Type/Square/QrCode/MaskNum.php +++ b/src/Type/Square/QrCode/MaskNum.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; - /** * Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum * @@ -43,19 +40,18 @@ abstract class MaskNum * @return int mask number */ protected function makeMaskNo( - int $maskNo, - int $width, - array $frame, + int $maskNo, + int $width, + array $frame, array &$mask - ): int - { + ): int { $bnum = 0; $bitMask = $this->generateMaskNo($maskNo, $width, $frame); $mask = $frame; for ($ypos = 0; $ypos < $width; ++$ypos) { for ($xpos = 0; $xpos < $width; ++$xpos) { if ($bitMask[$ypos][$xpos] == 1) { - $mask[$ypos][$xpos] = chr(ord($frame[$ypos][$xpos]) ^ ((int)($bitMask[$ypos][$xpos]))); + $mask[$ypos][$xpos] = chr(ord($frame[$ypos][$xpos]) ^ ((int) ($bitMask[$ypos][$xpos]))); } $bnum += ord($mask[$ypos][$xpos]) & 1; @@ -76,10 +72,9 @@ protected function makeMaskNo( */ protected function generateMaskNo( int $maskNo, - int $width, + int $width, array $frame - ): array - { + ): array { $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); for ($ypos = 0; $ypos < $width; ++$ypos) { for ($xpos = 0; $xpos < $width; ++$xpos) { @@ -157,7 +152,7 @@ protected function mask3(int $xpos, int $ypos): int */ protected function mask4(int $xpos, int $ypos): int { - return ((((int)($ypos / 2)) + ((int)($xpos / 3))) & 1); + return ((((int) ($ypos / 2)) + ((int) ($xpos / 3))) & 1); } /** diff --git a/src/Type/Square/QrCode/Spec.php b/src/Type/Square/QrCode/Spec.php index 1214c880..f11f8319 100644 --- a/src/Type/Square/QrCode/Spec.php +++ b/src/Type/Square/QrCode/Spec.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; - /** * Com\Tecnick\Barcode\Type\Square\QrCode\Spec * @@ -135,14 +132,14 @@ public function getEccSpec(int $version, int $level, array $spec): array $ecc = $this->getECCLength($version, $level); if ($bv2 == 0) { $spec[0] = $bv1; - $spec[1] = (int)($data / $bv1); /* @phpstan-ignore-line */ - $spec[2] = (int)($ecc / $bv1); /* @phpstan-ignore-line */ + $spec[1] = (int) ($data / $bv1); /* @phpstan-ignore-line */ + $spec[2] = (int) ($ecc / $bv1); /* @phpstan-ignore-line */ $spec[3] = 0; $spec[4] = 0; } else { $spec[0] = $bv1; - $spec[1] = (int)($data / ($bv1 + $bv2)); - $spec[2] = (int)($ecc / ($bv1 + $bv2)); + $spec[1] = (int) ($data / ($bv1 + $bv2)); + $spec[2] = (int) ($ecc / ($bv1 + $bv2)); $spec[3] = $bv2; $spec[4] = $spec[1] + 1; } diff --git a/src/Type/Square/QrCode/SpecRs.php b/src/Type/Square/QrCode/SpecRs.php index d3b0e141..08b78628 100644 --- a/src/Type/Square/QrCode/SpecRs.php +++ b/src/Type/Square/QrCode/SpecRs.php @@ -16,9 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; -use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; - /** * Com\Tecnick\Barcode\Type\Square\QrCode\SpecRs * @@ -37,7 +34,6 @@ abstract class SpecRs /** * Return block number 0 * - * * @return int value */ public function rsBlockNum(array $spec): int @@ -48,7 +44,6 @@ public function rsBlockNum(array $spec): int /** * Return block number 1 * - * * @return int value */ public function rsBlockNum1(array $spec): int @@ -59,7 +54,6 @@ public function rsBlockNum1(array $spec): int /** * Return data codes 1 * - * * @return int value */ public function rsDataCodes1(array $spec): int @@ -70,7 +64,6 @@ public function rsDataCodes1(array $spec): int /** * Return ecc codes 1 * - * * @return int value */ public function rsEccCodes1(array $spec): int @@ -81,7 +74,6 @@ public function rsEccCodes1(array $spec): int /** * Return block number 2 * - * * @return int value */ public function rsBlockNum2(array $spec): int @@ -92,7 +84,6 @@ public function rsBlockNum2(array $spec): int /** * Return data codes 2 * - * * @return int value */ public function rsDataCodes2(array $spec): int @@ -103,7 +94,6 @@ public function rsDataCodes2(array $spec): int /** * Return ecc codes 2 * - * * @return int value */ public function rsEccCodes2(array $spec): int @@ -114,7 +104,6 @@ public function rsEccCodes2(array $spec): int /** * Return data length * - * * @return int value */ public function rsDataLength(array $spec): int @@ -125,7 +114,6 @@ public function rsDataLength(array $spec): int /** * Return ecc length * - * * @return int value */ public function rsEccLength(array $spec): int @@ -217,13 +205,12 @@ public function createFrame(int $version): array * @return array srctab */ public function qrstrset( - array $srctab, - int $xpos, - int $ypos, - string $repl, + array $srctab, + int $xpos, + int $ypos, + string $repl, int $replLen = null - ): array - { + ): array { $srctab[$ypos] = substr_replace( $srctab[$ypos], ($replLen !== null) ? substr($repl, 0, $replLen) : $repl, @@ -243,11 +230,10 @@ public function qrstrset( * @return array frame */ public function putAlignmentMarker( - array $frame, - int $pox, + array $frame, + int $pox, int $poy - ): array - { + ): array { $finder = ["\xa1\xa1\xa1\xa1\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa0\xa1\xa0\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa1\xa1\xa1\xa1"]; $yStart = $poy - 2; $xStart = $pox - 2; @@ -268,11 +254,10 @@ public function putAlignmentMarker( * @return array frame */ public function putFinderPattern( - array $frame, - int $pox, + array $frame, + int $pox, int $poy - ): array - { + ): array { $finder = ["\xc1\xc1\xc1\xc1\xc1\xc1\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc1\xc1\xc1\xc1\xc1\xc1"]; for ($ypos = 0; $ypos < 7; ++$ypos) { $frame = $this->qrstrset($frame, $pox, ($poy + $ypos), $finder[$ypos]); @@ -306,11 +291,10 @@ public function getVersionPattern(int $version): int * @return array frame */ public function putAlignmentPattern( - int $version, - array $frame, + int $version, + array $frame, int $width - ): array - { + ): array { if ($version < 2) { return $frame; } @@ -319,7 +303,7 @@ public function putAlignmentPattern( if ($dval < 0) { $wdt = 2; } else { - $wdt = (int)(($width - Data::ALIGN_PATTERN[$version][0]) / $dval + 2); + $wdt = (int) (($width - Data::ALIGN_PATTERN[$version][0]) / $dval + 2); } if ($wdt * $wdt - 3 == 1) { diff --git a/src/Type/Square/QrCode/Split.php b/src/Type/Square/QrCode/Split.php index 732834fb..3809c34c 100644 --- a/src/Type/Square/QrCode/Split.php +++ b/src/Type/Square/QrCode/Split.php @@ -17,9 +17,6 @@ namespace Com\Tecnick\Barcode\Type\Square\QrCode; use Com\Tecnick\Barcode\Exception as BarcodeException; -use Com\Tecnick\Barcode\Type\Square\QrCode\Data; -use Com\Tecnick\Barcode\Type\Square\QrCode\ByteStream; -use Com\Tecnick\Barcode\Type\Square\QrCode\EncodingMode; /** * Com\Tecnick\Barcode\Type\Square\QrCode\Split @@ -62,8 +59,7 @@ public function __construct( * So version 40 is 177*177 matrix. */ protected int $version - ) - { + ) { } /** @@ -139,7 +135,7 @@ protected function eatNum(string $data): int if ($mode == Data::ENC_MODES['AN']) { $dif = $this->encodingMode->estimateBitsModeNum($pos) + 4 + $lng + $this->encodingMode->estimateBitsModeAn(1) // + 4 + la - - $this->encodingMode->estimateBitsModeAn($pos + 1);// - 4 - la + - $this->encodingMode->estimateBitsModeAn($pos + 1); // - 4 - la if ($dif > 0) { return $this->eatAn($data); } @@ -158,14 +154,14 @@ protected function eatNum(string $data): int * eatAn * * @param string $data Data - * + * * @return int run */ protected function eatAn(string $data): int { $lag = $this->encodingMode->getLengthIndicator(Data::ENC_MODES['AN'], $this->version); $lng = $this->encodingMode->getLengthIndicator(Data::ENC_MODES['NM'], $this->version); - $pos = 1 ; + $pos = 1; while ($this->encodingMode->isAlphanumericAt($data, $pos)) { if ($this->encodingMode->isDigitAt($data, $pos)) { $qix = $pos; @@ -186,7 +182,7 @@ protected function eatAn(string $data): int } } - if (!$this->encodingMode->isAlphanumericAt($data, $pos)) { + if (! $this->encodingMode->isAlphanumericAt($data, $pos)) { $dif = $this->encodingMode->estimateBitsModeAn($pos) + 4 + $lag + $this->encodingMode->estimateBitsMode8(1) // + 4 + l8 - $this->encodingMode->estimateBitsMode8($pos + 1); // - 4 - l8 @@ -208,7 +204,7 @@ protected function eatAn(string $data): int * eatKanji * * @param string $data Data - * + * * @return int run */ protected function eatKanji(string $data): int @@ -231,7 +227,7 @@ protected function eatKanji(string $data): int * eat8 * * @param string $data Data - * + * * @return int run */ protected function eat8(string $data): int diff --git a/src/Type/Square/Raw.php b/src/Type/Square/Raw.php index dffcee2f..118fa157 100644 --- a/src/Type/Square/Raw.php +++ b/src/Type/Square/Raw.php @@ -16,8 +16,6 @@ namespace Com\Tecnick\Barcode\Type\Square; -use Com\Tecnick\Barcode\Exception as BarcodeException; - /** * Com\Tecnick\Barcode\Type\Square\Raw * diff --git a/test/BarcodeTest.php b/test/BarcodeTest.php index 2d4209b8..a66a7c91 100644 --- a/test/BarcodeTest.php +++ b/test/BarcodeTest.php @@ -16,8 +16,6 @@ namespace Test; -use PHPUnit\Framework\TestCase; - /** * Barcode class test * @@ -148,7 +146,12 @@ public function testExportMethods(): void $this->assertEquals(4, $barr['height']); $this->assertEquals(2, $barr['width_ratio']); $this->assertEquals(2, $barr['height_ratio']); - $this->assertEquals(['T' => 4, 'R' => 3, 'B' => 0, 'L' => 1], $barr['padding']); + $this->assertEquals([ + 'T' => 4, + 'R' => 3, + 'B' => 0, + 'L' => 1, + ], $barr['padding']); $this->assertEquals(44, $barr['full_width']); $this->assertEquals(8, $barr['full_height']); diff --git a/test/Linear/CodabarTest.php b/test/Linear/CodabarTest.php index ca33fd15..b1355705 100644 --- a/test/Linear/CodabarTest.php +++ b/test/Linear/CodabarTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeNineThreeTest.php b/test/Linear/CodeNineThreeTest.php index eaa9a02b..f89aad3e 100644 --- a/test/Linear/CodeNineThreeTest.php +++ b/test/Linear/CodeNineThreeTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** @@ -46,7 +45,6 @@ public function testGetGrid(): void . "1001001001000101010100001000100101000010101001011001001100101010111101\n"; $this->assertEquals($expected, $grid); - $bobj = $barcode->getBarcodeObj('C93', '012345678901234567890123456789'); $grid = $bobj->getGrid(); $expected = "10101111010001010010100100010100010010100001010010100010010010010010001010101" diff --git a/test/Linear/CodeOneOneTest.php b/test/Linear/CodeOneOneTest.php index a877d992..924d5705 100644 --- a/test/Linear/CodeOneOneTest.php +++ b/test/Linear/CodeOneOneTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeOneTwoEight/CodeOneTwoEightATest.php b/test/Linear/CodeOneTwoEight/CodeOneTwoEightATest.php index ef43e904..6c190246 100644 --- a/test/Linear/CodeOneTwoEight/CodeOneTwoEightATest.php +++ b/test/Linear/CodeOneTwoEight/CodeOneTwoEightATest.php @@ -16,7 +16,6 @@ namespace Test\Linear\CodeOneTwoEight; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeOneTwoEight/CodeOneTwoEightBTest.php b/test/Linear/CodeOneTwoEight/CodeOneTwoEightBTest.php index 6e56e66c..7f34f76c 100644 --- a/test/Linear/CodeOneTwoEight/CodeOneTwoEightBTest.php +++ b/test/Linear/CodeOneTwoEight/CodeOneTwoEightBTest.php @@ -16,7 +16,6 @@ namespace Test\Linear\CodeOneTwoEight; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeOneTwoEight/CodeOneTwoEightCTest.php b/test/Linear/CodeOneTwoEight/CodeOneTwoEightCTest.php index 098ba0e4..ce7e1145 100644 --- a/test/Linear/CodeOneTwoEight/CodeOneTwoEightCTest.php +++ b/test/Linear/CodeOneTwoEight/CodeOneTwoEightCTest.php @@ -16,7 +16,6 @@ namespace Test\Linear\CodeOneTwoEight; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeOneTwoEightTest.php b/test/Linear/CodeOneTwoEightTest.php index 6d655f6d..df3c329d 100644 --- a/test/Linear/CodeOneTwoEightTest.php +++ b/test/Linear/CodeOneTwoEightTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeThreeNineCheckTest.php b/test/Linear/CodeThreeNineCheckTest.php index f36938e9..57dc3dd4 100644 --- a/test/Linear/CodeThreeNineCheckTest.php +++ b/test/Linear/CodeThreeNineCheckTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeThreeNineExtCheckTest.php b/test/Linear/CodeThreeNineExtCheckTest.php index db1ef6a8..de9e539c 100644 --- a/test/Linear/CodeThreeNineExtCheckTest.php +++ b/test/Linear/CodeThreeNineExtCheckTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeThreeNineExtTest.php b/test/Linear/CodeThreeNineExtTest.php index fab280eb..c99d90d2 100644 --- a/test/Linear/CodeThreeNineExtTest.php +++ b/test/Linear/CodeThreeNineExtTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/CodeThreeNineTest.php b/test/Linear/CodeThreeNineTest.php index 5bba68cb..bf41fd62 100644 --- a/test/Linear/CodeThreeNineTest.php +++ b/test/Linear/CodeThreeNineTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/EanEightTest.php b/test/Linear/EanEightTest.php index 175431a6..6c72b65f 100644 --- a/test/Linear/EanEightTest.php +++ b/test/Linear/EanEightTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/EanFiveTest.php b/test/Linear/EanFiveTest.php index b4b06bce..9f09365a 100644 --- a/test/Linear/EanFiveTest.php +++ b/test/Linear/EanFiveTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/EanOneThreeTest.php b/test/Linear/EanOneThreeTest.php index 59efa55e..2afbff79 100644 --- a/test/Linear/EanOneThreeTest.php +++ b/test/Linear/EanOneThreeTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/EanTwoTest.php b/test/Linear/EanTwoTest.php index b5007b76..0f5bc11e 100644 --- a/test/Linear/EanTwoTest.php +++ b/test/Linear/EanTwoTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/ImbPreTest.php b/test/Linear/ImbPreTest.php index a2332b5f..ce2a46e9 100644 --- a/test/Linear/ImbPreTest.php +++ b/test/Linear/ImbPreTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/ImbTest.php b/test/Linear/ImbTest.php index d68a47c1..3eae9b54 100644 --- a/test/Linear/ImbTest.php +++ b/test/Linear/ImbTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/InterleavedTwoOfFiveCheckTest.php b/test/Linear/InterleavedTwoOfFiveCheckTest.php index c7f9d49d..35ddaa83 100644 --- a/test/Linear/InterleavedTwoOfFiveCheckTest.php +++ b/test/Linear/InterleavedTwoOfFiveCheckTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/InterleavedTwoOfFiveTest.php b/test/Linear/InterleavedTwoOfFiveTest.php index ddc2cb25..5aa36cf6 100644 --- a/test/Linear/InterleavedTwoOfFiveTest.php +++ b/test/Linear/InterleavedTwoOfFiveTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/KlantIndexTest.php b/test/Linear/KlantIndexTest.php index c0285072..6a65e060 100644 --- a/test/Linear/KlantIndexTest.php +++ b/test/Linear/KlantIndexTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/MsiCheckTest.php b/test/Linear/MsiCheckTest.php index 6b64b894..90805c29 100644 --- a/test/Linear/MsiCheckTest.php +++ b/test/Linear/MsiCheckTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/MsiTest.php b/test/Linear/MsiTest.php index f623074b..444c6e93 100644 --- a/test/Linear/MsiTest.php +++ b/test/Linear/MsiTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/PharmaTest.php b/test/Linear/PharmaTest.php index cb8ca433..6960960f 100644 --- a/test/Linear/PharmaTest.php +++ b/test/Linear/PharmaTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/PharmaTwoTracksTest.php b/test/Linear/PharmaTwoTracksTest.php index c0b16f7d..776f3b08 100644 --- a/test/Linear/PharmaTwoTracksTest.php +++ b/test/Linear/PharmaTwoTracksTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/PlanetTest.php b/test/Linear/PlanetTest.php index 1d057a4c..e7c1005e 100644 --- a/test/Linear/PlanetTest.php +++ b/test/Linear/PlanetTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/PostnetTest.php b/test/Linear/PostnetTest.php index cc2005ba..4e3458bb 100644 --- a/test/Linear/PostnetTest.php +++ b/test/Linear/PostnetTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/RawTest.php b/test/Linear/RawTest.php index 04597103..a6f04cc2 100644 --- a/test/Linear/RawTest.php +++ b/test/Linear/RawTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/RoyalMailFourCcTest.php b/test/Linear/RoyalMailFourCcTest.php index b30d3509..0bd3e585 100644 --- a/test/Linear/RoyalMailFourCcTest.php +++ b/test/Linear/RoyalMailFourCcTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/StandardTwoOfFiveCheckTest.php b/test/Linear/StandardTwoOfFiveCheckTest.php index 26e27172..9c91ea65 100644 --- a/test/Linear/StandardTwoOfFiveCheckTest.php +++ b/test/Linear/StandardTwoOfFiveCheckTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/StandardTwoOfFiveTest.php b/test/Linear/StandardTwoOfFiveTest.php index 4bde71ff..c753ad26 100644 --- a/test/Linear/StandardTwoOfFiveTest.php +++ b/test/Linear/StandardTwoOfFiveTest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/UpcATest.php b/test/Linear/UpcATest.php index f212eda1..d8d87d14 100644 --- a/test/Linear/UpcATest.php +++ b/test/Linear/UpcATest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Linear/UpcETest.php b/test/Linear/UpcETest.php index 529b4c76..eeb5f2f0 100644 --- a/test/Linear/UpcETest.php +++ b/test/Linear/UpcETest.php @@ -16,7 +16,6 @@ namespace Test\Linear; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Square/AztecTest.php b/test/Square/AztecTest.php index f1c76756..5e7f4b31 100644 --- a/test/Square/AztecTest.php +++ b/test/Square/AztecTest.php @@ -16,7 +16,6 @@ namespace Test\Square; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Square/DatamatrixTest.php b/test/Square/DatamatrixTest.php index 53ba0ddc..9d6b632a 100644 --- a/test/Square/DatamatrixTest.php +++ b/test/Square/DatamatrixTest.php @@ -16,7 +16,6 @@ namespace Test\Square; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** @@ -124,26 +123,26 @@ public static function getGridDataProvider(): array . 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\' . 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\', '0b2921466e097ff9cc1ad63719430540'], ['DATAMATRIX', chr(128) - . chr(138) - . chr(148) - . chr(158), '9300000cee5a5f7b3b48145d44aa7fff'], + . chr(138) + . chr(148) + . chr(158), '9300000cee5a5f7b3b48145d44aa7fff'], ['DATAMATRIX', '!"£$%^&*()-+_={}[]\'#@~;:/?,.<>|', '4993e149fd20569c8a4f0d758b6dfa76'], ['DATAMATRIX', '!"£$', '792181edb48c6722217dc7e2e4cd4095'], ['DATAMATRIX', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\1234567890', '7360a5a6c25476711139ae1244f56c29'], ['DATAMATRIX', chr(254) - . chr(253) + . chr(253) . 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\' . chr(252) - . chr(251), '0f078e5e5735396312245740484fa6d1'], + . chr(251), '0f078e5e5735396312245740484fa6d1'], ['DATAMATRIX', 'aABCDEFG', 'f074dee3f0f386d9b2f30b1ce4ad08a8'], ['DATAMATRIX', '123 45678', '6c2e6503625e408fe9a4e392743f31a8'], ['DATAMATRIX', 'DATA MATRIX', '3ba4f4ef8449d795813b353ddcce4d23'], ['DATAMATRIX', '123ABCD89', '7ce2f8433b82c16e80f4a4c59cad5d10'], ['DATAMATRIX', 'AB/C123-X', '703318e1964c63d5d500d14a821827cd'], ['DATAMATRIX', str_pad('', 300, chr(254) - . chr(253) - . chr(252) - . chr(251)), 'e524bb17821d0461f3db6f313d35018f'], + . chr(253) + . chr(252) + . chr(251)), 'e524bb17821d0461f3db6f313d35018f'], ['DATAMATRIX', 'ec:b47' . chr(127) . '4#P d*b}gI2#DB|hl{!~[EYH*=cmR{lf' . chr(127) . '=gcGIa.st286. #*"!eG[.Ryr?Kn,1mIyQqC3 6\'3N>', '57fbb9bfb7d542e2e5eadb615e6be549'], ['DATAMATRIX', 'eA211101A2raJTGL/r9o93CVk4gtpEvWd2A2Qz8jvPc7l8ybD3m' diff --git a/test/Square/PdfFourOneSevenTest.php b/test/Square/PdfFourOneSevenTest.php index 14cbe59e..0e1c61ba 100644 --- a/test/Square/PdfFourOneSevenTest.php +++ b/test/Square/PdfFourOneSevenTest.php @@ -16,7 +16,6 @@ namespace Test\Square; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/Square/QrCodeTest.php b/test/Square/QrCodeTest.php index 3f474e7e..d62b09c3 100644 --- a/test/Square/QrCodeTest.php +++ b/test/Square/QrCodeTest.php @@ -16,7 +16,6 @@ namespace Test\Square; -use PHPUnit\Framework\TestCase; use Test\TestUtil; /** diff --git a/test/TestStrings.php b/test/TestStrings.php index f3ca68ff..c6d9cf4e 100644 --- a/test/TestStrings.php +++ b/test/TestStrings.php @@ -1,4 +1,5 @@ Date: Mon, 20 Nov 2023 12:23:05 +0000 Subject: [PATCH 059/100] ASCII --- src/Barcode.php | 51 +- src/Type.php | 83 +- src/Type/Convert.php | 14 +- src/Type/Linear/CodeNineThree.php | 182 +- src/Type/Linear/CodeOneTwoEight/Process.php | Bin 12579 -> 12000 bytes src/Type/Linear/CodeThreeNineExtCheck.php | 177 +- src/Type/Linear/Imb.php | 272 ++- src/Type/Square/Aztec/Bitstream.php | 6 +- src/Type/Square/Datamatrix/Data.php | 570 ++++- src/Type/Square/Datamatrix/Encode.php | 13 +- .../Square/PdfFourOneSeven/Compaction.php | 5 +- src/Type/Square/QrCode/SpecRs.php | 18 +- test/BarcodeTest.php | 11 +- test/Square/AztecTest.php | 217 +- test/Square/DatamatrixTest.php | 619 +++--- test/Square/QrCodeTest.php | 1844 +++-------------- 16 files changed, 2041 insertions(+), 2041 deletions(-) diff --git a/src/Barcode.php b/src/Barcode.php index 4958b487..4c8e0973 100644 --- a/src/Barcode.php +++ b/src/Barcode.php @@ -3,13 +3,13 @@ /** * Barcode.php * - * @since 2015-02-21 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode * * This file is part of tc-lib-barcode software library. */ @@ -23,13 +23,13 @@ * * Barcode Barcode class * - * @since 2015-02-21 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode */ class Barcode { @@ -81,15 +81,20 @@ class Barcode /** * Get the barcode object * - * @param string $type Barcode type - * @param string|array $code Barcode content - * @param int $width Barcode width in user units (excluding padding). - * A negative value indicates the multiplication factor for each column. - * @param int $height Barcode height in user units (excluding padding). - * A negative value indicates the multiplication factor for each row. - * @param string $color Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax) - * @param array{int, int, int, int} $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. - * A negative value indicates the multiplication factor for each row or column. + * @param string $type Barcode type + * @param string|array $code Barcode content + * @param int $width Barcode width in user units (excluding padding). + * A negative value indicates the multiplication + * factor for each column. + * @param int $height Barcode height in user units (excluding padding). + * A negative value indicates the multiplication + * factor for each row. + * @param string $color Foreground color in Web notation + * (color name, or hexadecimal code, or CSS syntax) + * @param array{int, int, int, int} $padding Additional padding to add around the barcode + * (top, right, bottom, left) in user units. A + * negative value indicates the multiplication + * factor for each row or column. * * @throws BarcodeException in case of error */ diff --git a/src/Type.php b/src/Type.php index a694ab0f..829b0b6c 100644 --- a/src/Type.php +++ b/src/Type.php @@ -3,13 +3,13 @@ /** * Type.php * - * @since 2015-02-21 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode * * This file is part of tc-lib-barcode software library. */ @@ -26,28 +26,33 @@ * * Barcode Type class * - * @since 2015-02-21 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode */ abstract class Type extends \Com\Tecnick\Barcode\Type\Convert { /** * Initialize a new barcode object * - * @param string|array $code Barcode content - * @param int $width Barcode width in user units (excluding padding). - * A negative value indicates the multiplication factor for each column. - * @param int $height Barcode height in user units (excluding padding). - * A negative value indicates the multiplication factor for each row. - * @param string $color Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax) - * @param array $params Array containing extra parameters for the specified barcode type - * @param array{int, int, int, int} $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. - * A negative value indicates the number or rows or columns. + * @param string|array $code Barcode content + * @param int $width Barcode width in user units (excluding padding). + * A negative value indicates the multiplication + * factor for each column. + * @param int $height Barcode height in user units (excluding padding). + * A negative value indicates the multiplication + * factor for each row. + * @param string $color Foreground color in Web notation + * (color name, or hexadecimal code, or CSS syntax) + * @param array $params Array containing extra parameters for the specified barcode type + * @param array{int, int, int, int} $padding Additional padding to add around the barcode + * (top, right, bottom, left) in user units. A + * negative value indicates the number or rows + * or columns. * * @throws BarcodeException in case of error * @throws ColorException in case of color error @@ -86,12 +91,16 @@ abstract protected function setBars(): void; /** * Set the size of the barcode to be exported * - * @param int $width Barcode width in user units (excluding padding). - * A negative value indicates the multiplication factor for each column. - * @param int $height Barcode height in user units (excluding padding). - * A negative value indicates the multiplication factor for each row. - * @param array{int, int, int, int} $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. - * A negative value indicates the number or rows or columns. + * @param int $width Barcode width in user units (excluding padding). + * A negative value indicates the multiplication + * factor for each column. + * @param int $height Barcode height in user units (excluding padding). + * A negative value indicates the multiplication + * factor for each row. + * @param array{int, int, int, int} $padding Additional padding to add around the barcode + * (top, right, bottom, left) in user units. A + * negative value indicates the number or rows + * or columns. */ public function setSize( int $width, @@ -119,18 +128,26 @@ public function setSize( /** * Set the barcode padding * - * @param array{int, int, int, int} $padding Additional padding to add around the barcode (top, right, bottom, left) in user units. - * A negative value indicates the number or rows or columns. + * @param array{int, int, int, int} $padding Additional padding to add around the barcode + * (top, right, bottom, left) in user units. + * A negative value indicates the number or rows or columns. * * @throws BarcodeException in case of error */ protected function setPadding(array $padding): static { if (! is_array($padding) || (count($padding) != 4)) { - throw new BarcodeException('Invalid padding, expecting an array of 4 numbers (top, right, bottom, left)'); + throw new BarcodeException( + 'Invalid padding, expecting an array of 4 numbers (top, right, bottom, left)' + ); } - $map = [['T', $this->height_ratio], ['R', $this->width_ratio], ['B', $this->height_ratio], ['L', $this->width_ratio]]; + $map = [ + ['T', $this->height_ratio], + ['R', $this->width_ratio], + ['B', $this->height_ratio], + ['L', $this->width_ratio], + ]; foreach ($padding as $key => $val) { $val = (int) $val; if ($val < 0) { diff --git a/src/Type/Convert.php b/src/Type/Convert.php index 217be2e2..9d1f0340 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -248,7 +248,12 @@ protected function getRotatedBarArray(): array */ protected function getBarRectXYXY(array $bar): array { - return [($this->padding['L'] + ($bar[0] * $this->width_ratio)), ($this->padding['T'] + ($bar[1] * $this->height_ratio)), ($this->padding['L'] + (($bar[0] + $bar[2]) * $this->width_ratio) - 1), ($this->padding['T'] + (($bar[1] + $bar[3]) * $this->height_ratio) - 1)]; + return [ + ($this->padding['L'] + ($bar[0] * $this->width_ratio)), + ($this->padding['T'] + ($bar[1] * $this->height_ratio)), + ($this->padding['L'] + (($bar[0] + $bar[2]) * $this->width_ratio) - 1), + ($this->padding['T'] + (($bar[1] + $bar[3]) * $this->height_ratio) - 1), + ]; } /** @@ -260,6 +265,11 @@ protected function getBarRectXYXY(array $bar): array */ protected function getBarRectXYWH(array $bar): array { - return [($this->padding['L'] + ($bar[0] * $this->width_ratio)), ($this->padding['T'] + ($bar[1] * $this->height_ratio)), ($bar[2] * $this->width_ratio), ($bar[3] * $this->height_ratio)]; + return [ + ($this->padding['L'] + ($bar[0] * $this->width_ratio)), + ($this->padding['T'] + ($bar[1] * $this->height_ratio)), + ($bar[2] * $this->width_ratio), + ($bar[3] * $this->height_ratio), + ]; } } diff --git a/src/Type/Linear/CodeNineThree.php b/src/Type/Linear/CodeNineThree.php index da50aa9f..9cc83335 100644 --- a/src/Type/Linear/CodeNineThree.php +++ b/src/Type/Linear/CodeNineThree.php @@ -102,14 +102,192 @@ class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtChe * * @var array */ - protected const EXTCODES = ["\x83U", "\x80A", "\x80B", "\x80C", "\x80D", "\x80E", "\x80F", "\x80G", "\x80H", "\x80I", "\x80J", "\x80K", "\x80L", "\x80M", "\x80N", "\x80O", "\x80P", "\x80Q", "\x80R", "\x80S", "\x80T", "\x80U", "\x80V", "\x80W", "\x80X", "\x80Y", "\x80Z", "\x83A", "\x83B", "\x83C", "\x83D", "\x83E", " ", "\x81A", "\x81B", "\x81C", "\x81D", "\x81E", "\x81F", "\x81G", "\x81H", "\x81I", "\x81J", "\x81K", "\x81L", "-", ".", "\x81O", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\x81Z", "\x83F", "\x83G", "\x83H", "\x83I", "\x83J", "\x83V", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "\x83K", "\x83L", "\x83M", "\x83N", "\x83O", "\x83W", "\x82A", "\x82B", "\x82C", "\x82D", "\x82E", "\x82F", "\x82G", "\x82H", "\x82I", "\x82J", "\x82K", "\x82L", "\x82M", "\x82N", "\x82O", "\x82P", "\x82Q", "\x82R", "\x82S", "\x82T", "\x82U", "\x82V", "\x82W", "\x82X", "\x82Y", "\x82Z", "\x83P", "\x83Q", "\x83R", "\x83S", "\x83T"]; + protected const EXTCODES = [ + "\x83U", + "\x80A", + "\x80B", + "\x80C", + "\x80D", + "\x80E", + "\x80F", + "\x80G", + "\x80H", + "\x80I", + "\x80J", + "\x80K", + "\x80L", + "\x80M", + "\x80N", + "\x80O", + "\x80P", + "\x80Q", + "\x80R", + "\x80S", + "\x80T", + "\x80U", + "\x80V", + "\x80W", + "\x80X", + "\x80Y", + "\x80Z", + "\x83A", + "\x83B", + "\x83C", + "\x83D", + "\x83E", + " ", + "\x81A", + "\x81B", + "\x81C", + "\x81D", + "\x81E", + + "\x81F", + "\x81G", + "\x81H", + "\x81I", + "\x81J", + "\x81K", + "\x81L", + "-", + ".", + "\x81O", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "\x81Z", + "\x83F", + "\x83G", + "\x83H", + "\x83I", + "\x83J", + "\x83V", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "\x83K", + "\x83L", + "\x83M", + "\x83N", + "\x83O", + "\x83W", + "\x82A", + "\x82B", + "\x82C", + "\x82D", + "\x82E", + "\x82F", + "\x82G", + "\x82H", + "\x82I", + "\x82J", + "\x82K", + "\x82L", + "\x82M", + "\x82N", + "\x82O", + "\x82P", + "\x82Q", + "\x82R", + "\x82S", + "\x82T", + "\x82U", + "\x82V", + "\x82W", + "\x82X", + "\x82Y", + "\x82Z", + "\x83P", + "\x83Q", + "\x83R", + "\x83S", + "\x83T", + ]; /** * Characters used for checksum * * @var array */ - protected const CHKSUM = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%', '<', '=', '>', '?']; + protected const CHKSUM = [ + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', + '-', + '.', + ' ', + '$', + '/', + '+', + '%', + '<', + '=', + '>', + '?', + ]; /** * Calculate CODE 93 checksum (modulo 47). diff --git a/src/Type/Linear/CodeOneTwoEight/Process.php b/src/Type/Linear/CodeOneTwoEight/Process.php index 0391e6cc5c66adea649ae80ff54f87f99a3d2695..cc15a56fac0aa316c33fe67115f8e53784050de2 100644 GIT binary patch delta 2920 zcmbuBO>PrG5QPO&gp>_Zl&~;Da>8OZ2)lZEJRW|+Uy>zT79@Z;1rk5Q9lT?O#08LY z0xp8M0axHX&s5FpY_U|EH#M*7tLnD>kJp746-~ zgxCl+7Pf*I{;n6q>~xrfDKWC0*qW&!W8vP73Sy#-MncSX%=MCZYN#ZRhEfm%7}*Zo zCn0A4{vZi42jpZ)h?(tVNr>5I=t9i04weSs?fxqih>nsFa}Lpv5ObhDiKN8bJcmh*zaG(PJPF@Af9%gl^Fg$p_dV%HlbCh$ns2r+qm5{;~wShe*-M~x73qE6NbG3}k85n|ehF2ux&h9+Vj_Nk#> zh&j0ERETTKp|6xU@xcJF65>n(*M%5jN_os5fw_O|-m>45UkNa>asRv{A!b>>_pK1q#`9YtCYKYpN{lwcM^;SSA-`YDTOnrIFcM;>M`0n( zJaprzTOnpUQCNvqi!DWcUKS_hB{25Q(|l; zbRnkd*RpGR`8|fc6Ld<9!tsIs3+46s`Nf;JDjl7FSS}HUNQfGd5e;I6Xc22fhj@l~j(CAML7XDaj-)x58O#i3 z1~Y@%!r*3bGq@St3~mNDgPXz4;AU_$xY^m!=KJ1qb7%k8e?cEAVKqR%E40ncgW26e V`S|Jc7Zt$LZrizad3x~s_CG5+>qh_p literal 12579 zcmeHNX?xqo5$=7k_kFkPl(9%l6bT-ZWm}3#T6WyXvTM<85=m7d2s|nhU;t1@T(y6_ z@9g3j?2@vbx_$B?{GbD~GduInwL9Rw_ol;Xp-{bbs~~QPXMyjyVYo`qgnV*89C?l_ z)TdsvT9sP8QnzUFeaDX6fgfBFac6WK*ukZIKDC`wd!U#)cHsCYu6%CKqM;usQM)6@ zAKRiG&b*PhH}d-a{m6B^k#oB0_>(Oq-=AIvqror&3%0IR>a}`9J0_K@vHJ2)r!pQLSB_KLiN7}-g`z(i zy8^$bb`S}_FQVK^5&He;+zwm;c7k&ijMYNHvnOr{R9(^aCkL^`2Qjnb9>!+UEJNLHf=+P-kyX*BXZVTU3Xl|BPs91-(aui5Y*j-b0xoQ#hD z6%!Y(KY{)5zouidxrktgaK?5R5@+}6gKc5eZ^weZh{LxLht-0897cidL<;ECKkh~3 zdhibd=-L1)yev=($l#zqZl&IXXD4|QtvWtSE9sMJRn%(fe@h@@g+@m~j6X!j3XNXR=oYazGANV!=Esh_!b^NRxegtqHA1j9+0i@9xex$vn)ARV5`seX8^sjULz^&s) z4LS2q0}$r*t26uvejT4W!;iRi`|Aupvd*A0{75?;pE|>j&^7d9_z}7Wo#98`)A6ly z{3yJ%_-y3xBM0U2X>k0=0G-b8vn)73m(TD6xaR&0KhVwn8GgjA=U0Q_N8ART;YZr( z_%s-P#BK0%{J^c#n;buI>++inKj?2YG<=#l{OS!o{+c=b%=m0_{II=_e=~<)!@#$h z!;dl`@Bb#lkIXaZ8h(cU8h$#x#qlHfG<;eNKSEE(x5e-ybPV|nKXRXrPmAG4yX*F~ z7=E<7L1*|8I)?r^{LJ`kG5p9ohJ6gbhSfCaYaG8iEy(+Cjp5fM0CYOT55#)Csqr)X zKyT{xZH?ha<{SJBKhT>xerpUr(%z8I@B`hbpKA<1;G-cR{75^4&hR5{LqCRJlk!LN?>fVev^VtQ_%&!j-v8@4`~aZV zKX2#oqX5bC-_GGj4$$ZvKMD_>pW{ac=yZl3X{YOdo8d>?20zD-@YUrr{75@PKEsd5 zhJ6e_qU!O#!SExhLFf2Ey{1+lH*)w{@L(R_4UQke!=Q8gK-KHl2E&hb*X`fn_(4B| zpW_Fr!O!p`vY{WtkF?k8yTvac6#lvZtHuzd_%Zg$wc>?cwvgJ3=Doe%(`Rf&jXtq|59eP6+k4%|kNJg=<_a`t5^YgZ z#9B>M#6}CF8~WT5xW(aW2{Mfz#GV_8b{Q)SN#Mina-$_mwaUhdXjeWKwkPkYQQ(i| zCSiF+gj3fU+4w)bl*St+`@Qbf_k-<^_Kw50bbNAln)_eEco$iC}hmYQW{HG6gp6ot-_UGq&y%&G^>xUnGynk@`x1%q8`72-j z+SkAF&2N3X@SX2|@B2Ua;g5d&lb`?B||>VV3s zuWM+6o}$^AizXO>CO9)VSA<>p^sOV^mH6R+g!kbOp zVC0C<{bc6Su)8$sBj+y-XJKe-PvUWwD9Ump!yge2Qivh9EH$Zfqha8mo5NLjSvWSv zvY7w6LEr~5gFd0^&pbyCXa{bzt90CpRV=C5mQtd8N5~M8V$^(&^eCqG08#i>Do4-9 zt_P4I0e_UF8Rd+MGKuXBOhOG5k^|hZ1^J6fp9b#W2!lXpcw~>qrKM`=;N)d<<*Hm= zT2boam*QLz&z^5TI(qu>;of%dsM~(ld+~gmsRA#QZU}cWjV?0qKBaGrfeHtV)8la|N5)*xj zsRAS#YQ}v_QPocfPo>0uH06YO?~t(CAp<25NZ=IZ;&(+|+<@Wp?4i}zmMnqXK{OPT z8OE*0u5iy>&)A)oS1M9$9!4V22eRyw6Jb$NPoarT4}CK4n8vg82E$SFd?Xb5?TL7& zANUig2;B9~+?|(~V-(H3uhc+TDWQH!0OGB;co1BJgNL^ruXF*4=eZ+u>j))c;Fjj< zony$#t5P%jS&Z-ksIrCZqH{b)tj08rO1G3iRUV^rpsIY(0l;RT60V3sI|x?+N;&buMi=*=}%MVKkY;0oMm z7I;}iD$U~s>oOZ7yPX;(X0Q=>y20#6#DtjpfgT+`S>605I|b&~!_cZe5V z*TuBJm+ytH?_v3BNTr0K#1ZE`2>zlT)=pKM*S*kyU){U*4=!r8%E5)zKg=~SVt%9c zMGW(rSF9=(XxEEIsGFJAqU2sU2q+CnPfXG*`Tbdncox&SBuzx7K@r!tj#=Nb!n3%f`ptPU7q>xT>$JT&n$#PVC4QqD?QV=^j9pO$w0jw(T+A za>w;l+@DjORhXrh5B04bje)emM?xHj<*q!R$^Fu?1s&z^I-b7v6AMV?yv6$qsrmpW zx3eRZg5#!ihlC?LI`P|0_LK}FYova-^ql#l6V|Dz!Ig?rKSckn-4*gLb*{K8aI^$L zKVKAScta-_LVurDuz--*(SjrFvMK!F1V=Rd%lZ#3p$eu5v~Fut;67d!H*Z3fg!vvl zY#R3#wE=dP#>Y zU)k4Y_-r7_t~E%;e(bzYrYS@t5O8+9|IX&Cz1Qm*rVNx3_iC$Fm9Mq&EQ z`KRWY;`7qm{+F$(`^M?Bpb_EhM-4?BkA3GfL=mJ0PTzGqzLe*9QF4ZX>=Viy1Z**0 zyD8j@=@`tkq(rSGKCi%m>Edjr6?4%*Oa7?`r0o6KF;lH!k|9raaWxrNyeVQ#Po7)gfV7 zSY@rX5;MV(-KygGWjz^RO2K8ZwRqa5Rh<$JE#*X`{Lq1RTi9obcpd1k-)rSIIbhjQ zmx!9ic#)9l$(ACj19#$|VUlQLgotG_%2UbmICnJlrzoAtp(ZXnW_y1)@^Do66jMS< z6gmqlIr>QAzdJG~Ctx|L#K8ogJvq;P{DA4cxVQFWExS;X4zGHF$PCpEsqu!=rer$L zj%QRL?6ET&qblIEnJLAy7^)DCWo16e(m%yn-oj7aOM0C%Z?r9CAzeyD#JkW^ zkrq=1u*Q)0HH~=}s+MjnkCm81L)CW?5)EFaU?m9&BY&D61T*XMBCOh4W?%-Z6mQkm zGg>N?#_}XX*y<(Du{#)fUiv*_xLO6|%nOI3e#C+j6*b0`Ynxp9QoYokSB0y>e*jv< Bdo}<7 diff --git a/src/Type/Linear/CodeThreeNineExtCheck.php b/src/Type/Linear/CodeThreeNineExtCheck.php index cc735b0c..db8e04d5 100644 --- a/src/Type/Linear/CodeThreeNineExtCheck.php +++ b/src/Type/Linear/CodeThreeNineExtCheck.php @@ -98,14 +98,187 @@ class CodeThreeNineExtCheck extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const EXTCODES = ['%U', '$A', '$B', '$C', '$D', '$E', '$F', '$G', '$H', '$I', '$J', '$K', '$L', '$M', '$N', '$O', '$P', '$Q', '$R', '$S', '$T', '$U', '$V', '$W', '$X', '$Y', '$Z', '%A', '%B', '%C', '%D', '%E', ' ', '/A', '/B', '/C', '/D', '/E', '/F', '/G', '/H', '/I', '/J', '/K', '/L', '-', '.', '/O', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '/Z', '%F', '%G', '%H', '%I', '%J', '%V', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%K', '%L', '%M', '%N', '%O', '%W', '+A', '+B', '+C', '+D', '+E', '+F', '+G', '+H', '+I', '+J', '+K', '+L', '+M', '+N', '+O', '+P', '+Q', '+R', '+S', '+T', '+U', '+V', '+W', '+X', '+Y', '+Z', '%P', '%Q', '%R', '%S', '%T']; + protected const EXTCODES = [ + '%U', + '$A', + '$B', + '$C', + '$D', + '$E', + '$F', + '$G', + '$H', + '$I', + '$J', + '$K', + '$L', + '$M', + '$N', + '$O', + '$P', + '$Q', + '$R', + '$S', + '$T', + '$U', + '$V', + '$W', + '$X', + '$Y', + '$Z', + '%A', + '%B', + '%C', + '%D', + '%E', + ' ', + '/A', + '/B', + '/C', + '/D', + '/E', + '/F', + '/G', + '/H', + '/I', + '/J', + '/K', + '/L', + '-', + '.', + '/O', + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '/Z', + '%F', + '%G', + '%H', + '%I', + '%J', + '%V', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', + '%K', + '%L', + '%M', + '%N', + '%O', + '%W', + '+A', + '+B', + '+C', + '+D', + '+E', + '+F', + '+G', + '+H', + '+I', + '+J', + '+K', + '+L', + '+M', + '+N', + '+O', + '+P', + '+Q', + '+R', + '+S', + '+T', + '+U', + '+V', + '+W', + '+X', + '+Y', + '+Z', + '%P', + '%Q', + '%R', + '%S', + '%T', + ]; /** * Characters used for checksum * * @var array */ - protected const CHKSUM = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%']; + protected const CHKSUM = [ + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', + '-', + '.', + ' ', + '$', + '/', + '+', + '%', + ]; /** * Encode a string to be used for CODE 39 Extended mode. diff --git a/src/Type/Linear/Imb.php b/src/Type/Linear/Imb.php index e74c8aeb..fa8ff1c1 100644 --- a/src/Type/Linear/Imb.php +++ b/src/Type/Linear/Imb.php @@ -67,28 +67,292 @@ class Imb extends \Com\Tecnick\Barcode\Type\Linear * * @var array */ - protected const ASC_CHR = [4, 0, 2, 6, 3, 5, 1, 9, 8, 7, 1, 2, 0, 6, 4, 8, 2, 9, 5, 3, 0, 1, 3, 7, 4, 6, 8, 9, 2, 0, 5, 1, 9, 4, 3, 8, 6, 7, 1, 2, 4, 3, 9, 5, 7, 8, 3, 0, 2, 1, 4, 0, 9, 1, 7, 0, 2, 4, 6, 3, 7, 1, 9, 5, 8]; + protected const ASC_CHR = [ + 4, + 0, + 2, + 6, + 3, + 5, + 1, + 9, + 8, + 7, + 1, + 2, + 0, + 6, + 4, + 8, + 2, + 9, + 5, + 3, + 0, + 1, + 3, + 7, + 4, + 6, + 8, + 9, + 2, + 0, + 5, + 1, + 9, + 4, + 3, + 8, + 6, + 7, + 1, + 2, + 4, + 3, + 9, + 5, + 7, + 8, + 3, + 0, + 2, + 1, + 4, + 0, + 9, + 1, + 7, + 0, + 2, + 4, + 6, + 3, + 7, + 1, + 9, + 5, + 8, + ]; /** * DSC characters * * @var array */ - protected const DSC_CHR = [7, 1, 9, 5, 8, 0, 2, 4, 6, 3, 5, 8, 9, 7, 3, 0, 6, 1, 7, 4, 6, 8, 9, 2, 5, 1, 7, 5, 4, 3, 8, 7, 6, 0, 2, 5, 4, 9, 3, 0, 1, 6, 8, 2, 0, 4, 5, 9, 6, 7, 5, 2, 6, 3, 8, 5, 1, 9, 8, 7, 4, 0, 2, 6, 3]; + protected const DSC_CHR = [ + 7, + 1, + 9, + 5, + 8, + 0, + 2, + 4, + 6, + 3, + 5, + 8, + 9, + 7, + 3, + 0, + 6, + 1, + 7, + 4, + 6, + 8, + 9, + 2, + 5, + 1, + 7, + 5, + 4, + 3, + 8, + 7, + 6, + 0, + 2, + 5, + 4, + 9, + 3, + 0, + 1, + 6, + 8, + 2, + 0, + 4, + 5, + 9, + 6, + 7, + 5, + 2, + 6, + 3, + 8, + 5, + 1, + 9, + 8, + 7, + 4, + 0, + 2, + 6, + 3, + ]; /** * ASC positions * * @var array */ - protected const ASC_POS = [3, 0, 8, 11, 1, 12, 8, 11, 10, 6, 4, 12, 2, 7, 9, 6, 7, 9, 2, 8, 4, 0, 12, 7, 10, 9, 0, 7, 10, 5, 7, 9, 6, 8, 2, 12, 1, 4, 2, 0, 1, 5, 4, 6, 12, 1, 0, 9, 4, 7, 5, 10, 2, 6, 9, 11, 2, 12, 6, 7, 5, 11, 0, 3, 2]; + protected const ASC_POS = [ + 3, + 0, + 8, + 11, + 1, + 12, + 8, + 11, + 10, + 6, + 4, + 12, + 2, + 7, + 9, + 6, + 7, + 9, + 2, + 8, + 4, + 0, + 12, + 7, + 10, + 9, + 0, + 7, + 10, + 5, + 7, + 9, + 6, + 8, + 2, + 12, + 1, + 4, + 2, + 0, + 1, + 5, + 4, + 6, + 12, + 1, + 0, + 9, + 4, + 7, + 5, + 10, + 2, + 6, + 9, + 11, + 2, + 12, + 6, + 7, + 5, + 11, + 0, + 3, + 2, + ]; /** * DSC positions * * @var array */ - protected const DSC_POS = [2, 10, 12, 5, 9, 1, 5, 4, 3, 9, 11, 5, 10, 1, 6, 3, 4, 1, 10, 0, 2, 11, 8, 6, 1, 12, 3, 8, 6, 4, 4, 11, 0, 6, 1, 9, 11, 5, 3, 7, 3, 10, 7, 11, 8, 2, 10, 3, 5, 8, 0, 3, 12, 11, 8, 4, 5, 1, 3, 0, 7, 12, 9, 8, 10]; + protected const DSC_POS = [ + 2, + 10, + 12, + 5, + 9, + 1, + 5, + 4, + 3, + 9, + 11, + 5, + 10, + 1, + 6, + 3, + 4, + 1, + 10, + 0, + 2, + 11, + 8, + 6, + 1, + 12, + 3, + 8, + 6, + 4, + 4, + 11, + 0, + 6, + 1, + 9, + 11, + 5, + 3, + 7, + 3, + 10, + 7, + 11, + 8, + 2, + 10, + 3, + 5, + 8, + 0, + 3, + 12, + 11, + 8, + 4, + 5, + 1, + 3, + 0, + 7, + 12, + 9, + 8, + 10, + ]; /** * Reverse unsigned short value diff --git a/src/Type/Square/Aztec/Bitstream.php b/src/Type/Square/Aztec/Bitstream.php index 4083992e..fb7952ab 100644 --- a/src/Type/Square/Aztec/Bitstream.php +++ b/src/Type/Square/Aztec/Bitstream.php @@ -133,7 +133,11 @@ protected function processModeChars(array &$chars, int &$idx, int $chrlen): void $nchr = $this->countModeChars($chars, $idx, $chrlen, $mode); if ($this->encmode !== $mode) { - if (($nchr == 1) && (isset(Data::SHIFT_MAP[$this->encmode][$mode]) && Data::SHIFT_MAP[$this->encmode][$mode] !== [])) { + if ( + ($nchr == 1) + && (isset(Data::SHIFT_MAP[$this->encmode][$mode]) + && Data::SHIFT_MAP[$this->encmode][$mode] !== []) + ) { $this->addShift($mode); } else { $this->addLatch($mode); diff --git a/src/Type/Square/Datamatrix/Data.php b/src/Type/Square/Datamatrix/Data.php index 990a3529..7c95f6f9 100644 --- a/src/Type/Square/Datamatrix/Data.php +++ b/src/Type/Square/Datamatrix/Data.php @@ -98,68 +98,578 @@ class Data 'S' => [ // square form // 10x10 - [0x00a, 0x00a, 0x008, 0x008, 0x00a, 0x00a, 0x008, 0x008, 0x001, 0x001, 0x001, 0x003, 0x005, 0x001, 0x003, 0x005], + [ + 0x00a, + 0x00a, + 0x008, + 0x008, + 0x00a, + 0x00a, + 0x008, + 0x008, + 0x001, + 0x001, + 0x001, + 0x003, + 0x005, + 0x001, + 0x003, + 0x005, + ], // 12x12 - [0x00c, 0x00c, 0x00a, 0x00a, 0x00c, 0x00c, 0x00a, 0x00a, 0x001, 0x001, 0x001, 0x005, 0x007, 0x001, 0x005, 0x007], + [ + 0x00c, + 0x00c, + 0x00a, + 0x00a, + 0x00c, + 0x00c, + 0x00a, + 0x00a, + 0x001, + 0x001, + 0x001, + 0x005, + 0x007, + 0x001, + 0x005, + 0x007, + ], // 14x14 - [0x00e, 0x00e, 0x00c, 0x00c, 0x00e, 0x00e, 0x00c, 0x00c, 0x001, 0x001, 0x001, 0x008, 0x00a, 0x001, 0x008, 0x00a], + [ + 0x00e, + 0x00e, + 0x00c, + 0x00c, + 0x00e, + 0x00e, + 0x00c, + 0x00c, + 0x001, + 0x001, + 0x001, + 0x008, + 0x00a, + 0x001, + 0x008, + 0x00a, + ], // 16x16 - [0x010, 0x010, 0x00e, 0x00e, 0x010, 0x010, 0x00e, 0x00e, 0x001, 0x001, 0x001, 0x00c, 0x00c, 0x001, 0x00c, 0x00c], + [ + 0x010, + 0x010, + 0x00e, + 0x00e, + 0x010, + 0x010, + 0x00e, + 0x00e, + 0x001, + 0x001, + 0x001, + 0x00c, + 0x00c, + 0x001, + 0x00c, + 0x00c, + ], // 18x18 - [0x012, 0x012, 0x010, 0x010, 0x012, 0x012, 0x010, 0x010, 0x001, 0x001, 0x001, 0x012, 0x00e, 0x001, 0x012, 0x00e], + [ + 0x012, + 0x012, + 0x010, + 0x010, + 0x012, + 0x012, + 0x010, + 0x010, + 0x001, + 0x001, + 0x001, + 0x012, + 0x00e, + 0x001, + 0x012, + 0x00e, + ], // 20x20 - [0x014, 0x014, 0x012, 0x012, 0x014, 0x014, 0x012, 0x012, 0x001, 0x001, 0x001, 0x016, 0x012, 0x001, 0x016, 0x012], + [ + 0x014, + 0x014, + 0x012, + 0x012, + 0x014, + 0x014, + 0x012, + 0x012, + 0x001, + 0x001, + 0x001, + 0x016, + 0x012, + 0x001, + 0x016, + 0x012, + ], // 22x22 - [0x016, 0x016, 0x014, 0x014, 0x016, 0x016, 0x014, 0x014, 0x001, 0x001, 0x001, 0x01e, 0x014, 0x001, 0x01e, 0x014], + [ + 0x016, + 0x016, + 0x014, + 0x014, + 0x016, + 0x016, + 0x014, + 0x014, + 0x001, + 0x001, + 0x001, + 0x01e, + 0x014, + 0x001, + 0x01e, + 0x014, + ], // 24x24 - [0x018, 0x018, 0x016, 0x016, 0x018, 0x018, 0x016, 0x016, 0x001, 0x001, 0x001, 0x024, 0x018, 0x001, 0x024, 0x018], + [ + 0x018, + 0x018, + 0x016, + 0x016, + 0x018, + 0x018, + 0x016, + 0x016, + 0x001, + 0x001, + 0x001, + 0x024, + 0x018, + 0x001, + 0x024, + 0x018, + ], // 26x26 - [0x01a, 0x01a, 0x018, 0x018, 0x01a, 0x01a, 0x018, 0x018, 0x001, 0x001, 0x001, 0x02c, 0x01c, 0x001, 0x02c, 0x01c], + [ + 0x01a, + 0x01a, + 0x018, + 0x018, + 0x01a, + 0x01a, + 0x018, + 0x018, + 0x001, + 0x001, + 0x001, + 0x02c, + 0x01c, + 0x001, + 0x02c, + 0x01c, + ], // 32x32 - [0x020, 0x020, 0x01c, 0x01c, 0x010, 0x010, 0x00e, 0x00e, 0x002, 0x002, 0x004, 0x03e, 0x024, 0x001, 0x03e, 0x024], + [ + 0x020, + 0x020, + 0x01c, + 0x01c, + 0x010, + 0x010, + 0x00e, + 0x00e, + 0x002, + 0x002, + 0x004, + 0x03e, + 0x024, + 0x001, + 0x03e, + 0x024, + ], // 36x36 - [0x024, 0x024, 0x020, 0x020, 0x012, 0x012, 0x010, 0x010, 0x002, 0x002, 0x004, 0x056, 0x02a, 0x001, 0x056, 0x02a], + [ + 0x024, + 0x024, + 0x020, + 0x020, + 0x012, + 0x012, + 0x010, + 0x010, + 0x002, + 0x002, + 0x004, + 0x056, + 0x02a, + 0x001, + 0x056, + 0x02a, + ], // 40x40 - [0x028, 0x028, 0x024, 0x024, 0x014, 0x014, 0x012, 0x012, 0x002, 0x002, 0x004, 0x072, 0x030, 0x001, 0x072, 0x030], + [ + 0x028, + 0x028, + 0x024, + 0x024, + 0x014, + 0x014, + 0x012, + 0x012, + 0x002, + 0x002, + 0x004, + 0x072, + 0x030, + 0x001, + 0x072, + 0x030, + ], // 44x44 - [0x02c, 0x02c, 0x028, 0x028, 0x016, 0x016, 0x014, 0x014, 0x002, 0x002, 0x004, 0x090, 0x038, 0x001, 0x090, 0x038], + [ + 0x02c, + 0x02c, + 0x028, + 0x028, + 0x016, + 0x016, + 0x014, + 0x014, + 0x002, + 0x002, + 0x004, + 0x090, + 0x038, + 0x001, + 0x090, + 0x038, + ], // 48x48 - [0x030, 0x030, 0x02c, 0x02c, 0x018, 0x018, 0x016, 0x016, 0x002, 0x002, 0x004, 0x0ae, 0x044, 0x001, 0x0ae, 0x044], + [ + 0x030, + 0x030, + 0x02c, + 0x02c, + 0x018, + 0x018, + 0x016, + 0x016, + 0x002, + 0x002, + 0x004, + 0x0ae, + 0x044, + 0x001, + 0x0ae, + 0x044, + ], // 52x52 - [0x034, 0x034, 0x030, 0x030, 0x01a, 0x01a, 0x018, 0x018, 0x002, 0x002, 0x004, 0x0cc, 0x054, 0x002, 0x066, 0x02a], + [ + 0x034, + 0x034, + 0x030, + 0x030, + 0x01a, + 0x01a, + 0x018, + 0x018, + 0x002, + 0x002, + 0x004, + 0x0cc, + 0x054, + 0x002, + 0x066, + 0x02a, + ], // 64x64 - [0x040, 0x040, 0x038, 0x038, 0x010, 0x010, 0x00e, 0x00e, 0x004, 0x004, 0x010, 0x118, 0x070, 0x002, 0x08c, 0x038], + [ + 0x040, + 0x040, + 0x038, + 0x038, + 0x010, + 0x010, + 0x00e, + 0x00e, + 0x004, + 0x004, + 0x010, + 0x118, + 0x070, + 0x002, + 0x08c, + 0x038, + ], // 72x72 - [0x048, 0x048, 0x040, 0x040, 0x012, 0x012, 0x010, 0x010, 0x004, 0x004, 0x010, 0x170, 0x090, 0x004, 0x05c, 0x024], + [ + 0x048, + 0x048, + 0x040, + 0x040, + 0x012, + 0x012, + 0x010, + 0x010, + 0x004, + 0x004, + 0x010, + 0x170, + 0x090, + 0x004, + 0x05c, + 0x024, + ], // 80x80 - [0x050, 0x050, 0x048, 0x048, 0x014, 0x014, 0x012, 0x012, 0x004, 0x004, 0x010, 0x1c8, 0x0c0, 0x004, 0x072, 0x030], + [ + 0x050, + 0x050, + 0x048, + 0x048, + 0x014, + 0x014, + 0x012, + 0x012, + 0x004, + 0x004, + 0x010, + 0x1c8, + 0x0c0, + 0x004, + 0x072, + 0x030, + ], // 88x88 - [0x058, 0x058, 0x050, 0x050, 0x016, 0x016, 0x014, 0x014, 0x004, 0x004, 0x010, 0x240, 0x0e0, 0x004, 0x090, 0x038], + [ + 0x058, + 0x058, + 0x050, + 0x050, + 0x016, + 0x016, + 0x014, + 0x014, + 0x004, + 0x004, + 0x010, + 0x240, + 0x0e0, + 0x004, + 0x090, + 0x038, + ], // 96x96 - [0x060, 0x060, 0x058, 0x058, 0x018, 0x018, 0x016, 0x016, 0x004, 0x004, 0x010, 0x2b8, 0x110, 0x004, 0x0ae, 0x044], + [ + 0x060, + 0x060, + 0x058, + 0x058, + 0x018, + 0x018, + 0x016, + 0x016, + 0x004, + 0x004, + 0x010, + 0x2b8, + 0x110, + 0x004, + 0x0ae, + 0x044, + ], // 104x104 - [0x068, 0x068, 0x060, 0x060, 0x01a, 0x01a, 0x018, 0x018, 0x004, 0x004, 0x010, 0x330, 0x150, 0x006, 0x088, 0x038], + [ + 0x068, + 0x068, + 0x060, + 0x060, + 0x01a, + 0x01a, + 0x018, + 0x018, + 0x004, + 0x004, + 0x010, + 0x330, + 0x150, + 0x006, + 0x088, + 0x038, + ], // 120x120 - [0x078, 0x078, 0x06c, 0x06c, 0x014, 0x014, 0x012, 0x012, 0x006, 0x006, 0x024, 0x41a, 0x198, 0x006, 0x0af, 0x044], + [ + 0x078, + 0x078, + 0x06c, + 0x06c, + 0x014, + 0x014, + 0x012, + 0x012, + 0x006, + 0x006, + 0x024, + 0x41a, + 0x198, + 0x006, + 0x0af, + 0x044, + ], // 132x132 - [0x084, 0x084, 0x078, 0x078, 0x016, 0x016, 0x014, 0x014, 0x006, 0x006, 0x024, 0x518, 0x1f0, 0x008, 0x0a3, 0x03e], + [ + 0x084, + 0x084, + 0x078, + 0x078, + 0x016, + 0x016, + 0x014, + 0x014, + 0x006, + 0x006, + 0x024, + 0x518, + 0x1f0, + 0x008, + 0x0a3, + 0x03e, + ], // 144x144 - [0x090, 0x090, 0x084, 0x084, 0x018, 0x018, 0x016, 0x016, 0x006, 0x006, 0x024, 0x618, 0x26c, 0x00a, 0x09c, 0x03e], + [ + 0x090, + 0x090, + 0x084, + 0x084, + 0x018, + 0x018, + 0x016, + 0x016, + 0x006, + 0x006, + 0x024, + 0x618, + 0x26c, + 0x00a, + 0x09c, + 0x03e, + ], ], 'R' => [ // rectangular form // 8x18 - [0x008, 0x012, 0x006, 0x010, 0x008, 0x012, 0x006, 0x010, 0x001, 0x001, 0x001, 0x005, 0x007, 0x001, 0x005, 0x007], + [ + 0x008, + 0x012, + 0x006, + 0x010, + 0x008, + 0x012, + 0x006, + 0x010, + 0x001, + 0x001, + 0x001, + 0x005, + 0x007, + 0x001, + 0x005, + 0x007, + ], // 8x32 - [0x008, 0x020, 0x006, 0x01c, 0x008, 0x010, 0x006, 0x00e, 0x001, 0x002, 0x002, 0x00a, 0x00b, 0x001, 0x00a, 0x00b], + [ + 0x008, + 0x020, + 0x006, + 0x01c, + 0x008, + 0x010, + 0x006, + 0x00e, + 0x001, + 0x002, + 0x002, + 0x00a, + 0x00b, + 0x001, + 0x00a, + 0x00b, + ], // 12x26 - [0x00c, 0x01a, 0x00a, 0x018, 0x00c, 0x01a, 0x00a, 0x018, 0x001, 0x001, 0x001, 0x010, 0x00e, 0x001, 0x010, 0x00e], + [ + 0x00c, + 0x01a, + 0x00a, + 0x018, + 0x00c, + 0x01a, + 0x00a, + 0x018, + 0x001, + 0x001, + 0x001, + 0x010, + 0x00e, + 0x001, + 0x010, + 0x00e, + ], // 12x36 - [0x00c, 0x024, 0x00a, 0x020, 0x00c, 0x012, 0x00a, 0x010, 0x001, 0x002, 0x002, 0x00c, 0x012, 0x001, 0x00c, 0x012], + [ + 0x00c, + 0x024, + 0x00a, + 0x020, + 0x00c, + 0x012, + 0x00a, + 0x010, + 0x001, + 0x002, + 0x002, + 0x00c, + 0x012, + 0x001, + 0x00c, + 0x012, + ], // 16x36 - [0x010, 0x024, 0x00e, 0x020, 0x010, 0x012, 0x00e, 0x010, 0x001, 0x002, 0x002, 0x020, 0x018, 0x001, 0x020, 0x018], + [ + 0x010, + 0x024, + 0x00e, + 0x020, + 0x010, + 0x012, + 0x00e, + 0x010, + 0x001, + 0x002, + 0x002, + 0x020, + 0x018, + 0x001, + 0x020, + 0x018, + ], // 16x48 - [0x010, 0x030, 0x00e, 0x02c, 0x010, 0x018, 0x00e, 0x016, 0x001, 0x002, 0x002, 0x031, 0x01c, 0x001, 0x031, 0x01c], + [ + 0x010, + 0x030, + 0x00e, + 0x02c, + 0x010, + 0x018, + 0x00e, + 0x016, + 0x001, + 0x002, + 0x002, + 0x031, + 0x01c, + 0x001, + 0x031, + 0x01c, + ], ], ]; diff --git a/src/Type/Square/Datamatrix/Encode.php b/src/Type/Square/Datamatrix/Encode.php index c7a91d0c..a7041f54 100644 --- a/src/Type/Square/Datamatrix/Encode.php +++ b/src/Type/Square/Datamatrix/Encode.php @@ -186,7 +186,18 @@ public function encodeEDF( if ( (($field_length == 4) - || ($epos == $data_length) || ! $this->isCharMode($chr, Data::ENC_EDF)) && $this->encodeEDFfour($epos, $cdw, $cdw_num, $pos, $data_length, $field_length, $enc, $temp_cw) + || ($epos == $data_length) + || ! $this->isCharMode($chr, Data::ENC_EDF)) + && $this->encodeEDFfour( + $epos, + $cdw, + $cdw_num, + $pos, + $data_length, + $field_length, + $enc, + $temp_cw + ) ) { break; } diff --git a/src/Type/Square/PdfFourOneSeven/Compaction.php b/src/Type/Square/PdfFourOneSeven/Compaction.php index f7aa4b2c..84da4b9c 100644 --- a/src/Type/Square/PdfFourOneSeven/Compaction.php +++ b/src/Type/Square/PdfFourOneSeven/Compaction.php @@ -82,7 +82,10 @@ protected function processTextCompaction(string $code, array &$codewords): void // the sub-mode is changed for ($sub = 0; $sub < 4; ++$sub) { // search new sub-mode - if (($sub != $submode) && (($key = array_search($chval, Data::TEXT_SUB_MODES[$sub], true)) !== false)) { + if ( + ($sub != $submode) + && (($key = array_search($chval, Data::TEXT_SUB_MODES[$sub], true)) !== false) + ) { $this->processTextCompactionSub($txtarr, $submode, $sub, $code, $key, $idx, $codelen); break; } diff --git a/src/Type/Square/QrCode/SpecRs.php b/src/Type/Square/QrCode/SpecRs.php index 08b78628..57cbb5ea 100644 --- a/src/Type/Square/QrCode/SpecRs.php +++ b/src/Type/Square/QrCode/SpecRs.php @@ -234,7 +234,13 @@ public function putAlignmentMarker( int $pox, int $poy ): array { - $finder = ["\xa1\xa1\xa1\xa1\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa0\xa1\xa0\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa1\xa1\xa1\xa1"]; + $finder = [ + "\xa1\xa1\xa1\xa1\xa1", + "\xa1\xa0\xa0\xa0\xa1", + "\xa1\xa0\xa1\xa0\xa1", + "\xa1\xa0\xa0\xa0\xa1", + "\xa1\xa1\xa1\xa1\xa1", + ]; $yStart = $poy - 2; $xStart = $pox - 2; for ($ydx = 0; $ydx < 5; ++$ydx) { @@ -258,7 +264,15 @@ public function putFinderPattern( int $pox, int $poy ): array { - $finder = ["\xc1\xc1\xc1\xc1\xc1\xc1\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc1\xc1\xc1\xc1\xc1\xc1"]; + $finder = [ + "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", + "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", + "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", + "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", + "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", + "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", + "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", + ]; for ($ypos = 0; $ypos < 7; ++$ypos) { $frame = $this->qrstrset($frame, $pox, ($poy + $ypos), $finder[$ypos]); } diff --git a/test/BarcodeTest.php b/test/BarcodeTest.php index a66a7c91..64960a93 100644 --- a/test/BarcodeTest.php +++ b/test/BarcodeTest.php @@ -155,7 +155,16 @@ public function testExportMethods(): void $this->assertEquals(44, $barr['full_width']); $this->assertEquals(8, $barr['full_height']); - $expected = [[1, 0, 1, 1], [4, 0, 2, 1], [9, 0, 3, 1], [16, 0, 4, 1], [0, 1, 1, 1], [2, 1, 2, 1], [6, 1, 3, 1], [12, 1, 4, 1]]; + $expected = [ + [1, 0, 1, 1], + [4, 0, 2, 1], + [9, 0, 3, 1], + [16, 0, 4, 1], + [0, 1, 1, 1], + [2, 1, 2, 1], + [6, 1, 3, 1], + [12, 1, 4, 1], + ]; $this->assertEquals($expected, $barr['bars']); $this->assertEquals('#800080ff', $barr['color_obj']->getRgbaHexColor()); diff --git a/test/Square/AztecTest.php b/test/Square/AztecTest.php index 5e7f4b31..d4a6cc1d 100644 --- a/test/Square/AztecTest.php +++ b/test/Square/AztecTest.php @@ -3,13 +3,13 @@ /** * AztecTest.php * - * @since 2023-10-20 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2023-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2023-10-20 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2023-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode * * This file is part of tc-lib-barcode software library. */ @@ -21,13 +21,13 @@ /** * AZTEC Barcode class test * - * @since 2023-10-20 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2023-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2023-10-20 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2023-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode */ class AztecTest extends TestUtil { @@ -64,44 +64,157 @@ public function testGetGrid(string $options, string $code, mixed $expected): voi public static function getGridDataProvider(): array { - return [[',100,A,A,0', 'A', 'c48da49052f674edc66fa02e52334b17'], ['', ' ABCDEFGHIJKLMNOPQRSTUVWXYZ', '74f1e68830f0c635cd01167245743098'], ['', ' abcdefghijklmnopqrstuvwxyz', '100ebf910c88922b0ccee88256ba0c81'], ['', ' ,.0123456789', 'ee2a70b7c88a9e0956b1896983e93f91'], ['', ' !"#$%&\'()*+,-./:;<=>?[]{}', '6965459e50f7c3029de42ef5dc5c1fdf'], ['', chr(1) . chr(2) . chr(3) . chr(4) . chr(5) - . chr(6) . chr(7) . chr(8) . chr(9) . chr(10) - . chr(11) . chr(12) . chr(13) . chr(27) . chr(28) - . chr(29) . chr(30) . chr(31) . chr(64) . chr(92) - . chr(94) . chr(95) . chr(96) . chr(124) . chr(126) - . chr(127), 'b8961abf38519b529f7dc6a20e8f3e59'], ['', 'AaB0C#D' . chr(126), '9b1f2af28b8d9d222de93dfe6a09a047'], ['', 'aAb0c#d' . chr(126), 'f4c58cabbdb5d94fa0cc1c31d510936a'], ['', '#A$a%0&' . chr(126), 'a17634a1db6372efbf8ea25a303c38f8'], ['', chr(1) . 'A' . chr(1) . 'a' . chr(1) . '0' . chr(1) . '#', 'c1a585888c7a1eb424ff98bbf7b32d46'], ['', 'PUNCT pairs , . : -', '35281793cc5247b291abb8e3fe5ed853'], ['', 'ABCDEabcdeABCDE012345ABCDE?[]{}ABCDE' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), '4ae19b80469a1afff8e490f5afaa8b73'], ['', 'abcdeABCDEabcde012345abcde?[]{}abcde' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), 'b0158bfe19c6fe20042128d59e40ca3b'], ['', '?[]{}ABCDE?[]{}abcde?[]{}012345?[]{}' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), '71ba0ed8c308c93af6af7cd23a76355a'], ['', chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . 'ABCDE' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . 'abcde' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . '012345' - . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . '?[]{}', 'f31e14be0b2c1f903e77af11e6c901b0'], ['', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit,' - . ' sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' - . ' Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris' - . ' nisi ut aliquip ex ea commodo consequat.' - . ' Duis aute irure dolor in reprehenderit in voluptate velit esse' - . ' cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat' - . ' cupidatat non proident,' . - ' sunt in culpa qui officia deserunt mollit anim id est laborum.', 'bb2b103d59e035a581fed0619090f89c'], ['', chr(128) . chr(129) . chr(130) . chr(131) . chr(132), 'da92b009c1f4430e2f62c76c5f708121'], ['', chr(128) . chr(129) . chr(130) . chr(131) . chr(132) - . chr(133) . chr(134) . chr(135) . chr(136) . chr(137) - . chr(138) . chr(139) . chr(140) . chr(141) . chr(142) - . chr(143) . chr(144) . chr(145) . chr(146) . chr(147) - . chr(148) . chr(149) . chr(150) . chr(151) . chr(152) - . chr(153) . chr(154) . chr(155) . chr(156) . chr(157) - . chr(158) . chr(159) . chr(160), 'f3dfdda6d6fdbd747c86f042fc649193'], ['', chr(128) . chr(129) . chr(130) . chr(131) . chr(132) - . chr(133) . chr(134) . chr(135) . chr(136) . chr(137) - . chr(138) . chr(139) . chr(140) . chr(141) . chr(142) - . chr(143) . chr(144) . chr(145) . chr(146) . chr(147) - . chr(148) . chr(149) . chr(150) . chr(151) . chr(152) - . chr(153) . chr(154) . chr(155) . chr(156) . chr(157) - . chr(158) . chr(159) . chr(160) . chr(161) . chr(162) - . chr(163) . chr(164) . chr(165) . chr(166) . chr(167) - . chr(168) . chr(169) . chr(170) . chr(171) . chr(172) - . chr(173) . chr(174) . chr(175) . chr(176) . chr(177) - . chr(178) . chr(179) . chr(180) . chr(181) . chr(182) - . chr(183) . chr(184) . chr(185) . chr(186) . chr(187) - . chr(188) . chr(189) . chr(190), 'ee473dc76e160671f3d1991777894323'], ['', '012345: : : : : : : : ', 'b7ae80e65d754dc17fe116aaddd33c24'], ['', '012345. , ', '92b442e5f1b33be91c576eddc12bcca7'], ['', '012345. , . , . , . , ', '598fd97d8a28b1514cd0bf88369c68e9'], ['', '~~~~~~. , ', 'c40fc61717a7e802d7458897197227b1'], ['', '******. , ', 'abbe0bdfdc10ad059ad2c415e79dab31'], ['', chr(188) . chr(189) . chr(190) . '. , ', 'c9ae209e0c6d03014753363affffee8b']]; + return [ + [ + ',100,A,A,0', + 'A', + 'c48da49052f674edc66fa02e52334b17', + ], + [ + '', + ' ABCDEFGHIJKLMNOPQRSTUVWXYZ', + '74f1e68830f0c635cd01167245743098', + ], + [ + '', + ' abcdefghijklmnopqrstuvwxyz', + '100ebf910c88922b0ccee88256ba0c81', + ], + [ + '', + ' ,.0123456789', + 'ee2a70b7c88a9e0956b1896983e93f91', + ], + [ + '', + "\r" . '!"#$%&\'()*+,-./:;<=>?[]{}', + '6965459e50f7c3029de42ef5dc5c1fdf', + ], + [ + '', + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A" + . "\x0B\x0C\x0D\x1B\x1C\x1D\x1E\x1F\x40\x5C" + . "\x5E\x5F\x60\x7C\x7E\x7F", + 'b8961abf38519b529f7dc6a20e8f3e59', + ], + [ + '', + 'AaB0C#D' . "\x7E", + '9b1f2af28b8d9d222de93dfe6a09a047', + ], + [ + '', + 'aAb0c#d' . "\x7E", + 'f4c58cabbdb5d94fa0cc1c31d510936a', + ], + [ + '', + '#A$a%0&' . "\x7E", + 'a17634a1db6372efbf8ea25a303c38f8', + ], + [ + '', + "\x01A\x01a\x010\x01#", + 'c1a585888c7a1eb424ff98bbf7b32d46', + ], + [ + '', + 'PUNCT pairs , . : ' . "\r\n", + '35281793cc5247b291abb8e3fe5ed853', + ], + [ + '', + 'ABCDEabcdeABCDE012345ABCDE?[]{}ABCDE' + . "\x01\x02\x03\x04\x05", + '4ae19b80469a1afff8e490f5afaa8b73', + ], + [ + '', + 'abcdeABCDEabcde012345abcde?[]{}abcde' + . "\x01\x02\x03\x04\x05", + 'b0158bfe19c6fe20042128d59e40ca3b', + ], + [ + '', + '?[]{}ABCDE?[]{}abcde?[]{}012345?[]{}' + . "\x01\x02\x03\x04\x05", + '71ba0ed8c308c93af6af7cd23a76355a', + ], + [ + '', + "\x01\x02\x03\x04\x05" . 'ABCDE' + . "\x01\x02\x03\x04\x05" . 'abcde' + . "\x01\x02\x03\x04\x05" . '012345' + . "\x01\x02\x03\x04\x05" . '?[]{}', + 'f31e14be0b2c1f903e77af11e6c901b0', + ], + [ + '', + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit,' + . ' sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' + . ' Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris' + . ' nisi ut aliquip ex ea commodo consequat.' + . ' Duis aute irure dolor in reprehenderit in voluptate velit esse' + . ' cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat' + . ' cupidatat non proident,' . + ' sunt in culpa qui officia deserunt mollit anim id est laborum.', + 'bb2b103d59e035a581fed0619090f89c', + ], + [ + '', + "\x80\x81\x82\x83\x84", + 'da92b009c1f4430e2f62c76c5f708121', + ], + [ + '', + "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89" + . "\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93" + . "\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D" + . "\x9E\x9F\xA0", + 'f3dfdda6d6fdbd747c86f042fc649193', + ], + [ + '', + "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89" + . "\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93" + . "\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D" + . "\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7" + . "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1" + . "\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB" + . "\xBC\xBD\xBE", + 'ee473dc76e160671f3d1991777894323', + ], + [ + '', + '012345: : : : : : : : ', + 'b7ae80e65d754dc17fe116aaddd33c24', + ], + [ + '', + '012345. , ', + '92b442e5f1b33be91c576eddc12bcca7', + ], + [ + '', + '012345. , . , . , . , ', + '598fd97d8a28b1514cd0bf88369c68e9', + ], + [ + '', + '~~~~~~. , ', + 'c40fc61717a7e802d7458897197227b1', + ], + [ + '', + '******. , ', + 'abbe0bdfdc10ad059ad2c415e79dab31', + ], + [ + '', + "\xBC\xBD\xBE" . '. , ', + 'c9ae209e0c6d03014753363affffee8b', + ], + ]; } /** diff --git a/test/Square/DatamatrixTest.php b/test/Square/DatamatrixTest.php index 9d6b632a..d9569563 100644 --- a/test/Square/DatamatrixTest.php +++ b/test/Square/DatamatrixTest.php @@ -89,333 +89,306 @@ public function testGetGrid(string $mode, string $code, mixed $expected): void public static function getGridDataProvider(): array { return [ - ['DATAMATRIX', '0&0&0&0&0&0&_', 'fffdfdaec33af0788d24cdfa8cba5ac6'], - ['DATAMATRIX', '0&0&0&0&0&0&0', '10d0faf5a6e7b71829f268218df7e6af'], - ['DATAMATRIX', '-=-1-=-2-=-3', '75c6038d90476cec641ad07690989b36'], - ['DATAMATRIX', '-=-1-=-2-=-3x', 'f020e44d0926d17af7eb21febdb38d53'], - ['DATAMATRIX', '-=-1-=-2-=-3xyz', '17420fbffefddb5f1b8abd0d05de724d'], - ['DATAMATRIX', '-=-1-=-2-=-3-', 'a63372ce839b51294964f0da0ae0f9f9'], - ['DATAMATRIX', '-=-1-=-2-=-3-xy', 'f65ab07c374c53e2a93016776041de42'], - ['DATAMATRIX', '-=-1-=-2-=-3-=x', '7a30efdf7616397a1ea2fd5fd95fed2c'], - ['DATAMATRIX', '(400)BS2WZ64PA(00)0', '9cb7f1c2aa5989909229ef8e4252d61d'], - ['DATAMATRIX', '(400)BS2WZ64QA(00)0', '0494f709138a1feef5a1c9f14852dbe5'], - ['DATAMATRIX', 'LD2B 1 CLNGP', 'f806889d1dbe0908dcfb530f86098041'], - ['DATAMATRIX', 'XXXXXXXXXNGP', 'c6f2b7b293a2943bae74f2a191ec4aea'], - ['DATAMATRIX', 'XXXXXXXXXXXXNGP', 'f7679d5a7ab4a8edf12571a6866d92bc'], - ['DATAMATRIX', 'ABCDABCDAB' . chr(128) . 'DABCD', '39aca5ed58b922bee369e5ab8e3add8c'], - ['DATAMATRIX', '123aabcdefghijklmnopqrstuvwxyzc', 'b2d1e957af10655d7a8c3bae86696314'], - ['DATAMATRIX', 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq', 'c45bd372694ad7a20fca7d45f3d459ab'], - ['DATAMATRIX', 'abcdefghijklmnop', '4fc7940fe3d19fca12454340c38e3421'], - ['DATAMATRIX', 'abcdefghijklmnopq', 'a452e658e3096d8187969cbdc930909c'], - ['DATAMATRIX', 'abcdefghij', '8ec27153e5d173aa2cb907845334e68c'], - ['DATAMATRIX', '30Q324343430794|', '4993e149fd20569c8a4f0d758b6dfa76'], - ['DATAMATRIX', '!"£$', '792181edb48c6722217dc7e2e4cd4095'], - ['DATAMATRIX', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\1234567890', '7360a5a6c25476711139ae1244f56c29'], - ['DATAMATRIX', chr(254) - . chr(253) - . 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\' - . chr(252) - . chr(251), '0f078e5e5735396312245740484fa6d1'], - ['DATAMATRIX', 'aABCDEFG', 'f074dee3f0f386d9b2f30b1ce4ad08a8'], - ['DATAMATRIX', '123 45678', '6c2e6503625e408fe9a4e392743f31a8'], - ['DATAMATRIX', 'DATA MATRIX', '3ba4f4ef8449d795813b353ddcce4d23'], - ['DATAMATRIX', '123ABCD89', '7ce2f8433b82c16e80f4a4c59cad5d10'], - ['DATAMATRIX', 'AB/C123-X', '703318e1964c63d5d500d14a821827cd'], - ['DATAMATRIX', str_pad('', 300, chr(254) - . chr(253) - . chr(252) - . chr(251)), 'e524bb17821d0461f3db6f313d35018f'], - ['DATAMATRIX', 'ec:b47' . chr(127) . '4#P d*b}gI2#DB|hl{!~[EYH*=cmR{lf' - . chr(127) . '=gcGIa.st286. #*"!eG[.Ryr?Kn,1mIyQqC3 6\'3N>', '57fbb9bfb7d542e2e5eadb615e6be549'], - ['DATAMATRIX', 'eA211101A2raJTGL/r9o93CVk4gtpEvWd2A2Qz8jvPc7l8ybD3m' - . 'Wel91ih727kldinPeHJCjhr7fIBX1KQQfsN7BFMX00nlS8FlZG+', 'b2f0d45920c7da5b298bbab5cff5d402'], + + [ + 'DATAMATRIX', + '0&0&0&0&0&0&_', + 'fffdfdaec33af0788d24cdfa8cba5ac6', + ], + [ + 'DATAMATRIX', + '0&0&0&0&0&0&0', + '10d0faf5a6e7b71829f268218df7e6af', + ], + [ + 'DATAMATRIX', + '-=-1-=-2-=-3', + '75c6038d90476cec641ad07690989b36', + ], + [ + 'DATAMATRIX', + '-=-1-=-2-=-3x', + 'f020e44d0926d17af7eb21febdb38d53', + ], + [ + 'DATAMATRIX', + '-=-1-=-2-=-3xyz', + '17420fbffefddb5f1b8abd0d05de724d', + ], + [ + 'DATAMATRIX', + '-=-1-=-2-=-3-', + 'a63372ce839b51294964f0da0ae0f9f9', + ], + [ + 'DATAMATRIX', + '-=-1-=-2-=-3-xy', + 'f65ab07c374c53e2a93016776041de42', + ], + [ + 'DATAMATRIX', + '-=-1-=-2-=-3-=x', + '7a30efdf7616397a1ea2fd5fd95fed2c', + ], + [ + 'DATAMATRIX', + '(400)BS2WZ64PA(00)0', + '9cb7f1c2aa5989909229ef8e4252d61d', + ], + [ + 'DATAMATRIX', + '(400)BS2WZ64QA(00)0', + '0494f709138a1feef5a1c9f14852dbe5', + ], + [ + 'DATAMATRIX', + 'LD2B 1 CLNGP', + 'f806889d1dbe0908dcfb530f86098041', + ], + [ + 'DATAMATRIX', + 'XXXXXXXXXNGP', + 'c6f2b7b293a2943bae74f2a191ec4aea', + ], + [ + 'DATAMATRIX', + 'XXXXXXXXXXXXNGP', + 'f7679d5a7ab4a8edf12571a6866d92bc', + ], + [ + 'DATAMATRIX', + 'ABCDABCDAB' . "\x80" . 'DABCD', + '39aca5ed58b922bee369e5ab8e3add8c', + ], + [ + 'DATAMATRIX', + '123aabcdefghijklmnopqrstuvwxyzc', + 'b2d1e957af10655d7a8c3bae86696314', + ], + [ + 'DATAMATRIX', + 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq', + 'c45bd372694ad7a20fca7d45f3d459ab', + ], + [ + 'DATAMATRIX', + 'abcdefghijklmnop', + '4fc7940fe3d19fca12454340c38e3421', + ], + [ + 'DATAMATRIX', + 'abcdefghijklmnopq', + 'a452e658e3096d8187969cbdc930909c', + ], + [ + 'DATAMATRIX', + 'abcdefghij', + '8ec27153e5d173aa2cb907845334e68c', + ], + [ + 'DATAMATRIX', + '30Q324343430794|', + '4993e149fd20569c8a4f0d758b6dfa76', + ], + [ + 'DATAMATRIX', + '!"£$', + '792181edb48c6722217dc7e2e4cd4095', + ], + [ + 'DATAMATRIX', + 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\1234567890', + '7360a5a6c25476711139ae1244f56c29', + ], + [ + 'DATAMATRIX', + "\xFE\xFD" + . 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./\\' + . "\xFC\xFB", + '0f078e5e5735396312245740484fa6d1', + ], + [ + 'DATAMATRIX', + 'aABCDEFG', + 'f074dee3f0f386d9b2f30b1ce4ad08a8', + ], + [ + 'DATAMATRIX', + '123 45678', + '6c2e6503625e408fe9a4e392743f31a8', + ], + [ + 'DATAMATRIX', + 'DATA MATRIX', + '3ba4f4ef8449d795813b353ddcce4d23', + ], + [ + 'DATAMATRIX', + '123ABCD89', + '7ce2f8433b82c16e80f4a4c59cad5d10', + ], + [ + 'DATAMATRIX', + 'AB/C123-X', + '703318e1964c63d5d500d14a821827cd', + ], + [ + 'DATAMATRIX', + str_pad('', 300, "\xFE\xFD\xFC\xFB"), + 'e524bb17821d0461f3db6f313d35018f', + ], + [ + 'DATAMATRIX', + 'ec:b47' . "\x7F" . '4#P d*b}gI2#DB|hl{!~[EYH*=cmR{lf' + . "\x7F" . '=gcGIa.st286. #*"!eG[.Ryr?Kn,1mIyQqC3 6\'3N>', + '57fbb9bfb7d542e2e5eadb615e6be549', + ], + [ + 'DATAMATRIX', + 'eA211101A2raJTGL/r9o93CVk4gtpEvWd2A2Qz8jvPc7l8ybD3m' + . 'Wel91ih727kldinPeHJCjhr7fIBX1KQQfsN7BFMX00nlS8FlZG+', + 'b2f0d45920c7da5b298bbab5cff5d402', + ], // Square - ['DATAMATRIX,S', chr(255) - . chr(254) - . chr(253) - . chr(252) - . chr(251) - . chr(250) - . chr(249) - . chr(248) - . chr(247) - . chr(246) - . chr(245) - . chr(244) - . chr(243) - . chr(242) - . chr(241) - . chr(240) - . chr(239) - . chr(238) - . chr(237) - . chr(236) - . chr(235) - . chr(234) - . chr(233) - . chr(232) - . chr(231) - . chr(230) - . chr(229) - . chr(228) - . chr(227) - . chr(226) - . chr(225) - . chr(224) - . chr(223) - . chr(222) - . chr(221) - . chr(220) - . chr(219) - . chr(218) - . chr(217) - . chr(216) - . chr(215) - . chr(214) - . chr(213) - . chr(212) - . chr(211) - . chr(210) - . chr(209) - . chr(208) - . chr(207) - . chr(206) - . chr(205) - . chr(204) - . chr(203) - . chr(202) - . chr(201) - . chr(200) - . chr(199) - . chr(198) - . chr(197) - . chr(196) - . chr(195) - . chr(194) - . chr(193) - . chr(192) - . chr(191) - . chr(190) - . chr(189) - . chr(188) - . chr(187) - . chr(186) - . chr(185) - . chr(184) - . chr(183) - . chr(182) - . chr(181) - . chr(180) - . chr(179) - . chr(178) - . chr(177) - . chr(176) - . chr(175) - . chr(174) - . chr(173) - . chr(172) - . chr(171) - . chr(170) - . chr(169) - . chr(168) - . chr(167) - . chr(166) - . chr(165) - . chr(164) - . chr(163) - . chr(162) - . chr(161) - . chr(160) - . chr(159) - . chr(158) - . chr(157) - . chr(156) - . chr(155) - . chr(154) - . chr(153) - . chr(152) - . chr(151) - . chr(150) - . chr(149) - . chr(148) - . chr(147) - . chr(146) - . chr(145) - . chr(144) - . chr(143) - . chr(142) - . chr(141) - . chr(140) - . chr(139) - . chr(138) - . chr(137) - . chr(136) - . chr(135) - . chr(134) - . chr(133) - . chr(132) - . chr(131) - . chr(130) - . chr(129) - . chr(128) - . chr(127) - . chr(126) - . chr(125) - . chr(124) - . chr(123) - . chr(122) - . chr(121) - . chr(120) - . chr(119) - . chr(118) - . chr(117) - . chr(116) - . chr(115) - . chr(114) - . chr(113) - . chr(112) - . chr(111) - . chr(110) - . chr(109) - . chr(108) - . chr(107) - . chr(106) - . chr(105) - . chr(104) - . chr(103) - . chr(102) - . chr(101) - . chr(100) - . chr(99) - . chr(98) - . chr(97) - . chr(96) - . chr(95) - . chr(94) - . chr(93) - . chr(92) - . chr(91) - . chr(90) - . chr(89) - . chr(88) - . chr(87) - . chr(86) - . chr(85) - . chr(84) - . chr(83) - . chr(82) - . chr(81) - . chr(80) - . chr(79) - . chr(78) - . chr(77) - . chr(76) - . chr(75) - . chr(74) - . chr(73) - . chr(72) - . chr(71) - . chr(70) - . chr(69) - . chr(68) - . chr(67) - . chr(66) - . chr(65) - . chr(64) - . chr(63) - . chr(62) - . chr(61) - . chr(60) - . chr(59) - . chr(58) - . chr(57) - . chr(56) - . chr(55) - . chr(54) - . chr(53) - . chr(52) - . chr(51) - . chr(50) - . chr(49) - . chr(48) - . chr(47) - . chr(46) - . chr(45) - . chr(44) - . chr(43) - . chr(42) - . chr(41) - . chr(40) - . chr(39) - . chr(38) - . chr(37) - . chr(36) - . chr(35) - . chr(34) - . chr(33) - . chr(32) - . chr(31) - . chr(30) - . chr(29) - . chr(28) - . chr(27) - . chr(26) - . chr(25) - . chr(24) - . chr(23) - . chr(22) - . chr(21) - . chr(20) - . chr(19) - . chr(18) - . chr(17) - . chr(16) - . chr(15) - . chr(14) - . chr(13) - . chr(12) - . chr(11) - . chr(10) - . chr(9) - . chr(8) - . chr(7) - . chr(6) - . chr(5) - . chr(4) - . chr(3) - . chr(2) - . chr(1), '514963c4fde0cee7ff91f76dd56015cc'], + [ + 'DATAMATRIX,S', + "\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8\xF7\xF6" + . "\xF5\xF4\xF3\xF2\xF1\xF0\xEF\xEE\xED\xEC" + . "\xEB\xEA\xE9\xE8\xE7\xE6\xE5\xE4\xE3\xE2" + . "\xE1\xE0\xDF\xDE\xDD\xDC\xDB\xDA\xD9\xD8" + . "\xD7\xD6\xD5\xD4\xD3\xD2\xD1\xD0\xCF\xCE" + . "\xCD\xCC\xCB\xCA\xC9\xC8\xC7\xC6\xC5\xC4" + . "\xC3\xC2\xC1\xC0\xBF\xBE\xBD\xBC\xBB\xBA" + . "\xB9\xB8\xB7\xB6\xB5\xB4\xB3\xB2\xB1\xB0" + . "\xAF\xAE\xAD\xAC\xAB\xAA\xA9\xA8\xA7\xA6" + . "\xA5\xA4\xA3\xA2\xA1\xA0\x9F\x9E\x9D\x9C" + . "\x9B\x9A\x99\x98\x97\x96\x95\x94\x93\x92" + . "\x91\x90\x8F\x8E\x8D\x8C\x8B\x8A\x89\x88" + . "\x87\x86\x85\x84\x83\x82\x81\x80\x7F\x7E" + . "\x7D\x7C\x7B\x7A\x79\x78\x77\x76\x75\x74" + . "\x73\x72\x71\x70\x6F\x6E\x6D\x6C\x6B\x6A" + . "\x69\x68\x67\x66\x65\x64\x63\x62\x61\x60" + . "\x5F\x5E\x5D\x5C\x5B\x5A\x59\x58\x57\x56" + . "\x55\x54\x53\x52\x51\x50\x4F\x4E\x4D\x4C" + . "\x4B\x4A\x49\x48\x47\x46\x45\x44\x43\x42" + . "\x41\x40\x3F\x3E\x3D\x3C\x3B\x3A\x39\x38" + . "\x37\x36\x35\x34\x33\x32\x31\x30\x2F\x2E" + . "\x2D\x2C\x2B\x2A\x29\x28\x27\x26\x25\x24" + . "\x23\x22\x21\x20\x1F\x1E\x1D\x1C\x1B\x1A" + . "\x19\x18\x17\x16\x15\x14\x13\x12\x11\x10" + . "\x0F\x0E\x0D\x0C\x0B\x0A\x09\x08\x07\x06" + . "\x05\x04\x03\x02\x01", + '514963c4fde0cee7ff91f76dd56015cc', + ], // Rectangular shape - ['DATAMATRIX,R', '01234567890', 'd3811e018f960beed6d3fa5e675e290e'], - ['DATAMATRIX,R', '01234567890123456789', 'fe3ecb042dabc4b40c5017e204df105b'], - ['DATAMATRIX,R', '012345678901234567890123456789', '3f8e9aa4413b90f7e1c2e85b4471fd20'], - ['DATAMATRIX,R', '0123456789012345678901234567890123456789', 'b748b02c1c4cae621a84c8dbba97c710'], + [ + 'DATAMATRIX,R', + '01234567890', + 'd3811e018f960beed6d3fa5e675e290e', + ], + [ + 'DATAMATRIX,R', + '01234567890123456789', + 'fe3ecb042dabc4b40c5017e204df105b', + ], + [ + 'DATAMATRIX,R', + '012345678901234567890123456789', + '3f8e9aa4413b90f7e1c2e85b4471fd20', + ], + [ + 'DATAMATRIX,R', + '0123456789012345678901234567890123456789', + 'b748b02c1c4cae621a84c8dbba97c710', + ], // Rectangular GS1 - ['DATAMATRIX,R,GS1', chr(232) . '01034531200000111719112510ABCD1234', 'f55524d239fc95072d99eafe5363cfeb'], - ['DATAMATRIX,R,GS1', chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', 'e17f2a052271a18cdc00b161908eccb9'], - ['DATAMATRIX,R,GS1', chr(232) . '01034531200000111712050810ABCD1234' . chr(232) . '4109501101020917', '31759950f3253805b100fedf3e536575'], + [ + 'DATAMATRIX,R,GS1', + "\xE8" . '01034531200000111719112510ABCD1234', + 'f55524d239fc95072d99eafe5363cfeb', + ], + [ + 'DATAMATRIX,R,GS1', + "\xE8" . '01095011010209171719050810ABCD1234' . "\xE8" . '2110', + 'e17f2a052271a18cdc00b161908eccb9', + ], + [ + 'DATAMATRIX,R,GS1', + "\xE8" . '01034531200000111712050810ABCD1234' . "\xE8" . '4109501101020917', + '31759950f3253805b100fedf3e536575', + ], // Square GS1 - ['DATAMATRIX,S,GS1', chr(232) . '01034531200000111719112510ABCD1234', 'c9efb69a62114fb6a3d2b52f139a372a'], - ['DATAMATRIX,S,GS1', chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', '9630bdba9fc79b4a4911fc465aa08951'], - ['DATAMATRIX,S,GS1', chr(232) . '01034531200000111712050810ABCD1234' . chr(232) . '4109501101020917', 'a29a330a01cce34a346cf7049e2259ee'], + [ + 'DATAMATRIX,S,GS1', + "\xE8" . '01034531200000111719112510ABCD1234', + 'c9efb69a62114fb6a3d2b52f139a372a', + ], + [ + 'DATAMATRIX,S,GS1', + "\xE8" . '01095011010209171719050810ABCD1234' . "\xE8" . '2110', + '9630bdba9fc79b4a4911fc465aa08951', + ], + [ + 'DATAMATRIX,S,GS1', + "\xE8" . '01034531200000111712050810ABCD1234' . "\xE8" . '4109501101020917', + 'a29a330a01cce34a346cf7049e2259ee', + ], + ]; } diff --git a/test/Square/QrCodeTest.php b/test/Square/QrCodeTest.php index d62b09c3..fb48f3a4 100644 --- a/test/Square/QrCodeTest.php +++ b/test/Square/QrCodeTest.php @@ -64,1570 +64,286 @@ public function testGetGrid(string $options, string $code, mixed $expected): voi public static function getGridDataProvider(): array { - return [['', '0123456789', '89e599523008751db7eef3b5befc37ed'], [',L', '0123456789', '89e599523008751db7eef3b5befc37ed'], [',H,NM', '0123456789', '3c4ecb6cc99b7843de8d2d3274a43d9e'], [',L,8B,0,0', '123aeiouàèìòù', '1622068066c77d3e6ea0a3ad420d105c'], [',H,KJ,0,0', 'ぎポ亊', '1d429dd6a1627f6dc1620b3f56862d52'], [',H,ST,0,0', 'ABCdef0123', '3a8260f504bca8de8f55a7b3776080bb'], ['', str_pad('', 350, '0123456789'), '3cca7eb0f61bc39c5a79d7eb3e23a409'], ['', 'abcdefghijklmnopqrstuvwxyz01234567890123456789', '9c489cd7ded55a82b2d7e3589afbd7d0'], [',H,AN,40,1,0,1,2', 'abcdefghijklmnopqrstuvwxyz01234567890123456789', '5ba221be81b269ab1f105b07bf49b372'], ['', chr(158) - . chr(19) - . chr(192) - . chr(8) - . chr(71) - . chr(113) - . chr(107) - . chr(252) - . chr(171) - . chr(169) - . chr(114) - . chr(114) - . chr(204) - . chr(151) - . chr(183) - . chr(20) - . chr(180) - . chr(26) - . chr(73) - . chr(76) - . chr(193) - . chr(16) - . chr(69) - . chr(212) - . chr(232) - . chr(90) - . chr(248) - . chr(115) - . chr(9) - . chr(104) - . chr(149) - . chr(167) - . chr(123) - . chr(86) - . chr(175) - . chr(193) - . chr(199) - . chr(27) - . chr(190) - . chr(115) - . chr(196) - . chr(50) - . chr(228) - . chr(146) - . chr(201) - . chr(156) - . chr(165) - . chr(126) - . chr(182) - . chr(237) - . chr(201) - . chr(121) - . chr(253) - . chr(15) - . chr(78) - . chr(231) - . chr(105) - . chr(72) - . chr(92) - . chr(114) - . chr(175) - . chr(240) - . chr(26) - . chr(43) - . chr(71) - . chr(200) - . chr(236) - . chr(15) - . chr(227) - . chr(172) - . chr(129) - . chr(169) - . chr(221) - . chr(103) - . chr(60) - . chr(167) - . chr(5) - . chr(225) - . chr(39) - . chr(186) - . chr(208) - . chr(240) - . chr(52) - . chr(206) - . chr(254) - . chr(130) - . chr(183) - . chr(105) - . chr(201) - . chr(20) - . chr(218) - . chr(122) - . chr(5) - . chr(244) - . chr(165) - . chr(76) - . chr(189) - . chr(146) - . chr(91) - . chr(162) - . chr(63) - . chr(220) - . chr(76) - . chr(30) - . chr(68) - . chr(135) - . chr(196) - . chr(73) - . chr(106) - . chr(235) - . chr(5) - . chr(59) - . chr(220) - . chr(56) - . chr(11) - . chr(220) - . chr(186) - . chr(194) - . chr(70) - . chr(132) - . chr(213) - . chr(34) - . chr(254) - . chr(218) - . chr(23) - . chr(164) - . chr(40) - . chr(212) - . chr(56) - . chr(130) - . chr(119) - . chr(118) - . chr(95) - . chr(194) - . chr(148) - . chr(163) - . chr(75) - . chr(90) - . chr(236) - . chr(180) - . chr(70) - . chr(240) - . chr(239) - . chr(35) - . chr(42) - . chr(250) - . chr(254) - . chr(227) - . chr(189) - . chr(70) - . chr(105) - . chr(148) - . chr(103) - . chr(104) - . chr(112) - . chr(126) - . chr(13) - . chr(151) - . chr(83) - . chr(68) - . chr(27) - . chr(201) - . chr(186) - . chr(121) - . chr(141) - . chr(80) - . chr(30) - . chr(215) - . chr(169) - . chr(12) - . chr(141) - . chr(238) - . chr(251) - . chr(126) - . chr(18) - . chr(39) - . chr(121) - . chr(18) - . chr(12) - . chr(56) - . chr(88) - . chr(116) - . chr(203) - . chr(190) - . chr(220) - . chr(60) - . chr(61) - . chr(233) - . chr(211) - . chr(144) - . chr(47) - . chr(237) - . chr(90) - . chr(232) - . chr(104) - . chr(230) - . chr(57) - . chr(134) - . chr(191) - . chr(226) - . chr(145) - . chr(77) - . chr(209) - . chr(142) - . chr(202) - . chr(227) - . chr(180) - . chr(69) - . chr(245) - . chr(191) - . chr(124) - . chr(78) - . chr(53) - . chr(73) - . chr(13) - . chr(18) - . chr(133) - . chr(74) - . chr(250) - . chr(89) - . chr(217) - . chr(42) - . chr(71) - . chr(53) - . chr(20) - . chr(175) - . chr(29) - . chr(77) - . chr(54) - . chr(219) - . chr(48) - . chr(198) - . chr(41) - . chr(3) - . chr(85) - . chr(243) - . chr(229) - . chr(11) - . chr(57) - . chr(219) - . chr(201) - . chr(180) - . chr(43) - . chr(253) - . chr(252) - . chr(56) - . chr(17) - . chr(131) - . chr(129) - . chr(12) - . chr(219) - . chr(92) - . chr(54) - . chr(36) - . chr(145) - . chr(74) - . chr(210) - . chr(173) - . chr(151) - . chr(9) - . chr(137) - . chr(198) - . chr(207) - . chr(178) - . chr(201) - . chr(38) - . chr(166) - . chr(175) - . chr(48) - . chr(223) - . chr(140) - . chr(249) - . chr(149) - . chr(182) - . chr(248) - . chr(147) - . chr(237) - . chr(10) - . chr(23) - . chr(112) - . chr(22) - . chr(241) - . chr(204) - . chr(76) - . chr(23) - . chr(94) - . chr(150) - . chr(232) - . chr(13) - . chr(46) - . chr(241) - . chr(149) - . chr(243) - . chr(193) - . chr(73) - . chr(190) - . chr(230) - . chr(239) - . chr(110) - . chr(24), 'd1977c58334ea034ef4201fe95ee4d2b'], ['', chr(158) - . chr(198) - . chr(45) - . chr(94) - . chr(231) - . chr(83) - . chr(60) - . chr(45) - . chr(104) - . chr(62) - . chr(122) - . chr(88) - . chr(245) - . chr(8) - . chr(21) - . chr(76) - . chr(170) - . chr(250) - . chr(87) - . chr(6) - . chr(162) - . chr(32) - . chr(43) - . chr(208) - . chr(17) - . chr(96) - . chr(139) - . chr(43) - . chr(192) - . chr(15) - . chr(57) - . chr(95) - . chr(212) - . chr(102) - . chr(189) - . chr(188) - . chr(184) - . chr(249) - . chr(233) - . chr(34) - . chr(56) - . chr(101) - . chr(122) - . chr(47) - . chr(108) - . chr(142) - . chr(122) - . chr(24) - . chr(137) - . chr(209) - . chr(30) - . chr(45) - . chr(240) - . chr(72) - . chr(253) - . chr(2) - . chr(167) - . chr(138) - . chr(44) - . chr(105) - . chr(152) - . chr(101) - . chr(200) - . chr(109) - . chr(202) - . chr(135) - . chr(43) - . chr(132) - . chr(129) - . chr(21) - . chr(165) - . chr(185) - . chr(121) - . chr(32) - . chr(231) - . chr(229) - . chr(174) - . chr(99) - . chr(252) - . chr(57) - . chr(53) - . chr(27) - . chr(101) - . chr(38) - . chr(99) - . chr(100) - . chr(39) - . chr(12) - . chr(237) - . chr(83) - . chr(116) - . chr(134) - . chr(183) - . chr(62) - . chr(243) - . chr(131) - . chr(196) - . chr(31) - . chr(8) - . chr(70) - . chr(52) - . chr(172) - . chr(254) - . chr(173) - . chr(204) - . chr(231) - . chr(147) - . chr(124) - . chr(75) - . chr(145) - . chr(180) - . chr(128) - . chr(172) - . chr(27) - . chr(165) - . chr(16) - . chr(126) - . chr(204) - . chr(27) - . chr(109) - . chr(33) - . chr(143) - . chr(242) - . chr(216) - . chr(204) - . chr(231) - . chr(92) - . chr(145) - . chr(7) - . chr(99) - . chr(214) - . chr(59) - . chr(17) - . chr(214) - . chr(231) - . chr(221) - . chr(190) - . chr(124) - . chr(90) - . chr(11) - . chr(14) - . chr(16) - . chr(138) - . chr(186) - . chr(43) - . chr(49) - . chr(201) - . chr(168) - . chr(252) - . chr(227) - . chr(22) - . chr(31) - . chr(116) - . chr(10) - . chr(246) - . chr(65) - . chr(240) - . chr(83) - . chr(209) - . chr(247) - . chr(182) - . chr(169) - . chr(52) - . chr(199) - . chr(129) - . chr(29) - . chr(165) - . chr(65) - . chr(152) - . chr(1) - . chr(75) - . chr(166) - . chr(17) - . chr(212) - . chr(97) - . chr(59) - . chr(7) - . chr(44) - . chr(227) - . chr(4) - . chr(17) - . chr(249) - . chr(35) - . chr(132) - . chr(5) - . chr(26) - . chr(196) - . chr(244) - . chr(108) - . chr(151) - . chr(237) - . chr(36) - . chr(66) - . chr(34) - . chr(234) - . chr(194) - . chr(63) - . chr(145) - . chr(4) - . chr(214) - . chr(146) - . chr(79) - . chr(126) - . chr(162) - . chr(36) - . chr(222) - . chr(220) - . chr(42) - . chr(12) - . chr(193) - . chr(46) - . chr(28) - . chr(187) - . chr(80) - . chr(159) - . chr(191) - . chr(106) - . chr(100) - . chr(181) - . chr(213) - . chr(251) - . chr(164) - . chr(249) - . chr(62) - . chr(198) - . chr(228) - . chr(2) - . chr(6) - . chr(119) - . chr(5) - . chr(220) - . chr(10) - . chr(83) - . chr(91) - . chr(171) - . chr(119) - . chr(59) - . chr(137) - . chr(161) - . chr(70) - . chr(75) - . chr(207) - . chr(97) - . chr(8) - . chr(33) - . chr(1) - . chr(198) - . chr(138) - . chr(101) - . chr(125) - . chr(97) - . chr(97) - . chr(34) - . chr(91) - . chr(159) - . chr(231) - . chr(65) - . chr(160) - . chr(237) - . chr(183) - . chr(165) - . chr(202) - . chr(192) - . chr(248) - . chr(38) - . chr(108) - . chr(112) - . chr(96) - . chr(245) - . chr(19) - . chr(166) - . chr(65) - . chr(225) - . chr(8) - . chr(72) - . chr(4) - . chr(9) - . chr(16) - . chr(141) - . chr(109) - . chr(141) - . chr(237) - . chr(206) - . chr(174) - . chr(73) - . chr(111) - . chr(151) - . chr(138) - . chr(16) - . chr(133) - . chr(66) - . chr(180) - . chr(81) - . chr(3) - . chr(173) - . chr(118) - . chr(111) - . chr(31) - . chr(214) - . chr(101) - . chr(49) - . chr(125) - . chr(166) - . chr(20) - . chr(133) - . chr(238) - . chr(23) - . chr(141) - . chr(254) - . chr(163) - . chr(250) - . chr(140) - . chr(146) - . chr(202) - . chr(60) - . chr(219) - . chr(58) - . chr(211) - . chr(102) - . chr(73) - . chr(90) - . chr(167) - . chr(253) - . chr(170) - . chr(170) - . chr(172) - . chr(34) - . chr(27) - . chr(202) - . chr(247) - . chr(128) - . chr(251) - . chr(117) - . chr(39) - . chr(17) - . chr(249) - . chr(23) - . chr(39) - . chr(136) - . chr(22) - . chr(202) - . chr(131) - . chr(162) - . chr(94) - . chr(78) - . chr(222) - . chr(58) - . chr(136) - . chr(178) - . chr(159) - . chr(209) - . chr(14) - . chr(72) - . chr(207) - . chr(183) - . chr(242) - . chr(124) - . chr(217) - . chr(14) - . chr(72) - . chr(209) - . chr(141) - . chr(69) - . chr(72) - . chr(180) - . chr(85) - . chr(67) - . chr(202) - . chr(124) - . chr(202) - . chr(224) - . chr(72) - . chr(79) - . chr(131) - . chr(165) - . chr(157) - . chr(99) - . chr(223) - . chr(38) - . chr(23) - . chr(128) - . chr(246) - . chr(36) - . chr(199) - . chr(199) - . chr(219) - . chr(187) - . chr(69) - . chr(181) - . chr(200) - . chr(140) - . chr(136) - . chr(86) - . chr(208) - . chr(207) - . chr(11) - . chr(39) - . chr(19) - . chr(213) - . chr(162) - . chr(221) - . chr(182) - . chr(233) - . chr(46) - . chr(59) - . chr(144) - . chr(202) - . chr(157) - . chr(112) - . chr(240) - . chr(179) - . chr(240) - . chr(231) - . chr(215) - . chr(185) - . chr(176) - . chr(180) - . chr(117) - . chr(244) - . chr(106) - . chr(62) - . chr(129) - . chr(242) - . chr(148) - . chr(83) - . chr(194) - . chr(159) - . chr(121) - . chr(213) - . chr(117) - . chr(29) - . chr(179) - . chr(44) - . chr(8) - . chr(224) - . chr(103) - . chr(151) - . chr(172) - . chr(5) - . chr(9) - . chr(157) - . chr(184) - . chr(248) - . chr(134) - . chr(145) - . chr(179) - . chr(55) - . chr(70) - . chr(41) - . chr(44) - . chr(176) - . chr(102) - . chr(173) - . chr(163) - . chr(250) - . chr(2) - . chr(103) - . chr(154) - . chr(123) - . chr(61) - . chr(16) - . chr(151) - . chr(240) - . chr(60) - . chr(159) - . chr(210) - . chr(162) - . chr(55) - . chr(127) - . chr(167) - . chr(64) - . chr(30) - . chr(97) - . chr(58) - . chr(163) - . chr(241) - . chr(236) - . chr(218) - . chr(57) - . chr(22) - . chr(8) - . chr(233) - . chr(124) - . chr(180) - . chr(141) - . chr(119) - . chr(182) - . chr(243) - . chr(18) - . chr(51) - . chr(50) - . chr(34) - . chr(201) - . chr(35) - . chr(93) - . chr(106) - . chr(244) - . chr(1) - . chr(161) - . chr(116) - . chr(167) - . chr(224) - . chr(146) - . chr(9) - . chr(28) - . chr(54) - . chr(250) - . chr(10) - . chr(17) - . chr(53) - . chr(32) - . chr(24) - . chr(31) - . chr(155) - . chr(204) - . chr(172) - . chr(20) - . chr(132) - . chr(160) - . chr(38) - . chr(182) - . chr(209) - . chr(72) - . chr(129) - . chr(243) - . chr(164) - . chr(234) - . chr(233) - . chr(164) - . chr(140) - . chr(95) - . chr(77) - . chr(110) - . chr(240) - . chr(86) - . chr(137) - . chr(39) - . chr(81) - . chr(146) - . chr(56) - . chr(134) - . chr(177) - . chr(80) - . chr(164) - . chr(78) - . chr(30) - . chr(81) - . chr(98) - . chr(161) - . chr(241) - . chr(135) - . chr(88) - . chr(196) - . chr(206) - . chr(216) - . chr(185) - . chr(116) - . chr(195) - . chr(163) - . chr(26) - . chr(81) - . chr(3) - . chr(102) - . chr(190) - . chr(243) - . chr(187) - . chr(72) - . chr(28) - . chr(14) - . chr(218) - . chr(83) - . chr(147) - . chr(141) - . chr(163) - . chr(57) - . chr(218) - . chr(192) - . chr(137) - . chr(61) - . chr(98) - . chr(124) - . chr(196) - . chr(186) - . chr(65) - . chr(148) - . chr(147) - . chr(249) - . chr(9) - . chr(88) - . chr(157) - . chr(34) - . chr(168) - . chr(160) - . chr(135) - . chr(103) - . chr(148) - . chr(68) - . chr(175) - . chr(176) - . chr(81) - . chr(138) - . chr(4) - . chr(228) - . chr(25) - . chr(167) - . chr(30) - . chr(242) - . chr(104) - . chr(167) - . chr(49) - . chr(202) - . chr(36) - . chr(244) - . chr(133) - . chr(100) - . chr(138) - . chr(26) - . chr(94) - . chr(146) - . chr(113) - . chr(251) - . chr(180) - . chr(27) - . chr(157) - . chr(61) - . chr(129) - . chr(51) - . chr(128) - . chr(50) - . chr(226) - . chr(209) - . chr(188) - . chr(230) - . chr(182) - . chr(212) - . chr(142) - . chr(212) - . chr(200) - . chr(246) - . chr(124) - . chr(248) - . chr(193) - . chr(159) - . chr(238) - . chr(71) - . chr(4) - . chr(121) - . chr(96) - . chr(98) - . chr(13) - . chr(209) - . chr(95) - . chr(193) - . chr(235) - . chr(251) - . chr(253) - . chr(110) - . chr(47) - . chr(127) - . chr(159) - . chr(18) - . chr(81) - . chr(93) - . chr(247) - . chr(9) - . chr(50) - . chr(135) - . chr(220) - . chr(249) - . chr(126) - . chr(90) - . chr(243) - . chr(64) - . chr(248) - . chr(227) - . chr(135) - . chr(252) - . chr(94) - . chr(231) - . chr(96) - . chr(106) - . chr(186) - . chr(190) - . chr(44) - . chr(166) - . chr(187) - . chr(43) - . chr(21) - . chr(233) - . chr(169) - . chr(180) - . chr(251) - . chr(250) - . chr(18) - . chr(244) - . chr(5) - . chr(68) - . chr(124) - . chr(225) - . chr(63) - . chr(250) - . chr(60) - . chr(52) - . chr(59) - . chr(53) - . chr(24) - . chr(194) - . chr(51) - . chr(117) - . chr(171) - . chr(146) - . chr(223) - . chr(102) - . chr(82) - . chr(12) - . chr(13) - . chr(14) - . chr(54) - . chr(34) - . chr(246) - . chr(223) - . chr(214) - . chr(243) - . chr(218) - . chr(232) - . chr(232) - . chr(222) - . chr(45) - . chr(102) - . chr(192) - . chr(108) - . chr(97) - . chr(252) - . chr(159) - . chr(156) - . chr(50) - . chr(183) - . chr(96) - . chr(101) - . chr(45) - . chr(12) - . chr(246) - . chr(13) - . chr(113) - . chr(73) - . chr(25) - . chr(126) - . chr(87) - . chr(79) - . chr(160) - . chr(78) - . chr(47) - . chr(119) - . chr(67) - . chr(11) - . chr(96) - . chr(45) - . chr(233) - . chr(141) - . chr(146) - . chr(171) - . chr(249) - . chr(242) - . chr(168) - . chr(153) - . chr(143) - . chr(218) - . chr(81) - . chr(238) - . chr(64) - . chr(126) - . chr(250) - . chr(55) - . chr(139) - . chr(109) - . chr(128) - . chr(163) - . chr(234) - . chr(214) - . chr(242) - . chr(139) - . chr(38) - . chr(34) - . chr(4) - . chr(104) - . chr(45) - . chr(100) - . chr(148) - . chr(23) - . chr(241) - . chr(40) - . chr(194) - . chr(235) - . chr(27) - . chr(107) - . chr(133) - . chr(170) - . chr(70) - . chr(214) - . chr(154) - . chr(133) - . chr(86) - . chr(149) - . chr(188) - . chr(224) - . chr(3) - . chr(61) - . chr(133) - . chr(237) - . chr(21) - . chr(121) - . chr(122) - . chr(59) - . chr(154) - . chr(125) - . chr(163) - . chr(199) - . chr(225) - . chr(56) - . chr(222) - . chr(211) - . chr(96) - . chr(161) - . chr(191) - . chr(122) - . chr(13) - . chr(70) - . chr(38) - . chr(82) - . chr(30) - . chr(191) - . chr(215) - . chr(115) - . chr(86) - . chr(148) - . chr(85) - . chr(89) - . chr(209) - . chr(218) - . chr(71) - . chr(230) - . chr(84) - . chr(193) - . chr(34) - . chr(238) - . chr(63) - . chr(196) - . chr(182) - . chr(34) - . chr(252) - . chr(149) - . chr(244) - . chr(93) - . chr(55) - . chr(180) - . chr(215) - . chr(68) - . chr(249) - . chr(252) - . chr(150) - . chr(24) - . chr(189) - . chr(110) - . chr(139) - . chr(21) - . chr(4) - . chr(223) - . chr(109) - . chr(213) - . chr(186) - . chr(180) - . chr(188) - . chr(16) - . chr(118) - . chr(221) - . chr(253) - . chr(181) - . chr(163) - . chr(180) - . chr(214) - . chr(160) - . chr(75) - . chr(203) - . chr(252) - . chr(130) - . chr(129) - . chr(213) - . chr(197) - . chr(124) - . chr(210) - . chr(92) - . chr(148) - . chr(145) - . chr(202) - . chr(32) - . chr(166) - . chr(205) - . chr(1) - . chr(21) - . chr(164) - . chr(187) - . chr(200) - . chr(97) - . chr(202) - . chr(64) - . chr(64) - . chr(200) - . chr(245) - . chr(226) - . chr(126) - . chr(205) - . chr(132) - . chr(201) - . chr(154) - . chr(130) - . chr(76) - . chr(28) - . chr(88) - . chr(18) - . chr(152) - . chr(44) - . chr(110) - . chr(45) - . chr(188) - . chr(57) - . chr(76) - . chr(100) - . chr(8) - . chr(76) - . chr(120) - . chr(172) - . chr(9) - . chr(65) - . chr(14) - . chr(210) - . chr(129) - . chr(78) - . chr(156) - . chr(120) - . chr(50) - . chr(28) - . chr(70) - . chr(181) - . chr(228) - . chr(223) - . chr(56) - . chr(49) - . chr(251) - . chr(143) - . chr(67) - . chr(148) - . chr(187) - . chr(176) - . chr(192) - . chr(120) - . chr(233) - . chr(14) - . chr(219) - . chr(241) - . chr(90) - . chr(85) - . chr(158) - . chr(98) - . chr(150) - . chr(172) - . chr(54) - . chr(24) - . chr(249) - . chr(209) - . chr(143) - . chr(45) - . chr(236) - . chr(213) - . chr(225) - . chr(210) - . chr(182) - . chr(27) - . chr(4) - . chr(179) - . chr(169) - . chr(70) - . chr(72) - . chr(101) - . chr(246) - . chr(10) - . chr(221) - . chr(225) - . chr(24) - . chr(186) - . chr(212) - . chr(113) - . chr(16) - . chr(115) - . chr(211) - . chr(165) - . chr(33) - . chr(10) - . chr(189) - . chr(28) - . chr(219), 'f4bf6b42c6964562a3a91e054fc8ec51'], [',H,NM', chr(26) - . chr(151) - . chr(224) - . chr(193) - . chr(71) - . chr(32) - . chr(162) - . chr(191) - . chr(30) - . chr(98) - . chr(82) - . chr(13) - . chr(153) - . chr(145) - . chr(69) - . chr(3) - . chr(123) - . chr(227) - . chr(50) - . chr(200) - . chr(24) - . chr(234) - . chr(128) - . chr(81) - . chr(232) - . chr(112) - . chr(147) - . chr(45) - . chr(25) - . chr(8) - . chr(38) - . chr(51) - . chr(158) - . chr(7) - . chr(243) - . chr(229) - . chr(39) - . chr(150) - . chr(165) - . chr(69) - . chr(247) - . chr(246) - . chr(81) - . chr(146) - . chr(137) - . chr(149) - . chr(148) - . chr(6) - . chr(122) - . chr(197), '4f6fd3799489b48fa07e1a7aef0561fc'], [',H,AN', chr(205) - . chr(146) - . chr(176) - . chr(79) - . chr(226) - . chr(154) - . chr(191) - . chr(118) - . chr(198) - . chr(215) - . chr(126) - . chr(236) - . chr(12) - . chr(29) - . chr(243) - . chr(254) - . chr(4) - . chr(27) - . chr(150) - . chr(168) - . chr(96) - . chr(142) - . chr(160) - . chr(176) - . chr(34) - . chr(42) - . chr(71) - . chr(182) - . chr(48) - . chr(192) - . chr(125) - . chr(252) - . chr(84) - . chr(46) - . chr(77) - . chr(55) - . chr(200) - . chr(13) - . chr(173) - . chr(144) - . chr(227) - . chr(44) - . chr(125) - . chr(238) - . chr(73) - . chr(113) - . chr(238) - . chr(76) - . chr(140) - . chr(133), '55cd590ed76d12591c6df3b673904530'], [',H,KJ', chr(244) - . chr(235) - . chr(21) - . chr(149) - . chr(157) - . chr(54) - . chr(191) - . chr(227) - . chr(235) - . chr(238) - . chr(165) - . chr(105) - . chr(236) - . chr(248) - . chr(151) - . chr(58) - . chr(49) - . chr(97) - . chr(70) - . chr(221) - . chr(240) - . chr(43) - . chr(11) - . chr(111) - . chr(27) - . chr(83) - . chr(223) - . chr(10) - . chr(159) - . chr(109) - . chr(142) - . chr(148) - . chr(89) - . chr(163) - . chr(42) - . chr(246) - . chr(216) - . chr(233) - . chr(218) - . chr(197) - . chr(216) - . chr(129) - . chr(48) - . chr(197) - . chr(122) - . chr(199) - . chr(1) - . chr(170) - . chr(41) - . chr(70), '92e82c296965d97d35ab7168ece11dd0'], [',H,8B', chr(137) - . chr(27) - . chr(112) - . chr(147) - . chr(137) - . chr(138) - . chr(230) - . chr(106) - . chr(148) - . chr(134) - . chr(214) - . chr(36) - . chr(27) - . chr(49) - . chr(198) - . chr(69) - . chr(40) - . chr(160) - . chr(47) - . chr(4) - . chr(103) - . chr(9) - . chr(133) - . chr(150) - . chr(206) - . chr(254) - . chr(95) - . chr(206) - . chr(170) - . chr(136) - . chr(22) - . chr(53) - . chr(162) - . chr(134) - . chr(199) - . chr(45) - . chr(18) - . chr(174) - . chr(150) - . chr(165) - . chr(54) - . chr(109) - . chr(201) - . chr(81) - . chr(158) - . chr(144) - . chr(150) - . chr(198) - . chr(50) - . chr(196), '68799fdb9685b5e2f258245833006425'], [',H,ST', chr(201) - . chr(152) - . chr(205) - . chr(79) - . chr(47) - . chr(157) - . chr(79) - . chr(142) - . chr(108) - . chr(249) - . chr(23) - . chr(130) - . chr(47) - . chr(185) - . chr(9) - . chr(246) - . chr(229) - . chr(26) - . chr(166) - . chr(124) - . chr(191) - . chr(219) - . chr(233) - . chr(137) - . chr(45) - . chr(137) - . chr(27) - . chr(194) - . chr(80) - . chr(76) - . chr(136) - . chr(27) - . chr(227) - . chr(87) - . chr(106) - . chr(20) - . chr(243) - . chr(184) - . chr(161) - . chr(97) - . chr(179) - . chr(184) - . chr(226) - . chr(226) - . chr(114) - . chr(235) - . chr(217) - . chr(88) - . chr(6) - . chr(129), '6fb328c418ea40c6c94277f420ba9357'], ['', 'w(fa`nC]e=}OY(K^ 3xN1Vz1gkKnFS;&TN $`W~r?;9\\l?]5MF@<~oh>\\4-#hH*=w*AYaAL!]f^J&<`Tc!' - . 'pcpZ"Nn0RWY\\uQf8+HZXJ8?*bFGDz+Eln7Gqe6"8n[te.\\}:&YrQq3[UY#yU.@B}Xio>!rWoNMV]*Uw0/kb!~>WYAR0PrROK' - . '=?j>3B/boe@z;8,K$nM$-%]OWm KAOv^oa}#%-ets&p/?|[Dk)Hy.\'IfuI27y*viktmq#Tfv[X\'zUb?Bkh=zofbe1t|+~tuk' - . 'id]l9Edt}kpTO0wSr^PK|T2SZ:[Jb0UX!I8}Grc^>L)jzG>n\'n:%DMX g5KKF!$GJ=Er0*QOVZ:R#YA+H\\0m*inr :>G;Cof`5Yq@,Avg\\J' - . 'j6lv_J(MUqv>?03:!+8ig9`\\-PZW\'D%Qz^wEC,z3JrQj#d&$p>nYXP6f!p' - . '?)5EZ1$RWH_S[+F-vIr|Nc<==tmT\\oF{x\\ASnF\'FnfyKr@YijLg91$VOyD%V4KS-(tav;h>+P8VCY0.D]u^nz6?tZDLoo }' - . 'xt_p1I0=zIs?#%MHbD(R?>q4y7ai(ah"WIrir$\'nM{.P![yd "7@@*T:A7%IxmKP7?:+CAyp>)B?e<$e><\'_F\\yhs~2ll^>' - . '%~X1Bz+494VYys^`2zhrBEl+9l>&Y}D_|}p@y|T32,m- Ln3HW&j|sv6`6=;5bz2alS[i(o{5]*6*xIRPP>NE6d&L#Abe=tG+H' - . '$tQsqgQ{}\\tH0FyNt?eZE2]gtD&jl14p\'fdxO7uMskv$2pS(19bWLA@BeF-RXBD_*)YY@O\'5;~9NolV!\':YS[yuA@$tyF9' - . 'YPC3*cc2y~13N"!%$(@][{WR>xV4r|MMNp`YUDkPD|cr~ex#m9`J69}T2Th&R7S")4[_YG0~EtqDZkHI&*tw+T.8r!mk4j"CEn9+S!Qn]\'Ohu%y0`9)lm7' - . '%a9sMN^Oq$?,0r.ablh2U_8PoxixeX1k;K_hy>9lBXxRL\'5/s~BJ^Z{OSfI:?[&[\'eD!$^mG8gzen1uc08/or+@Fria2FgnM' - . 'N3NRr=z+%uqt\'gY8 h(rtI:g4{zZdi(3}Wfpta|zXoo`WIxX3"L)Kgp_cl:IVB\\UyCGo&Ej^5[?m&8F::rCfZ4F?"`hX$F/~' - . 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjBmu7 GM3ZK!qp|)!P1" sRanqC(:Ky&mh{&hDS|~ }qqzzrL,u' - . 'L!H/o:RwU}r[l\\XrE|FB{FAm9=i-iv#7wKFgfx`RM883KI~dMkt}L9 ]uN[,@:6/[",:jKl8c%L/OKs}7i{c#{BxK}%' - . 'k9(0*S}C7#oGS;TW2x8z]!sK=k]rf', '83747986cf0df320b915587609232076']]; + return [ + [ + '', + '0123456789', + '89e599523008751db7eef3b5befc37ed', + ], + [ + ',L', + '0123456789', + '89e599523008751db7eef3b5befc37ed', + ], + [ + ',H,NM', + '0123456789', + '3c4ecb6cc99b7843de8d2d3274a43d9e', + ], + [ + ',L,8B,0,0', + '123aeiouàèìòù', + '1622068066c77d3e6ea0a3ad420d105c', + ], + [ + ',H,KJ,0,0', + 'ぎポ亊', + '1d429dd6a1627f6dc1620b3f56862d52', + ], + [ + ',H,ST,0,0', + 'ABCdef0123', + '3a8260f504bca8de8f55a7b3776080bb', + ], + [ + '', + str_pad('', 350, '0123456789'), + '3cca7eb0f61bc39c5a79d7eb3e23a409', + ], + [ + '', + 'abcdefghijklmnopqrstuvwxyz01234567890123456789', + '9c489cd7ded55a82b2d7e3589afbd7d0', + ], + [ + ',H,AN,40,1,0,1,2', + 'abcdefghijklmnopqrstuvwxyz01234567890123456789', + '5ba221be81b269ab1f105b07bf49b372', + ], + [ + '', + "\x9E\x13\xC0\x08\x47\x71\x6B\xFC\xAB\xA9" + . "\x72\x72\xCC\x97\xB7\x14\xB4\x1A\x49\x4C" + . "\xC1\x10\x45\xD4\xE8\x5A\xF8\x73\x09\x68" + . "\x95\xA7\x7B\x56\xAF\xC1\xC7\x1B\xBE\x73" + . "\xC4\x32\xE4\x92\xC9\x9C\xA5\x7E\xB6\xED" + . "\xC9\x79\xFD\x0F\x4E\xE7\x69\x48\x5C\x72" + . "\xAF\xF0\x1A\x2B\x47\xC8\xEC\x0F\xE3\xAC" + . "\x81\xA9\xDD\x67\x3C\xA7\x05\xE1\x27\xBA" + . "\xD0\xF0\x34\xCE\xFE\x82\xB7\x69\xC9\x14" + . "\xDA\x7A\x05\xF4\xA5\x4C\xBD\x92\x5B\xA2" + . "\x3F\xDC\x4C\x1E\x44\x87\xC4\x49\x6A\xEB" + . "\x05\x3B\xDC\x38\x0B\xDC\xBA\xC2\x46\x84" + . "\xD5\x22\xFE\xDA\x17\xA4\x28\xD4\x38\x82" + . "\x77\x76\x5F\xC2\x94\xA3\x4B\x5A\xEC\xB4" + . "\x46\xF0\xEF\x23\x2A\xFA\xFE\xE3\xBD\x46" + . "\x69\x94\x67\x68\x70\x7E\x0D\x97\x53\x44" + . "\x1B\xC9\xBA\x79\x8D\x50\x1E\xD7\xA9\x0C" + . "\x8D\xEE\xFB\x7E\x12\x27\x79\x12\x0C\x38" + . "\x58\x74\xCB\xBE\xDC\x3C\x3D\xE9\xD3\x90" + . "\x2F\xED\x5A\xE8\x68\xE6\x39\x86\xBF\xE2" + . "\x91\x4D\xD1\x8E\xCA\xE3\xB4\x45\xF5\xBF" + . "\x7C\x4E\x35\x49\x0D\x12\x85\x4A\xFA\x59" + . "\xD9\x2A\x47\x35\x14\xAF\x1D\x4D\x36\xDB" + . "\x30\xC6\x29\x03\x55\xF3\xE5\x0B\x39\xDB" + . "\xC9\xB4\x2B\xFD\xFC\x38\x11\x83\x81\x0C" + . "\xDB\x5C\x36\x24\x91\x4A\xD2\xAD\x97\x09" + . "\x89\xC6\xCF\xB2\xC9\x26\xA6\xAF\x30\xDF" + . "\x8C\xF9\x95\xB6\xF8\x93\xED\x0A\x17\x70" + . "\x16\xF1\xCC\x4C\x17\x5E\x96\xE8\x0D\x2E" + . "\xF1\x95\xF3\xC1\x49\xBE\xE6\xEF\x6E\x18", + 'd1977c58334ea034ef4201fe95ee4d2b', + ], + [ + '', + "\x9E\xC6\x2D\x5E\xE7\x53\x3C\x2D\x68\x3E" + . "\x7A\x58\xF5\x08\x15\x4C\xAA\xFA\x57\x06" + . "\xA2\x20\x2B\xD0\x11\x60\x8B\x2B\xC0\x0F" + . "\x39\x5F\xD4\x66\xBD\xBC\xB8\xF9\xE9\x22" + . "\x38\x65\x7A\x2F\x6C\x8E\x7A\x18\x89\xD1" + . "\x1E\x2D\xF0\x48\xFD\x02\xA7\x8A\x2C\x69" + . "\x98\x65\xC8\x6D\xCA\x87\x2B\x84\x81\x15" + . "\xA5\xB9\x79\x20\xE7\xE5\xAE\x63\xFC\x39" + . "\x35\x1B\x65\x26\x63\x64\x27\x0C\xED\x53" + . "\x74\x86\xB7\x3E\xF3\x83\xC4\x1F\x08\x46" + . "\x34\xAC\xFE\xAD\xCC\xE7\x93\x7C\x4B\x91" + . "\xB4\x80\xAC\x1B\xA5\x10\x7E\xCC\x1B\x6D" + . "\x21\x8F\xF2\xD8\xCC\xE7\x5C\x91\x07\x63" + . "\xD6\x3B\x11\xD6\xE7\xDD\xBE\x7C\x5A\x0B" + . "\x0E\x10\x8A\xBA\x2B\x31\xC9\xA8\xFC\xE3" + . "\x16\x1F\x74\x0A\xF6\x41\xF0\x53\xD1\xF7" + . "\xB6\xA9\x34\xC7\x81\x1D\xA5\x41\x98\x01" + . "\x4B\xA6\x11\xD4\x61\x3B\x07\x2C\xE3\x04" + . "\x11\xF9\x23\x84\x05\x1A\xC4\xF4\x6C\x97" + . "\xED\x24\x42\x22\xEA\xC2\x3F\x91\x04\xD6" + . "\x92\x4F\x7E\xA2\x24\xDE\xDC\x2A\x0C\xC1" + . "\x2E\x1C\xBB\x50\x9F\xBF\x6A\x64\xB5\xD5" + . "\xFB\xA4\xF9\x3E\xC6\xE4\x02\x06\x77\x05" + . "\xDC\x0A\x53\x5B\xAB\x77\x3B\x89\xA1\x46" + . "\x4B\xCF\x61\x08\x21\x01\xC6\x8A\x65\x7D" + . "\x61\x61\x22\x5B\x9F\xE7\x41\xA0\xED\xB7" + . "\xA5\xCA\xC0\xF8\x26\x6C\x70\x60\xF5\x13" + . "\xA6\x41\xE1\x08\x48\x04\x09\x10\x8D\x6D" + . "\x8D\xED\xCE\xAE\x49\x6F\x97\x8A\x10\x85" + . "\x42\xB4\x51\x03\xAD\x76\x6F\x1F\xD6\x65" + . "\x31\x7D\xA6\x14\x85\xEE\x17\x8D\xFE\xA3" + . "\xFA\x8C\x92\xCA\x3C\xDB\x3A\xD3\x66\x49" + . "\x5A\xA7\xFD\xAA\xAA\xAC\x22\x1B\xCA\xF7" + . "\x80\xFB\x75\x27\x11\xF9\x17\x27\x88\x16" + . "\xCA\x83\xA2\x5E\x4E\xDE\x3A\x88\xB2\x9F" + . "\xD1\x0E\x48\xCF\xB7\xF2\x7C\xD9\x0E\x48" + . "\xD1\x8D\x45\x48\xB4\x55\x43\xCA\x7C\xCA" + . "\xE0\x48\x4F\x83\xA5\x9D\x63\xDF\x26\x17" + . "\x80\xF6\x24\xC7\xC7\xDB\xBB\x45\xB5\xC8" + . "\x8C\x88\x56\xD0\xCF\x0B\x27\x13\xD5\xA2" + . "\xDD\xB6\xE9\x2E\x3B\x90\xCA\x9D\x70\xF0" + . "\xB3\xF0\xE7\xD7\xB9\xB0\xB4\x75\xF4\x6A" + . "\x3E\x81\xF2\x94\x53\xC2\x9F\x79\xD5\x75" + . "\x1D\xB3\x2C\x08\xE0\x67\x97\xAC\x05\x09" + . "\x9D\xB8\xF8\x86\x91\xB3\x37\x46\x29\x2C" + . "\xB0\x66\xAD\xA3\xFA\x02\x67\x9A\x7B\x3D" + . "\x10\x97\xF0\x3C\x9F\xD2\xA2\x37\x7F\xA7" + . "\x40\x1E\x61\x3A\xA3\xF1\xEC\xDA\x39\x16" + . "\x08\xE9\x7C\xB4\x8D\x77\xB6\xF3\x12\x33" + . "\x32\x22\xC9\x23\x5D\x6A\xF4\x01\xA1\x74" + . "\xA7\xE0\x92\x09\x1C\x36\xFA\x0A\x11\x35" + . "\x20\x18\x1F\x9B\xCC\xAC\x14\x84\xA0\x26" + . "\xB6\xD1\x48\x81\xF3\xA4\xEA\xE9\xA4\x8C" + . "\x5F\x4D\x6E\xF0\x56\x89\x27\x51\x92\x38" + . "\x86\xB1\x50\xA4\x4E\x1E\x51\x62\xA1\xF1" + . "\x87\x58\xC4\xCE\xD8\xB9\x74\xC3\xA3\x1A" + . "\x51\x03\x66\xBE\xF3\xBB\x48\x1C\x0E\xDA" + . "\x53\x93\x8D\xA3\x39\xDA\xC0\x89\x3D\x62" + . "\x7C\xC4\xBA\x41\x94\x93\xF9\x09\x58\x9D" + . "\x22\xA8\xA0\x87\x67\x94\x44\xAF\xB0\x51" + . "\x8A\x04\xE4\x19\xA7\x1E\xF2\x68\xA7\x31" + . "\xCA\x24\xF4\x85\x64\x8A\x1A\x5E\x92\x71" + . "\xFB\xB4\x1B\x9D\x3D\x81\x33\x80\x32\xE2" + . "\xD1\xBC\xE6\xB6\xD4\x8E\xD4\xC8\xF6\x7C" + . "\xF8\xC1\x9F\xEE\x47\x04\x79\x60\x62\x0D" + . "\xD1\x5F\xC1\xEB\xFB\xFD\x6E\x2F\x7F\x9F" + . "\x12\x51\x5D\xF7\x09\x32\x87\xDC\xF9\x7E" + . "\x5A\xF3\x40\xF8\xE3\x87\xFC\x5E\xE7\x60" + . "\x6A\xBA\xBE\x2C\xA6\xBB\x2B\x15\xE9\xA9" + . "\xB4\xFB\xFA\x12\xF4\x05\x44\x7C\xE1\x3F" + . "\xFA\x3C\x34\x3B\x35\x18\xC2\x33\x75\xAB" + . "\x92\xDF\x66\x52\x0C\x0D\x0E\x36\x22\xF6" + . "\xDF\xD6\xF3\xDA\xE8\xE8\xDE\x2D\x66\xC0" + . "\x6C\x61\xFC\x9F\x9C\x32\xB7\x60\x65\x2D" + . "\x0C\xF6\x0D\x71\x49\x19\x7E\x57\x4F\xA0" + . "\x4E\x2F\x77\x43\x0B\x60\x2D\xE9\x8D\x92" + . "\xAB\xF9\xF2\xA8\x99\x8F\xDA\x51\xEE\x40" + . "\x7E\xFA\x37\x8B\x6D\x80\xA3\xEA\xD6\xF2" + . "\x8B\x26\x22\x04\x68\x2D\x64\x94\x17\xF1" + . "\x28\xC2\xEB\x1B\x6B\x85\xAA\x46\xD6\x9A" + . "\x85\x56\x95\xBC\xE0\x03\x3D\x85\xED\x15" + . "\x79\x7A\x3B\x9A\x7D\xA3\xC7\xE1\x38\xDE" + . "\xD3\x60\xA1\xBF\x7A\x0D\x46\x26\x52\x1E" + . "\xBF\xD7\x73\x56\x94\x55\x59\xD1\xDA\x47" + . "\xE6\x54\xC1\x22\xEE\x3F\xC4\xB6\x22\xFC" + . "\x95\xF4\x5D\x37\xB4\xD7\x44\xF9\xFC\x96" + . "\x18\xBD\x6E\x8B\x15\x04\xDF\x6D\xD5\xBA" + . "\xB4\xBC\x10\x76\xDD\xFD\xB5\xA3\xB4\xD6" + . "\xA0\x4B\xCB\xFC\x82\x81\xD5\xC5\x7C\xD2" + . "\x5C\x94\x91\xCA\x20\xA6\xCD\x01\x15\xA4" + . "\xBB\xC8\x61\xCA\x40\x40\xC8\xF5\xE2\x7E" + . "\xCD\x84\xC9\x9A\x82\x4C\x1C\x58\x12\x98" + . "\x2C\x6E\x2D\xBC\x39\x4C\x64\x08\x4C\x78" + . "\xAC\x09\x41\x0E\xD2\x81\x4E\x9C\x78\x32" + . "\x1C\x46\xB5\xE4\xDF\x38\x31\xFB\x8F\x43" + . "\x94\xBB\xB0\xC0\x78\xE9\x0E\xDB\xF1\x5A" + . "\x55\x9E\x62\x96\xAC\x36\x18\xF9\xD1\x8F" + . "\x2D\xEC\xD5\xE1\xD2\xB6\x1B\x04\xB3\xA9" + . "\x46\x48\x65\xF6\x0A\xDD\xE1\x18\xBA\xD4" + . "\x71\x10\x73\xD3\xA5\x21\x0A\xBD\x1C\xDB", + 'f4bf6b42c6964562a3a91e054fc8ec51'], + [ + ',H,NM', + + "\x1A\x97\xE0\xC1\x47\x20\xA2\xBF\x1E\x62" + . "\x52\x0D\x99\x91\x45\x03\x7B\xE3\x32\xC8" + . "\x18\xEA\x80\x51\xE8\x70\x93\x2D\x19\x08" + . "\x26\x33\x9E\x07\xF3\xE5\x27\x96\xA5\x45" + . "\xF7\xF6\x51\x92\x89\x95\x94\x06\x7A\xC5", + + '4f6fd3799489b48fa07e1a7aef0561fc', + ], + [ + ',H,AN', + + "\xCD\x92\xB0\x4F\xE2\x9A\xBF\x76\xC6\xD7" + . "\x7E\xEC\x0C\x1D\xF3\xFE\x04\x1B\x96\xA8" + . "\x60\x8E\xA0\xB0\x22\x2A\x47\xB6\x30\xC0" + . "\x7D\xFC\x54\x2E\x4D\x37\xC8\x0D\xAD\x90" + . "\xE3\x2C\x7D\xEE\x49\x71\xEE\x4C\x8C\x85", + + '55cd590ed76d12591c6df3b673904530', + ], + [ + ',H,KJ', + "\xF4\xEB\x15\x95\x9D\x36\xBF\xE3\xEB\xEE" + . "\xA5\x69\xEC\xF8\x97\x3A\x31\x61\x46\xDD" + . "\xF0\x2B\x0B\x6F\x1B\x53\xDF\x0A\x9F\x6D" + . "\x8E\x94\x59\xA3\x2A\xF6\xD8\xE9\xDA\xC5" + . "\xD8\x81\x30\xC5\x7A\xC7\x01\xAA\x29\x46", + + '92e82c296965d97d35ab7168ece11dd0', + ], + [ + ',H,8B', + "\x89\x1B\x70\x93\x89\x8A\xE6\x6A\x94\x86" + . "\xD6\x24\x1B\x31\xC6\x45\x28\xA0\x2F\x04" + . "\x67\x09\x85\x96\xCE\xFE\x5F\xCE\xAA\x88" + . "\x16\x35\xA2\x86\xC7\x2D\x12\xAE\x96\xA5" + . "\x36\x6D\xC9\x51\x9E\x90\x96\xC6\x32\xC4", + '68799fdb9685b5e2f258245833006425', + ], + [ + ',H,ST', + "\xC9\x98\xCD\x4F\x2F\x9D\x4F\x8E\x6C\xF9" + . "\x17\x82\x2F\xB9\x09\xF6\xE5\x1A\xA6\x7C" + . "\xBF\xDB\xE9\x89\x2D\x89\x1B\xC2\x50\x4C" + . "\x88\x1B\xE3\x57\x6A\x14\xF3\xB8\xA1\x61" + . "\xB3\xB8\xE2\xE2\x72\xEB\xD9\x58\x06\x81", + '6fb328c418ea40c6c94277f420ba9357', + ], + [ + '', + 'w(fa`nC]e=}OY(K^ 3xN1Vz1gkKnFS;&TN ' + . '$`W~r?;9\\l?]5MF@<~oh>\\4-#hH*=w*AYaAL!]f^J&<`Tc!' + . 'pcpZ"Nn0RWY\\uQf8+HZXJ8?*bFGDz+Eln7Gqe6"8n[te.\\}' + . ':&YrQq3[UY#yU.@B}Xio>!rWoNMV]*Uw0/kb!~>WYAR0PrROK' + . '=?j>3B/boe@z;8,K$nM$-%]OWm KAOv^oa}#%-ets&p/?|[Dk' + . ')Hy.\'IfuI27y*viktmq#Tfv[X\'zUb?Bkh=zofbe1t|+~tuk' + . 'id]l9Edt}kpTO0wSr^PK|T2SZ:[Jb0UX!I8}Grc^>L)jzG>n\'n:%DMX g5KK' + . 'F!$GJ=Er0*QOVZ:R#YA+H\\0m*inr :>G;Cof`5Yq@,Avg\\J' + . 'j6lv_J(MUqv' + . '>?03:!+8ig9`\\-PZW\'D%Qz^wEC,z3JrQj#d&$p>nYXP6f!p' + . '?)5EZ1$RWH_S[+F-vIr|Nc<==tmT\\oF{x\\ASnF\'FnfyKr@' + . 'YijLg91$VOyD%V4KS-(tav;h>+P8VCY0.D]u^nz6?tZDLoo }' + . 'xt_p1I0=zIs?#%MHbD(R?>q4y7ai(ah"WIrir$\'nM{.P![yd' + . ' "7@@*T:A7%IxmKP7?:+CAyp>)B?e<$e><\'_F\\yhs~2ll^>' + . '%~X1Bz+494VYys^`2zhrBEl+9l>&Y}D_|}p@y|T32,m- Ln3H' + . 'W&j|sv6`6=;5bz2alS[i(o{5]*6*xIRPP>NE6d&L#Abe=tG+H' + . '$tQsqgQ{}\\tH0FyNt?eZE2]gtD&jl14p\'fdxO7uMskv$2pS' + . '(19bWLA@BeF-RXBD_*)YY@O\'5;~9NolV!\':YS[yuA@$tyF9' + . 'YPC3*cc2y~13N"!%$(@][{WR>xV4r|MMNp`YUDkPD|cr~ex#m' + . '9`J69}T2Th&R7S")4[_YG0~EtqDZkHI&*tw+T.8r!mk4j"CEn9+S!Qn]\'Ohu%y0`9)lm7' + . '%a9sMN^Oq$?,0r.ablh2U_8PoxixeX1k;K_hy>9lBXxRL\'5/' + . 's~BJ^Z{OSfI:?[&[\'eD!$^mG8gzen1uc08/or+@Fria2FgnM' + . 'N3NRr=z+%uqt\'gY8 h(rtI:g4{zZdi(3}Wfpta|zXoo`WIxX' + . '3"L)Kgp_cl:IVB\\UyCGo&Ej^5[?m&8F::rCfZ4F?"`hX$F/~' + . 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjB' + . 'mu7 GM3ZK!qp|)!P1" sRanqC(:Ky&mh{&hDS|~ }qqzzrL,u' + . 'L!H/o:RwU}r[l\\XrE|FB{FAm9=i-iv#7wKFgfx`RM8' + . '83KI~dMkt}L9 ]uN[,@:6/[",:jKl8c%L/OKs}7i{c#{BxK}%' + . 'k9(0*S}C7#oGS;TW2x8z]!sK=k]rf', + '83747986cf0df320b915587609232076', + ], + ]; } /** From 6c801dee4d006def5718b8f0766b413db6c88c31 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 15:34:11 +0000 Subject: [PATCH 060/100] maskfunc --- src/Type/Square/PdfFourOneSeven/Data.php | 2 + src/Type/Square/QrCode/MaskNum.php | 116 +++-------------------- 2 files changed, 13 insertions(+), 105 deletions(-) diff --git a/src/Type/Square/PdfFourOneSeven/Data.php b/src/Type/Square/PdfFourOneSeven/Data.php index 4b760bae..7ad5516b 100644 --- a/src/Type/Square/PdfFourOneSeven/Data.php +++ b/src/Type/Square/PdfFourOneSeven/Data.php @@ -28,6 +28,8 @@ * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode + * + * @SuppressWarnings(PHPMD.ExcessiveClassLength) */ abstract class Data { diff --git a/src/Type/Square/QrCode/MaskNum.php b/src/Type/Square/QrCode/MaskNum.php index 367c67a1..7300d709 100644 --- a/src/Type/Square/QrCode/MaskNum.php +++ b/src/Type/Square/QrCode/MaskNum.php @@ -81,7 +81,17 @@ protected function generateMaskNo( if ((ord($frame[$ypos][$xpos]) & 0x80) !== 0) { $bitMask[$ypos][$xpos] = 0; } else { - $maskFunc = call_user_func([$this, 'mask' . $maskNo], $xpos, $ypos); + $maskFunc = match ($maskNo) { + 0 => (($xpos + $ypos) & 1), + 1 => ($ypos & 1), + 2 => ($xpos % 3), + 3 => (($xpos + $ypos) % 3), + 4 => ((((int) ($ypos / 2)) + ((int) ($xpos / 3))) & 1), + 5 => ((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3), + 6 => (((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3) & 1), + 7 => (((($xpos * $ypos) % 3) + (($xpos + $ypos) & 1)) & 1), + default => 0, + }; $bitMask[$ypos][$xpos] = (($maskFunc == 0) ? 1 : 0); } } @@ -89,108 +99,4 @@ protected function generateMaskNo( return $bitMask; } - - /** - * Mask 0 - * - * @param int $xpos X position - * @param int $ypos Y position - * - * @return int mask - */ - protected function mask0(int $xpos, int $ypos): int - { - return (($xpos + $ypos) & 1); - } - - /** - * Mask 1 - * - * @param int $xpos X position - * @param int $ypos Y position - * - * @return int mask - */ - protected function mask1(int $xpos, int $ypos): int - { - return ($ypos & 1); - } - - /** - * Mask 2 - * - * @param int $xpos X position - * @param int $ypos Y position - * - * @return int mask - */ - protected function mask2(int $xpos, int $ypos): int - { - return ($xpos % 3); - } - - /** - * Mask 3 - * - * @param int $xpos X position - * @param int $ypos Y position - * - * @return int mask - */ - protected function mask3(int $xpos, int $ypos): int - { - return (($xpos + $ypos) % 3); - } - - /** - * Mask 4 - * - * @param int $xpos X position - * @param int $ypos Y position - * - * @return int mask - */ - protected function mask4(int $xpos, int $ypos): int - { - return ((((int) ($ypos / 2)) + ((int) ($xpos / 3))) & 1); - } - - /** - * Mask 5 - * - * @param int $xpos X position - * @param int $ypos Y position - * - * @return int mask - */ - protected function mask5(int $xpos, int $ypos): int - { - return ((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3); - } - - /** - * Mask 6 - * - * @param int $xpos X position - * @param int $ypos Y position - * - * @return int mask - */ - protected function mask6(int $xpos, int $ypos): int - { - return (((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3) & 1); - } - - /** - * Mask 7 - * - * @param int $xpos X position - * @param int $ypos Y position - * - * @return int mask - */ - protected function mask7(int $xpos, int $ypos): int - { - return (((($xpos * $ypos) % 3) + (($xpos + $ypos) & 1)) & 1); - } } From dde7fa9f514ba90eabb964e30b040a68b96ffd0f Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 15:36:12 +0000 Subject: [PATCH 061/100] maskno --- src/Type/Square/PdfFourOneSeven/Data.php | 2 +- src/Type/Square/QrCode/MaskNum.php | 26 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Type/Square/PdfFourOneSeven/Data.php b/src/Type/Square/PdfFourOneSeven/Data.php index 7ad5516b..a33f8ddf 100644 --- a/src/Type/Square/PdfFourOneSeven/Data.php +++ b/src/Type/Square/PdfFourOneSeven/Data.php @@ -28,7 +28,7 @@ * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode - * + * * @SuppressWarnings(PHPMD.ExcessiveClassLength) */ abstract class Data diff --git a/src/Type/Square/QrCode/MaskNum.php b/src/Type/Square/QrCode/MaskNum.php index 7300d709..52aff1a3 100644 --- a/src/Type/Square/QrCode/MaskNum.php +++ b/src/Type/Square/QrCode/MaskNum.php @@ -80,20 +80,20 @@ protected function generateMaskNo( for ($xpos = 0; $xpos < $width; ++$xpos) { if ((ord($frame[$ypos][$xpos]) & 0x80) !== 0) { $bitMask[$ypos][$xpos] = 0; - } else { - $maskFunc = match ($maskNo) { - 0 => (($xpos + $ypos) & 1), - 1 => ($ypos & 1), - 2 => ($xpos % 3), - 3 => (($xpos + $ypos) % 3), - 4 => ((((int) ($ypos / 2)) + ((int) ($xpos / 3))) & 1), - 5 => ((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3), - 6 => (((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3) & 1), - 7 => (((($xpos * $ypos) % 3) + (($xpos + $ypos) & 1)) & 1), - default => 0, - }; - $bitMask[$ypos][$xpos] = (($maskFunc == 0) ? 1 : 0); + continue; } + $maskFunc = match ($maskNo) { + 0 => (($xpos + $ypos) & 1), + 1 => ($ypos & 1), + 2 => ($xpos % 3), + 3 => (($xpos + $ypos) % 3), + 4 => ((((int) ($ypos / 2)) + ((int) ($xpos / 3))) & 1), + 5 => ((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3), + 6 => (((($xpos * $ypos) & 1) + ($xpos * $ypos) % 3) & 1), + 7 => (((($xpos * $ypos) % 3) + (($xpos + $ypos) & 1)) & 1), + default => 1, + }; + $bitMask[$ypos][$xpos] = (($maskFunc == 0) ? 1 : 0); } } From b08937434a7ab08bf78f1f011d8c238a36fe801e Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 15:41:30 +0000 Subject: [PATCH 062/100] isCharMode --- src/Type/Square/Datamatrix/Modes.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Type/Square/Datamatrix/Modes.php b/src/Type/Square/Datamatrix/Modes.php index 523e133e..aac820e9 100644 --- a/src/Type/Square/Datamatrix/Modes.php +++ b/src/Type/Square/Datamatrix/Modes.php @@ -85,18 +85,19 @@ protected function get255StateCodeword(int $cdwpad, int $cdwpos): int */ protected function isCharMode(int $chr, int $mode): bool { - $map = [ + $ret = match ($mode) { //Data::ENC_ASCII => 'isASCIIMode', - Data::ENC_C40 => 'isC40Mode', - Data::ENC_TXT => 'isTXTMode', - Data::ENC_X12 => 'isX12Mode', - Data::ENC_EDF => 'isEDFMode', - Data::ENC_BASE256 => 'isBASE256Mode', - Data::ENC_ASCII_EXT => 'isASCIIEXTMode', - Data::ENC_ASCII_NUM => 'isASCIINUMMode', - ]; - $method = $map[$mode]; - return $this->$method($chr); + Data::ENC_C40 => $this->isC40Mode($chr), + Data::ENC_TXT => $this->isTXTMode($chr), + Data::ENC_X12 => $this->isX12Mode($chr), + Data::ENC_EDF => $this->isEDFMode($chr), + Data::ENC_BASE256 => $this->isBASE256Mode($chr), + Data::ENC_ASCII_EXT => $this->isASCIIEXTMode($chr), + Data::ENC_ASCII_NUM => $this->isASCIINUMMode($chr), + default => false, + }; + + return $ret; } ///** From c4eca1fe19744de0872916945656f080b57a404a Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 20 Nov 2023 15:52:26 +0000 Subject: [PATCH 063/100] typemtd --- phpstan.neon | 2 +- src/Type.php | 61 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index bf592cee..271361aa 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: max + level: 4 paths: - src - test diff --git a/src/Type.php b/src/Type.php index 829b0b6c..319cf695 100644 --- a/src/Type.php +++ b/src/Type.php @@ -33,6 +33,8 @@ * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode + * + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ abstract class Type extends \Com\Tecnick\Barcode\Type\Convert { @@ -305,7 +307,7 @@ public function getSvgCode(): string . ' stroke-width="0"' . ' stroke-linecap="square"' . '>' . "\n"; - $bars = $this->getBarsArray('XYWH'); + $bars = $this->getBarsArrayXYWH(); foreach ($bars as $bar) { $svg .= ' getBarsArray('XYWH'); + $bars = $this->getBarsArrayXYWH(); foreach ($bars as $bar) { $html .= '
    getTestObject(); $type = $barcode->getBarcodeObj('PDF417', $code); diff --git a/test/Square/QrCodeTest.php b/test/Square/QrCodeTest.php index fb48f3a4..932f095c 100644 --- a/test/Square/QrCodeTest.php +++ b/test/Square/QrCodeTest.php @@ -62,6 +62,9 @@ public function testGetGrid(string $options, string $code, mixed $expected): voi $this->assertEquals($expected, md5($grid)); } + /** + * @return array + */ public static function getGridDataProvider(): array { return [ @@ -300,47 +303,47 @@ public static function getGridDataProvider(): array [ '', 'w(fa`nC]e=}OY(K^ 3xN1Vz1gkKnFS;&TN ' - . '$`W~r?;9\\l?]5MF@<~oh>\\4-#hH*=w*AYaAL!]f^J&<`Tc!' - . 'pcpZ"Nn0RWY\\uQf8+HZXJ8?*bFGDz+Eln7Gqe6"8n[te.\\}' - . ':&YrQq3[UY#yU.@B}Xio>!rWoNMV]*Uw0/kb!~>WYAR0PrROK' - . '=?j>3B/boe@z;8,K$nM$-%]OWm KAOv^oa}#%-ets&p/?|[Dk' - . ')Hy.\'IfuI27y*viktmq#Tfv[X\'zUb?Bkh=zofbe1t|+~tuk' - . 'id]l9Edt}kpTO0wSr^PK|T2SZ:[Jb0UX!I8}Grc^>L)jzG>n\'n:%DMX g5KK' - . 'F!$GJ=Er0*QOVZ:R#YA+H\\0m*inr :>G;Cof`5Yq@,Avg\\J' - . 'j6lv_J(MUqv' - . '>?03:!+8ig9`\\-PZW\'D%Qz^wEC,z3JrQj#d&$p>nYXP6f!p' - . '?)5EZ1$RWH_S[+F-vIr|Nc<==tmT\\oF{x\\ASnF\'FnfyKr@' - . 'YijLg91$VOyD%V4KS-(tav;h>+P8VCY0.D]u^nz6?tZDLoo }' - . 'xt_p1I0=zIs?#%MHbD(R?>q4y7ai(ah"WIrir$\'nM{.P![yd' - . ' "7@@*T:A7%IxmKP7?:+CAyp>)B?e<$e><\'_F\\yhs~2ll^>' - . '%~X1Bz+494VYys^`2zhrBEl+9l>&Y}D_|}p@y|T32,m- Ln3H' - . 'W&j|sv6`6=;5bz2alS[i(o{5]*6*xIRPP>NE6d&L#Abe=tG+H' - . '$tQsqgQ{}\\tH0FyNt?eZE2]gtD&jl14p\'fdxO7uMskv$2pS' - . '(19bWLA@BeF-RXBD_*)YY@O\'5;~9NolV!\':YS[yuA@$tyF9' - . 'YPC3*cc2y~13N"!%$(@][{WR>xV4r|MMNp`YUDkPD|cr~ex#m' - . '9`J69}T2Th&R7S")4[_YG0~EtqDZkHI&*tw+T.8r!mk4j"CEn9+S!Qn]\'Ohu%y0`9)lm7' - . '%a9sMN^Oq$?,0r.ablh2U_8PoxixeX1k;K_hy>9lBXxRL\'5/' - . 's~BJ^Z{OSfI:?[&[\'eD!$^mG8gzen1uc08/or+@Fria2FgnM' - . 'N3NRr=z+%uqt\'gY8 h(rtI:g4{zZdi(3}Wfpta|zXoo`WIxX' - . '3"L)Kgp_cl:IVB\\UyCGo&Ej^5[?m&8F::rCfZ4F?"`hX$F/~' - . 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjB' - . 'mu7 GM3ZK!qp|)!P1" sRanqC(:Ky&mh{&hDS|~ }qqzzrL,u' - . 'L!H/o:RwU}r[l\\XrE|FB{FAm9=i-iv#7wKFgfx`RM8' - . '83KI~dMkt}L9 ]uN[,@:6/[",:jKl8c%L/OKs}7i{c#{BxK}%' - . 'k9(0*S}C7#oGS;TW2x8z]!sK=k]rf', + . '$`W~r?;9\\l?]5MF@<~oh>\\4-#hH*=w*AYaAL!]f^J&<`Tc!' + . 'pcpZ"Nn0RWY\\uQf8+HZXJ8?*bFGDz+Eln7Gqe6"8n[te.\\}' + . ':&YrQq3[UY#yU.@B}Xio>!rWoNMV]*Uw0/kb!~>WYAR0PrROK' + . '=?j>3B/boe@z;8,K$nM$-%]OWm KAOv^oa}#%-ets&p/?|[Dk' + . ')Hy.\'IfuI27y*viktmq#Tfv[X\'zUb?Bkh=zofbe1t|+~tuk' + . 'id]l9Edt}kpTO0wSr^PK|T2SZ:[Jb0UX!I8}Grc^>L)jzG>n\'n:%DMX g5KK' + . 'F!$GJ=Er0*QOVZ:R#YA+H\\0m*inr :>G;Cof`5Yq@,Avg\\J' + . 'j6lv_J(MUqv' + . '>?03:!+8ig9`\\-PZW\'D%Qz^wEC,z3JrQj#d&$p>nYXP6f!p' + . '?)5EZ1$RWH_S[+F-vIr|Nc<==tmT\\oF{x\\ASnF\'FnfyKr@' + . 'YijLg91$VOyD%V4KS-(tav;h>+P8VCY0.D]u^nz6?tZDLoo }' + . 'xt_p1I0=zIs?#%MHbD(R?>q4y7ai(ah"WIrir$\'nM{.P![yd' + . ' "7@@*T:A7%IxmKP7?:+CAyp>)B?e<$e><\'_F\\yhs~2ll^>' + . '%~X1Bz+494VYys^`2zhrBEl+9l>&Y}D_|}p@y|T32,m- Ln3H' + . 'W&j|sv6`6=;5bz2alS[i(o{5]*6*xIRPP>NE6d&L#Abe=tG+H' + . '$tQsqgQ{}\\tH0FyNt?eZE2]gtD&jl14p\'fdxO7uMskv$2pS' + . '(19bWLA@BeF-RXBD_*)YY@O\'5;~9NolV!\':YS[yuA@$tyF9' + . 'YPC3*cc2y~13N"!%$(@][{WR>xV4r|MMNp`YUDkPD|cr~ex#m' + . '9`J69}T2Th&R7S")4[_YG0~EtqDZkHI&*tw+T.8r!mk4j"CEn9+S!Qn]\'Ohu%y0`9)lm7' + . '%a9sMN^Oq$?,0r.ablh2U_8PoxixeX1k;K_hy>9lBXxRL\'5/' + . 's~BJ^Z{OSfI:?[&[\'eD!$^mG8gzen1uc08/or+@Fria2FgnM' + . 'N3NRr=z+%uqt\'gY8 h(rtI:g4{zZdi(3}Wfpta|zXoo`WIxX' + . '3"L)Kgp_cl:IVB\\UyCGo&Ej^5[?m&8F::rCfZ4F?"`hX$F/~' + . 'iVoo{[O17n~>(FXC9{*t1P532}l7E{7/R\' ObO`y?`9G(qjB' + . 'mu7 GM3ZK!qp|)!P1" sRanqC(:Ky&mh{&hDS|~ }qqzzrL,u' + . 'L!H/o:RwU}r[l\\XrE|FB{FAm9=i-iv#7wKFgfx`RM8' + . '83KI~dMkt}L9 ]uN[,@:6/[",:jKl8c%L/OKs}7i{c#{BxK}%' + . 'k9(0*S}C7#oGS;TW2x8z]!sK=k]rf', '83747986cf0df320b915587609232076', ], ]; @@ -349,7 +352,7 @@ public static function getGridDataProvider(): array /** * @dataProvider getStringDataProvider */ - public function testStrings(string|array $code): void + public function testStrings(string $code): void { $barcode = $this->getTestObject(); $type = $barcode->getBarcodeObj('QRCODE,H,NL,0,1,3,1', $code); From a0a1e05affdae6a0b4bf044ea99b71251d0cb1ad Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 08:46:01 +0000 Subject: [PATCH 073/100] TEST CLEAN --- test/BarcodeTest.php | 2 ++ test/Square/AztecTest.php | 6 ++++++ test/Square/DatamatrixTest.php | 6 ++++++ test/Square/PdfFourOneSevenTest.php | 6 ++++++ test/Square/QrCodeTest.php | 3 +++ test/TestStrings.php | 2 +- 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/test/BarcodeTest.php b/test/BarcodeTest.php index 08ba77c2..d205cd07 100644 --- a/test/BarcodeTest.php +++ b/test/BarcodeTest.php @@ -302,6 +302,7 @@ public function testGetSvg(): void ob_start(); $type->getSvg(); $svg = ob_get_clean(); + $this->assertNotFalse($svg); $this->assertEquals('86e0362768e8b1b26032381232c0367f', md5($svg)); } @@ -318,6 +319,7 @@ public function testGetPng(): void ob_start(); $type->getPng(); $png = ob_get_clean(); + $this->assertNotFalse($png); $this->assertEquals('PNG', substr($png, 1, 3)); } } diff --git a/test/Square/AztecTest.php b/test/Square/AztecTest.php index 34e97855..880f350d 100644 --- a/test/Square/AztecTest.php +++ b/test/Square/AztecTest.php @@ -62,6 +62,9 @@ public function testGetGrid(string $options, string $code, mixed $expected): voi $this->assertEquals($expected, md5($grid)); } + /** + * @return array + */ public static function getGridDataProvider(): array { return [ @@ -227,6 +230,9 @@ public function testStrings(string $code): void $this->assertNotNull($type); } + /** + * @return array + */ public static function getStringDataProvider() { return \Test\TestStrings::$data; diff --git a/test/Square/DatamatrixTest.php b/test/Square/DatamatrixTest.php index 8eb57b13..6caa6bea 100644 --- a/test/Square/DatamatrixTest.php +++ b/test/Square/DatamatrixTest.php @@ -86,6 +86,9 @@ public function testGetGrid(string $mode, string $code, mixed $expected): void $this->assertEquals($expected, md5($grid)); } + /** + * @return array + */ public static function getGridDataProvider(): array { return [ @@ -402,6 +405,9 @@ public function testStrings(string $code): void $this->assertNotNull($type); } + /** + * @return array + */ public static function getStringDataProvider() { return \Test\TestStrings::$data; diff --git a/test/Square/PdfFourOneSevenTest.php b/test/Square/PdfFourOneSevenTest.php index dee3de7b..653a3ed9 100644 --- a/test/Square/PdfFourOneSevenTest.php +++ b/test/Square/PdfFourOneSevenTest.php @@ -62,6 +62,9 @@ public function testGetGrid(string $options, string $code, mixed $expected): voi $this->assertEquals($expected, md5($grid)); } + /** + * @return array + */ public static function getGridDataProvider(): array { return [ @@ -258,6 +261,9 @@ public function testStrings(string $code): void $this->assertNotNull($type); } + /** + * @return array + */ public static function getStringDataProvider() { return \Test\TestStrings::$data; diff --git a/test/Square/QrCodeTest.php b/test/Square/QrCodeTest.php index 932f095c..05f24bde 100644 --- a/test/Square/QrCodeTest.php +++ b/test/Square/QrCodeTest.php @@ -359,6 +359,9 @@ public function testStrings(string $code): void $this->assertNotNull($type); } + /** + * @return array + */ public static function getStringDataProvider() { return \Test\TestStrings::$data; diff --git a/test/TestStrings.php b/test/TestStrings.php index c6d9cf4e..3e9d59ad 100644 --- a/test/TestStrings.php +++ b/test/TestStrings.php @@ -33,7 +33,7 @@ class TestStrings /** * Array containing testing strings. * - * @var array + * @var array */ public static $data = [ // Reserved keywords From cc85913b14256a3f5c6c17535b0bfd8305aa7cf3 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 08:52:13 +0000 Subject: [PATCH 074/100] qrcode random mask type --- src/Type/Square/QrCode.php | 9 +++++---- src/Type/Square/QrCode/Mask.php | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 61822bf1..2d136fd0 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -68,14 +68,15 @@ class QrCode extends \Com\Tecnick\Barcode\Type\Square protected bool $case_sensitive = true; /** - * If false, checks all masks available, - * otherwise the value indicates the number of masks to be checked, mask id are random + * If negative, checks all masks available, + * otherwise the value indicates the number of masks to be checked, + * mask ids are random. */ - protected int|bool $random_mask = false; + protected int $random_mask = -1; /** * If true, estimates best mask (spec. default, but extremally slow; - * set to false to significant performance boost but (propably) worst quality code + * set to false to significant performance boost but (propably) worst quality code. */ protected bool $best_mask = true; diff --git a/src/Type/Square/QrCode/Mask.php b/src/Type/Square/QrCode/Mask.php index 8c1df935..c0bbade3 100644 --- a/src/Type/Square/QrCode/Mask.php +++ b/src/Type/Square/QrCode/Mask.php @@ -44,8 +44,9 @@ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum * * @param int $version Code version * @param int $level Error Correction Level - * @param bool $qr_find_from_random If false, checks all masks available, - * otherwise the value indicates the number of masks to be checked, mask id are random + * @param int $qr_find_from_random If negative, checks all masks available, + * otherwise the value indicates the number of masks to be checked, + * mask ids are random * @param bool $qr_find_best_mask If true, estimates best mask (slow) * @param int $qr_default_mask Default mask used when $fbm is false */ @@ -61,7 +62,7 @@ public function __construct( * Error correction level */ protected int $level, - protected bool $qr_find_from_random = false, + protected int $qr_find_from_random = -1, protected bool $qr_find_best_mask = true, protected int $qr_default_mask = 2 ) { @@ -85,7 +86,7 @@ protected function mask( $minDemerit = PHP_INT_MAX; $bestMask = []; $checked_masks = [0, 1, 2, 3, 4, 5, 6, 7]; - if ($this->qr_find_from_random) { + if ($this->qr_find_from_random >= 0) { $howManuOut = (8 - ($this->qr_find_from_random % 9)); for ($idx = 0; $idx < $howManuOut; ++$idx) { $remPos = random_int(0, (count($checked_masks) - 1)); From 12ace2305fd14ebfd1c8294dfb5690079794171f Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 08:56:46 +0000 Subject: [PATCH 075/100] qrcode mask --- src/Type/Square/QrCode.php | 2 +- src/Type/Square/QrCode/Mask.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 2d136fd0..b4b5e920 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -69,7 +69,7 @@ class QrCode extends \Com\Tecnick\Barcode\Type\Square /** * If negative, checks all masks available, - * otherwise the value indicates the number of masks to be checked, + * otherwise the value indicates the number of masks to be checked, * mask ids are random. */ protected int $random_mask = -1; diff --git a/src/Type/Square/QrCode/Mask.php b/src/Type/Square/QrCode/Mask.php index c0bbade3..4ea25c07 100644 --- a/src/Type/Square/QrCode/Mask.php +++ b/src/Type/Square/QrCode/Mask.php @@ -45,7 +45,7 @@ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum * @param int $version Code version * @param int $level Error Correction Level * @param int $qr_find_from_random If negative, checks all masks available, - * otherwise the value indicates the number of masks to be checked, + * otherwise the value indicates the number of masks to be checked, * mask ids are random * @param bool $qr_find_best_mask If true, estimates best mask (slow) * @param int $qr_default_mask Default mask used when $fbm is false @@ -89,7 +89,8 @@ protected function mask( if ($this->qr_find_from_random >= 0) { $howManuOut = (8 - ($this->qr_find_from_random % 9)); for ($idx = 0; $idx < $howManuOut; ++$idx) { - $remPos = random_int(0, (count($checked_masks) - 1)); + $maxpos = (count($checked_masks) - 1); + $remPos = ($maxpos > 0) ? random_int(0, $maxpos) : 0; unset($checked_masks[$remPos]); $checked_masks = array_values($checked_masks); } From 9f396eb5e82e769132b6b6b5c439be32388f67cc Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 09:05:31 +0000 Subject: [PATCH 076/100] fixes --- src/Type/Linear/CodeOneOne.php | 4 ++-- src/Type/Linear/Imb.php | 2 +- src/Type/Linear/Postnet.php | 3 +++ src/Type/Square/Datamatrix/Data.php | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Type/Linear/CodeOneOne.php b/src/Type/Linear/CodeOneOne.php index bf0c34b9..596e937e 100644 --- a/src/Type/Linear/CodeOneOne.php +++ b/src/Type/Linear/CodeOneOne.php @@ -91,7 +91,7 @@ protected function getChecksum(string $code): string } if ($len <= 10) { - return $ccheck; + return ((string) $ccheck); } // calculate check digit K @@ -110,7 +110,7 @@ protected function getChecksum(string $code): string } $kcheck %= 11; - return $ccheck . $kcheck; + return ((string) $ccheck . $kcheck); } /** diff --git a/src/Type/Linear/Imb.php b/src/Type/Linear/Imb.php index fa8ff1c1..a6f80383 100644 --- a/src/Type/Linear/Imb.php +++ b/src/Type/Linear/Imb.php @@ -481,7 +481,7 @@ protected function getCharsArray(): array $this->bars = []; $code_arr = explode('-', $this->code); $tracking_number = $code_arr[0]; - $binary_code = 0; + $binary_code = '0'; if (isset($code_arr[1])) { $binary_code = $this->getRoutingCode($code_arr[1]); } diff --git a/src/Type/Linear/Postnet.php b/src/Type/Linear/Postnet.php index 496f263d..5483173f 100644 --- a/src/Type/Linear/Postnet.php +++ b/src/Type/Linear/Postnet.php @@ -88,6 +88,9 @@ protected function getChecksum(string $code): int protected function formatCode(): void { $code = preg_replace('/[-\s]+/', '', $this->code); + if ($code === null) { + throw new BarcodeException('Code not valid'); + } $this->extcode = $code . $this->getChecksum($code); } diff --git a/src/Type/Square/Datamatrix/Data.php b/src/Type/Square/Datamatrix/Data.php index 7c95f6f9..24a99366 100644 --- a/src/Type/Square/Datamatrix/Data.php +++ b/src/Type/Square/Datamatrix/Data.php @@ -957,6 +957,9 @@ class Data /** * Get the required codewords padding size * + * @param string $shape Shape. + * @param int $ncw Number of codewords. + * * @return array params * * @throws BarcodeException in case of error From cb21d033bb7ddc26dde4bddfe8051ca160cdf583 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 09:11:57 +0000 Subject: [PATCH 077/100] getRawCodeRows --- src/Type/Convert.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Type/Convert.php b/src/Type/Convert.php index b62cc08e..e0eb6910 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -171,13 +171,20 @@ protected function processBinarySequence(array $rows): void */ protected function getRawCodeRows(string $data): array { - // remove spaces and newlines - $code = preg_replace('/[\s]*/s', '', $data); - // remove trailing brackets or commas - $code = preg_replace('/^[\[,]+/', '', $code); - $code = preg_replace('/[\],]+$/', '', $code); - // convert bracket -separated to comma-separated - $code = preg_replace('/[\]][\[]$/', ',', $code); + $search = [ + '/[\s]*/s', // remove spaces and newlines + '/^[\[,]+/', // remove trailing brackets or commas + '/[\],]+$/', // remove trailing brackets or commas + '/[\]][\[]$/', // convert bracket -separated to comma-separated + ]; + + $replace = ['', '', '', '']; + + $code = preg_replace($search, $replace, $data); + if ($code === null) { + throw new BarcodeException('Invalid input string'); + } + return explode(',', $code); } From 2d55541cc971fab1b58846dc112851f52950380e Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 09:14:59 +0000 Subject: [PATCH 078/100] setPadding --- src/Type.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Type.php b/src/Type.php index 52e3dade..7107f9d7 100644 --- a/src/Type.php +++ b/src/Type.php @@ -151,12 +151,11 @@ protected function setPadding(array $padding): static ['L', $this->width_ratio], ]; foreach ($padding as $key => $val) { - $val = (int) $val; if ($val < 0) { $val = (abs(min(-1, $val)) * $map[$key][1]); } - $this->padding[$map[$key][0]] = $val; + $this->padding[$map[$key][0]] = (int) $val; } return $this; From c9c5f99e1a5ec1dccf9e5ef3937f12d881a77470 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 09:22:47 +0000 Subject: [PATCH 079/100] color object --- src/Type.php | 5 +++-- src/Type/Convert.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Type.php b/src/Type.php index 7107f9d7..04c9febd 100644 --- a/src/Type.php +++ b/src/Type.php @@ -172,11 +172,12 @@ protected function setPadding(array $padding): static */ public function setColor(string $color): static { - $this->color_obj = $this->getRgbColorObject($color); - if (! $this->color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { + $colobj = $this->getRgbColorObject($color); + if (! $colobj instanceof \Com\Tecnick\Color\Model\Rgb) { throw new BarcodeException('The foreground color cannot be empty or transparent'); } + $this->color_obj = $colobj; return $this; } diff --git a/src/Type/Convert.php b/src/Type/Convert.php index e0eb6910..3bcfee54 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -115,7 +115,7 @@ abstract class Convert /** * Foreground Color object */ - protected ?Color $color_obj = null; + protected Color $color_obj; /** * Backgorund Color object From d099a777832fe3e3ce29465a9b2da2da4052b60f Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 09:24:51 +0000 Subject: [PATCH 080/100] fixes --- src/Type.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Type.php b/src/Type.php index 04c9febd..c39d9c8c 100644 --- a/src/Type.php +++ b/src/Type.php @@ -392,7 +392,11 @@ public function getPngData(bool $imagick = true): string $gdImage = $this->getGd(); ob_start(); imagepng($gdImage); - return ob_get_clean(); + $data = ob_get_clean(); + if ($data === false) { + throw new BarcodeException('Unable to get PNG data'); + } + return $data; } /** From 7915ff79d3f3e9ce864adab29b31c7604eb0ce70 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 09:30:39 +0000 Subject: [PATCH 081/100] fixes --- src/Type.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Type.php b/src/Type.php index c39d9c8c..4e13cd80 100644 --- a/src/Type.php +++ b/src/Type.php @@ -440,6 +440,10 @@ public function getGd(): \GdImage $width = (int) ceil($this->width + $this->padding['L'] + $this->padding['R']); $height = (int) ceil($this->height + $this->padding['T'] + $this->padding['B']); $img = imagecreate($width, $height); + if ($img === false) { + throw new BarcodeException('Unable to create GD image'); + } + if (! $this->bg_color_obj instanceof \Com\Tecnick\Color\Model\Rgb) { $bgobj = clone $this->color_obj; $rgbcolor = $bgobj->invertColor()->getNormalizedArray(255); @@ -449,6 +453,9 @@ public function getGd(): \GdImage (int) round($rgbcolor['G']), (int) round($rgbcolor['B']), ); + if ($background_color === false) { + throw new BarcodeException('Unable to allocate default GD background color'); + } imagecolortransparent($img, $background_color); } else { $rgbcolor = $this->bg_color_obj->getNormalizedArray(255); @@ -458,6 +465,9 @@ public function getGd(): \GdImage (int) round($rgbcolor['G']), (int) round($rgbcolor['B']), ); + if ($bg_color === false) { + throw new BarcodeException('Unable to allocate GD background color'); + } imagefilledrectangle($img, 0, 0, $width, $height, $bg_color); } @@ -468,6 +478,9 @@ public function getGd(): \GdImage (int) round($rgbcolor['G']), (int) round($rgbcolor['B']), ); + if ($bar_color === false) { + throw new BarcodeException('Unable to allocate GD foreground color'); + } $bars = $this->getBarsArrayXYXY(); foreach ($bars as $bar) { imagefilledrectangle( From 06187b4a7a6196c559e6f3a615a8b59dab38f021 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 09:55:21 +0000 Subject: [PATCH 082/100] fixes --- src/Barcode.php | 56 ++++++++++++++++++++++++------------------------- src/Type.php | 4 +++- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/Barcode.php b/src/Barcode.php index b57fb988..b4701217 100644 --- a/src/Barcode.php +++ b/src/Barcode.php @@ -111,43 +111,43 @@ public function getBarcodeObj( $type = array_shift($params); $bclass = match ($type) { - 'C128' => 'Linear\\CodeOneTwoEight', // CODE 128 - 'C128A' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightA', // CODE 128 A + 'C128' => 'Linear\\CodeOneTwoEight', // CODE 128 + 'C128A' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightA', // CODE 128 A 'C128B' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightB', // CODE 128 B 'C128C' => 'Linear\\CodeOneTwoEight\\CodeOneTwoEightC', // CODE 128 C 'C39' => 'Linear\\CodeThreeNine', // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. - 'C39+' => 'Linear\\CodeThreeNineCheck', // CODE 39 + CHECKSUM - 'C39E' => 'Linear\\CodeThreeNineExt', // CODE 39 EXTENDED - 'C39E+' => 'Linear\\CodeThreeNineExtCheck', // CODE 39 EXTENDED + CHECKSUM + 'C39+' => 'Linear\\CodeThreeNineCheck', // CODE 39 + CHECKSUM + 'C39E' => 'Linear\\CodeThreeNineExt', // CODE 39 EXTENDED + 'C39E+' => 'Linear\\CodeThreeNineExtCheck', // CODE 39 EXTENDED + CHECKSUM 'C93' => 'Linear\\CodeNineThree', // CODE 93 - USS-93 - 'CODABAR' => 'Linear\\Codabar', // CODABAR - 'CODE11' => 'Linear\\CodeOneOne', // CODE 11 - 'EAN13' => 'Linear\\EanOneThree', // EAN 13 - 'EAN2' => 'Linear\\EanTwo', // EAN 2-Digits UPC-Based Extension - 'EAN5' => 'Linear\\EanFive', // EAN 5-Digits UPC-Based Extension - 'EAN8' => 'Linear\\EanEight', // EAN 8 + 'CODABAR' => 'Linear\\Codabar', // CODABAR + 'CODE11' => 'Linear\\CodeOneOne', // CODE 11 + 'EAN13' => 'Linear\\EanOneThree', // EAN 13 + 'EAN2' => 'Linear\\EanTwo', // EAN 2-Digits UPC-Based Extension + 'EAN5' => 'Linear\\EanFive', // EAN 5-Digits UPC-Based Extension + 'EAN8' => 'Linear\\EanEight', // EAN 8 'I25' => 'Linear\\InterleavedTwoOfFive', // Interleaved 2 of 5 - 'I25+' => 'Linear\\InterleavedTwoOfFiveCheck', // Interleaved 2 of 5 + CHECKSUM + 'I25+' => 'Linear\\InterleavedTwoOfFiveCheck', // Interleaved 2 of 5 + CHECKSUM 'IMB' => 'Linear\\Imb', // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 - 'IMBPRE' => 'Linear\\ImbPre', // IMB - Intelligent Mail Barcode pre-processed + 'IMBPRE' => 'Linear\\ImbPre', // IMB - Intelligent Mail Barcode pre-processed 'KIX' => 'Linear\\KlantIndex', // KIX (Klant index - Customer index) - 'LRAW' => 'Linear\\Raw', // 1D RAW MODE (comma-separated rows of 01 strings) + 'LRAW' => 'Linear\\Raw', // 1D RAW MODE (comma-separated rows of 01 strings) 'MSI' => 'Linear\\Msi', // MSI (Variation of Plessey code) - 'MSI+' => 'Linear\\MsiCheck', // MSI + CHECKSUM (modulo 11) - 'PHARMA' => 'Linear\\Pharma', // PHARMACODE - 'PHARMA2T' => 'Linear\\PharmaTwoTracks', // PHARMACODE TWO-TRACKS - 'PLANET' => 'Linear\\Planet', // PLANET - 'POSTNET' => 'Linear\\Postnet', // POSTNET - 'RMS4CC' => 'Linear\\RoyalMailFourCc', // RMS4CC (Royal Mail 4-state Customer Bar Code) + 'MSI+' => 'Linear\\MsiCheck', // MSI + CHECKSUM (modulo 11) + 'PHARMA' => 'Linear\\Pharma', // PHARMACODE + 'PHARMA2T' => 'Linear\\PharmaTwoTracks', // PHARMACODE TWO-TRACKS + 'PLANET' => 'Linear\\Planet', // PLANET + 'POSTNET' => 'Linear\\Postnet', // POSTNET + 'RMS4CC' => 'Linear\\RoyalMailFourCc', // RMS4CC (Royal Mail 4-state Customer Bar Code) 'S25' => 'Linear\\StandardTwoOfFive', // Standard 2 of 5 - 'S25+' => 'Linear\\StandardTwoOfFiveCheck', // Standard 2 of 5 + CHECKSUM - 'UPCA' => 'Linear\\UpcA', // UPC-A - 'UPCE' => 'Linear\\UpcE', // UPC-E - 'AZTEC' => 'Square\\Aztec', // AZTEC Code (ISO/IEC 24778:2008) - 'DATAMATRIX' => 'Square\\Datamatrix', // DATAMATRIX (ISO/IEC 16022) - 'PDF417' => 'Square\\PdfFourOneSeven', // PDF417 (ISO/IEC 15438:2006) - 'QRCODE' => 'Square\\QrCode', // QR-CODE - 'SRAW' => 'Square\\Raw', // 2D RAW MODE (comma-separated rows of 01 strings) + 'S25+' => 'Linear\\StandardTwoOfFiveCheck', // Standard 2 of 5 + CHECKSUM + 'UPCA' => 'Linear\\UpcA', // UPC-A + 'UPCE' => 'Linear\\UpcE', // UPC-E + 'AZTEC' => 'Square\\Aztec', // AZTEC Code (ISO/IEC 24778:2008) + 'DATAMATRIX' => 'Square\\Datamatrix', // DATAMATRIX (ISO/IEC 16022) + 'PDF417' => 'Square\\PdfFourOneSeven', // PDF417 (ISO/IEC 15438:2006) + 'QRCODE' => 'Square\\QrCode', // QR-CODE + 'SRAW' => 'Square\\Raw', // 2D RAW MODE (comma-separated rows of 01 strings) default => throw new BarcodeException('Unsupported barcode type: ' . $type) }; diff --git a/src/Type.php b/src/Type.php index 4e13cd80..ad6d6f50 100644 --- a/src/Type.php +++ b/src/Type.php @@ -88,7 +88,9 @@ protected function setParameters(): void * * @throws BarcodeException in case of error */ - abstract protected function setBars(): void; + protected function setBars(): void + { + } /** * Set the size of the barcode to be exported From a9a933de8479de916792fcb111e85e1d3397843c Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 10:41:01 +0000 Subject: [PATCH 083/100] types --- src/Barcode.php | 3 +- src/Model.php | 168 +++++++++++++++++++++++++++++++++++++++++++ src/Type.php | 26 ++++++- src/Type/Convert.php | 4 ++ test/BarcodeTest.php | 1 + 5 files changed, 198 insertions(+), 4 deletions(-) create mode 100644 src/Model.php diff --git a/src/Barcode.php b/src/Barcode.php index b4701217..4d936ab2 100644 --- a/src/Barcode.php +++ b/src/Barcode.php @@ -105,7 +105,7 @@ public function getBarcodeObj( int $height = -1, string $color = 'black', array $padding = [0, 0, 0, 0] - ): Type { + ): Model { // extract extra parameters (if any) $params = explode(',', $type); $type = array_shift($params); @@ -152,6 +152,7 @@ public function getBarcodeObj( }; $class = '\\Com\\Tecnick\\Barcode\\Type\\' . $bclass; + /* @phpstan-ignore-next-line */ return new $class($code, $width, $height, $color, $params, $padding); } } diff --git a/src/Model.php b/src/Model.php new file mode 100644 index 00000000..7ba3b44d --- /dev/null +++ b/src/Model.php @@ -0,0 +1,168 @@ + + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode + * + * This file is part of tc-lib-barcode software library. + */ + +namespace Com\Tecnick\Barcode; + +use Com\Tecnick\Barcode\Exception as BarcodeException; +use Com\Tecnick\Color\Exception as ColorException; +use Com\Tecnick\Color\Model\Rgb; + +/** + * Com\Tecnick\Barcode\Type + * + * Barcode Type class + * + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode + */ +interface Model +{ + /** + * Set the size of the barcode to be exported + * + * @param int $width Barcode width in user units (excluding padding). + * A negative value indicates the multiplication + * factor for each column. + * @param int $height Barcode height in user units (excluding padding). + * A negative value indicates the multiplication + * factor for each row. + * @param array{int, int, int, int} $padding Additional padding to add around the barcode + * (top, right, bottom, left) in user units. A + * negative value indicates the number or rows + * or columns. + */ + public function setSize(int $width, int $height, array $padding = [0, 0, 0, 0]): static; + + /** + * Set the color of the bars. + * If the color is transparent or empty it will be set to the default black color. + * + * @param string $color Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax) + * + * @throws ColorException in case of color error + * @throws BarcodeException in case of empty or transparent color + */ + public function setColor(string $color): static; + + /** + * Set the background color + * + * @param string $color Background color in Web notation (color name, or hexadecimal code, or CSS syntax) + * + * @throws ColorException in case of color error + */ + public function setBackgroundColor(string $color): static; + + /** + * Get the barcode raw array + * + * @return array{ + * 'type': string, + * 'format': string, + * 'params': array, + * 'code': string, + * 'extcode': string, + * 'ncols': int, + * 'nrows': int, + * 'width': int, + * 'height': int, + * 'width_ratio': float, + * 'height_ratio': float, + * 'padding': array{'T': int, 'R': int, 'B': int, 'L': int}, + * 'full_width': int, + * 'full_height': int, + * 'color_obj': Rgb, + * 'bg_color_obj': ?Rgb, + * 'bars': array>, + * } + */ + public function getArray(): array; + + /** + * Get the extended code (code + checksum) + */ + public function getExtendedCode(): string; + + /** + * Get the barcode as SVG image object + */ + public function getSvg(): void; + + /** + * Get the barcode as SVG code + * + * @return string SVG code + */ + public function getSvgCode(): string; + + /** + * Get an HTML representation of the barcode. + * + * @return string HTML code (DIV block) + */ + public function getHtmlDiv(): string; + + /** + * Get Barcode as PNG Image (requires GD or Imagick library) + */ + public function getPng(): void; + + /** + * Get the barcode as PNG image (requires GD or Imagick library) + * + * @param bool $imagick If true try to use the Imagick extension + * + * @return string PNG image data + */ + public function getPngData(bool $imagick = true): string; + + /** + * Get the barcode as PNG image (requires Imagick library) + * + * @throws BarcodeException if the Imagick library is not installed + */ + public function getPngDataImagick(): string; + + /** + * Get the barcode as GD image object (requires GD library) + * + * @throws BarcodeException if the GD library is not installed + */ + public function getGd(): \GdImage; + + /** + * Get a raw barcode string representation using characters + * + * @param string $space_char Character or string to use for filling empty spaces + * @param string $bar_char Character or string to use for filling bars + */ + public function getGrid(string $space_char = '0', string $bar_char = '1'): string; + + /** + * Get a raw barcode grid array + * + * @param string $space_char Character or string to use for filling empty spaces + * @param string $bar_char Character or string to use for filling bars + * + * @return array> + */ + public function getGridArray(string $space_char = '0', string $bar_char = '1'): array; +} diff --git a/src/Type.php b/src/Type.php index ad6d6f50..4ceb4fea 100644 --- a/src/Type.php +++ b/src/Type.php @@ -36,7 +36,7 @@ * * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ -abstract class Type extends \Com\Tecnick\Barcode\Type\Convert +abstract class Type extends \Com\Tecnick\Barcode\Type\Convert implements Model { /** * Initialize a new barcode object @@ -216,6 +216,26 @@ protected function getRgbColorObject(string $color): ?Rgb /** * Get the barcode raw array + * + * @return array{ + * 'type': string, + * 'format': string, + * 'params': array, + * 'code': string, + * 'extcode': string, + * 'ncols': int, + * 'nrows': int, + * 'width': int, + * 'height': int, + * 'width_ratio': float, + * 'height_ratio': float, + * 'padding': array{'T': int, 'R': int, 'B': int, 'L': int}, + * 'full_width': int, + * 'full_height': int, + * 'color_obj': Rgb, + * 'bg_color_obj': ?Rgb, + * 'bars': array>, + * } */ public function getArray(): array { @@ -520,7 +540,7 @@ public function getGrid( /** * Get the array containing all the formatted bars coordinates */ - public function getBarsArrayXYXY(): array + protected function getBarsArrayXYXY(): array { $rect = []; foreach ($this->bars as $bar) { @@ -557,7 +577,7 @@ public function getBarsArrayXYXY(): array /** * Get the array containing all the formatted bars coordinates */ - public function getBarsArrayXYWH(): array + protected function getBarsArrayXYWH(): array { $rect = []; foreach ($this->bars as $bar) { diff --git a/src/Type/Convert.php b/src/Type/Convert.php index 3bcfee54..d6b1dd36 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -50,6 +50,8 @@ abstract class Convert /** * Array containing extra parameters for the specified barcode type + * + * @var array */ protected array $params = []; @@ -236,6 +238,8 @@ protected function convertHexToDec(string $hex): string * * @param string $space_char Character or string to use for filling empty spaces * @param string $bar_char Character or string to use for filling bars + * + * @return array> */ public function getGridArray( string $space_char = '0', diff --git a/test/BarcodeTest.php b/test/BarcodeTest.php index d205cd07..8ad4e847 100644 --- a/test/BarcodeTest.php +++ b/test/BarcodeTest.php @@ -103,6 +103,7 @@ public function testBackgroundColor(): void [-2, 3, 0, 1] )->setBackgroundColor('mediumaquamarine'); $bobjarr = $type->getArray(); + $this->assertNotNull($bobjarr['bg_color_obj']); $this->assertEquals('#66cdaaff', $bobjarr['bg_color_obj']->getRgbaHexColor()); } From 0596e9b44ba9657c6a571ce867a29f859607b3ed Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 11:14:21 +0000 Subject: [PATCH 084/100] aztec --- src/Model.php | 2 +- src/Type.php | 8 ++++++-- src/Type/Convert.php | 16 +++++++++++----- src/Type/Square/Aztec.php | 27 +++++++++++++++++++++++---- src/Type/Square/PdfFourOneSeven.php | 9 ++++++++- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/Model.php b/src/Model.php index 7ba3b44d..42844d44 100644 --- a/src/Model.php +++ b/src/Model.php @@ -91,7 +91,7 @@ public function setBackgroundColor(string $color): static; * 'full_height': int, * 'color_obj': Rgb, * 'bg_color_obj': ?Rgb, - * 'bars': array>, + * 'bars': array, * } */ public function getArray(): array; diff --git a/src/Type.php b/src/Type.php index 4ceb4fea..5d32c629 100644 --- a/src/Type.php +++ b/src/Type.php @@ -50,7 +50,7 @@ abstract class Type extends \Com\Tecnick\Barcode\Type\Convert implements Model * factor for each row. * @param string $color Foreground color in Web notation * (color name, or hexadecimal code, or CSS syntax) - * @param array $params Array containing extra parameters for the specified barcode type + * @param array $params Array containing extra parameters for the specified barcode type * @param array{int, int, int, int} $padding Additional padding to add around the barcode * (top, right, bottom, left) in user units. A * negative value indicates the number or rows @@ -234,7 +234,7 @@ protected function getRgbColorObject(string $color): ?Rgb * 'full_height': int, * 'color_obj': Rgb, * 'bg_color_obj': ?Rgb, - * 'bars': array>, + * 'bars': array, * } */ public function getArray(): array @@ -539,6 +539,8 @@ public function getGrid( /** * Get the array containing all the formatted bars coordinates + * + * @return array */ protected function getBarsArrayXYXY(): array { @@ -576,6 +578,8 @@ protected function getBarsArrayXYXY(): array /** * Get the array containing all the formatted bars coordinates + * + * @return array */ protected function getBarsArrayXYWH(): array { diff --git a/src/Type/Convert.php b/src/Type/Convert.php index d6b1dd36..c85e619e 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -78,6 +78,8 @@ abstract class Convert /** * Array containing the position and dimensions of each barcode bar * (x, y, width, height) + * + * @var array, */ protected array $bars = []; @@ -127,7 +129,7 @@ abstract class Convert /** * Process binary sequence rows. * - * @param array $rows Binary sequence data to process + * @param array> $rows Binary sequence data to process * * @throws BarcodeException in case of error */ @@ -170,6 +172,8 @@ protected function processBinarySequence(array $rows): void /** * Extract rows from a binary sequence of comma-separated 01 strings. + * + * @return array */ protected function getRawCodeRows(string $data): array { @@ -267,6 +271,8 @@ public function getGridArray( /** * Returns the bars array ordered by columns + * + * @return array */ protected function getRotatedBarArray(): array { @@ -299,9 +305,9 @@ protected function getRotatedBarArray(): array /** * Get the adjusted rectangular coordinates (x1,y1,x2,y2) for the specified bar * - * @param array $bar Raw bar coordinates + * @param array{int, int, int, int} $bar Raw bar coordinates * - * @return array Bar coordinates + * @return array{float, float, float, float} Bar coordinates */ protected function getBarRectXYXY(array $bar): array { @@ -316,9 +322,9 @@ protected function getBarRectXYXY(array $bar): array /** * Get the adjusted rectangular coordinates (x,y,w,h) for the specified bar * - * @param array $bar Raw bar coordinates + * @param array{int, int, int, int} $bar Raw bar coordinates * - * @return array Bar coordinates + * @return array{float, float, float, float} Bar coordinates */ protected function getBarRectXYWH(array $bar): array { diff --git a/src/Type/Square/Aztec.php b/src/Type/Square/Aztec.php index 4f6359d0..b437789d 100644 --- a/src/Type/Square/Aztec.php +++ b/src/Type/Square/Aztec.php @@ -75,34 +75,53 @@ class Aztec extends \Com\Tecnick\Barcode\Type\Square * 2: HINT : Encoding mode: A=Automatic, B=Binary. * 3: LAYERS : Custom number of layers (0 = auto). * 4: ECI : Extended Channel Interpretation (ECI) code. Use -1 for FNC1. See $this->eci. + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function setParameters(): void { parent::setParameters(); // ecc percentage - if (! isset($this->params[0]) || ! in_array($this->params[0], range(1, 100))) { + if ( + ! isset($this->params[0]) + || ! is_numeric($this->params[0]) + || ! in_array($this->params[0], range(1, 100)) + ) { $this->params[0] = 33; } $this->ecc = (int) $this->params[0]; // hint - if (! isset($this->params[1]) || ! in_array($this->params[1], ['A', 'B'])) { + if ( + ! isset($this->params[1]) + || ! is_string($this->params[1]) + || ! in_array($this->params[1], ['A', 'B']) + ) { $this->params[1] = 'A'; } $this->hint = $this->params[1]; // mode - if (! isset($this->params[2]) || ! in_array($this->params[2], ['A', 'F'])) { + if ( + ! isset($this->params[2]) + || ! is_string($this->params[2]) + || ! in_array($this->params[2], ['A', 'F']) + ) { $this->params[2] = 'A'; } $this->mode = $this->params[2]; // eci code. Used to set the charset encoding. See $this->eci. - if (! isset($this->params[3]) || ! array_key_exists($this->params[3], Data::ECI)) { + if ( + ! isset($this->params[3]) + || ! is_numeric($this->params[3]) + || ! isset(Data::ECI[(int) $this->params[3]]) + ) { $this->params[3] = -1; } diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index 178fdfec..fd974107 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -108,11 +108,14 @@ protected function setParameters(): void /** * Set macro block parameter + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function setMacroBlockParam(): void { if ( isset($this->params[4]) + && (is_string($this->params[4])) && ($this->params[2] !== '') && ($this->params[3] !== '') && ($this->params[4] !== '') @@ -122,7 +125,11 @@ protected function setMacroBlockParam(): void $this->macro['file_id'] = strtr($this->params[4], "\xff", ','); for ($idx = 0; $idx < 7; ++$idx) { $opt = $idx + 5; - if (isset($this->params[$opt]) && ($this->params[$opt] !== '')) { + if ( + isset($this->params[$opt]) + && (is_string($this->params[$opt])) + && ($this->params[$opt] !== '') + ) { $this->macro['option_' . $idx] = strtr($this->params[$opt], "\xff", ','); } } From 9aeb74d723b2038c936df4aa14d20a7cb2e946b5 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 11:16:10 +0000 Subject: [PATCH 085/100] fixes --- src/Type/Linear/Postnet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Type/Linear/Postnet.php b/src/Type/Linear/Postnet.php index 5483173f..0c732bc0 100644 --- a/src/Type/Linear/Postnet.php +++ b/src/Type/Linear/Postnet.php @@ -117,7 +117,7 @@ protected function setBars(): void for ($pos = 0; $pos < 5; ++$pos) { $bar_height = (int) $this::CHBAR[$char][$pos]; - $this->bars[] = [$this->ncols, floor(1 / $bar_height), 1, $bar_height]; + $this->bars[] = [$this->ncols, (int) floor(1 / $bar_height), 1, $bar_height]; $this->ncols += 2; } } From 26ea96476c338503c519629449be6c2428fb4948 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 11:35:10 +0000 Subject: [PATCH 086/100] getRotatedBarArray --- src/Type/Convert.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Type/Convert.php b/src/Type/Convert.php index c85e619e..dd69aa3d 100644 --- a/src/Type/Convert.php +++ b/src/Type/Convert.php @@ -277,9 +277,7 @@ public function getGridArray( protected function getRotatedBarArray(): array { $grid = $this->getGridArray(); - $cols = array_map(...[ - -1 => null, - ] + $grid); + $cols = array_map(null, ...$grid); $bars = []; foreach ($cols as $posx => $col) { $prevrow = ''; From 261bfc51b04e90b7214a72cc5ef9003584f59b1a Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 11:45:09 +0000 Subject: [PATCH 087/100] isset const --- src/Type/Square/Aztec/Codeword.php | 4 ++-- src/Type/Square/Datamatrix/EncodeTxt.php | 8 ++++---- src/Type/Square/QrCode.php | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Type/Square/Aztec/Codeword.php b/src/Type/Square/Aztec/Codeword.php index 66e70321..714ebc1c 100644 --- a/src/Type/Square/Aztec/Codeword.php +++ b/src/Type/Square/Aztec/Codeword.php @@ -66,7 +66,7 @@ abstract class Codeword */ protected function charEnc(int $mode, int $ord): int { - return array_key_exists($ord, Data::CHAR_ENC[$mode]) ? Data::CHAR_ENC[$mode][$ord] : 0; + return isset(Data::CHAR_ENC[$mode][$ord]) ? Data::CHAR_ENC[$mode][$ord] : 0; } /** @@ -78,7 +78,7 @@ protected function charEnc(int $mode, int $ord): int */ protected function charMode(int $ord): int { - return array_key_exists($ord, Data::CHAR_MODES) ? Data::CHAR_MODES[$ord] : Data::MODE_BINARY; + return isset($ord, Data::CHAR_MODES[$ord]) ? Data::CHAR_MODES[$ord] : Data::MODE_BINARY; } /** diff --git a/src/Type/Square/Datamatrix/EncodeTxt.php b/src/Type/Square/Datamatrix/EncodeTxt.php index 9061a365..3c0bff84 100644 --- a/src/Type/Square/Datamatrix/EncodeTxt.php +++ b/src/Type/Square/Datamatrix/EncodeTxt.php @@ -43,16 +43,16 @@ public function encodeTXTC40shift( array &$temp_cw, int &$ptr ): void { - if (array_key_exists($chr, Data::CHSET['SH1'])) { + if (isset(Data::CHSET['SH1'][$chr])) { $temp_cw[] = 0; // shift 1 $shiftset = Data::CHSET['SH1']; - } elseif (array_key_exists($chr, Data::CHSET['SH2'])) { + } elseif (isset(Data::CHSET['SH2'][$chr])) { $temp_cw[] = 1; // shift 2 $shiftset = Data::CHSET['SH2']; - } elseif (($enc == Data::ENC_C40) && array_key_exists($chr, Data::CHSET['S3C'])) { + } elseif (($enc == Data::ENC_C40) && isset(Data::CHSET['S3C'][$chr])) { $temp_cw[] = 2; // shift 3 $shiftset = Data::CHSET['S3C']; - } elseif (($enc == Data::ENC_TXT) && array_key_exists($chr, Data::CHSET['S3T'])) { + } elseif (($enc == Data::ENC_TXT) && isset(Data::CHSET['S3T'][$chr])) { $temp_cw[] = 2; // shift 3 $shiftset = Data::CHSET['S3T']; } else { diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index b4b5e920..655cae30 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -108,21 +108,31 @@ protected function setParameters(): void parent::setParameters(); // level - if (! isset($this->params[0]) || ! array_key_exists($this->params[0], Data::ECC_LEVELS)) { + if ( + ! isset($this->params[0]) + || ! isset(Data::ECC_LEVELS[$this->params[0]]) + ) { $this->params[0] = 'L'; } $this->level = Data::ECC_LEVELS[$this->params[0]]; // hint - if (! isset($this->params[1]) || ! array_key_exists($this->params[1], Data::ENC_MODES)) { + if ( + ! isset($this->params[1]) + || ! isset(Data::ENC_MODES[$this->params[1]]) + ) { $this->params[1] = '8B'; } $this->hint = Data::ENC_MODES[$this->params[1]]; // version - if (! isset($this->params[2]) || ($this->params[2] < 0) || ($this->params[2] > Data::QRSPEC_VERSION_MAX)) { + if ( + ! isset($this->params[2]) + || ($this->params[2] < 0) + || ($this->params[2] > Data::QRSPEC_VERSION_MAX) + ) { $this->params[2] = 0; } From 985a588a522e4dc9b52724e34dcf10085579d5b7 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 11:47:02 +0000 Subject: [PATCH 088/100] typo --- src/Type/Square/Aztec/Codeword.php | 2 +- src/Type/Square/QrCode.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Type/Square/Aztec/Codeword.php b/src/Type/Square/Aztec/Codeword.php index 714ebc1c..874b1aa3 100644 --- a/src/Type/Square/Aztec/Codeword.php +++ b/src/Type/Square/Aztec/Codeword.php @@ -78,7 +78,7 @@ protected function charEnc(int $mode, int $ord): int */ protected function charMode(int $ord): int { - return isset($ord, Data::CHAR_MODES[$ord]) ? Data::CHAR_MODES[$ord] : Data::MODE_BINARY; + return isset(Data::CHAR_MODES[$ord]) ? Data::CHAR_MODES[$ord] : Data::MODE_BINARY; } /** diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index 655cae30..f694ef72 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -109,7 +109,7 @@ protected function setParameters(): void // level if ( - ! isset($this->params[0]) + ! isset($this->params[0]) || ! isset(Data::ECC_LEVELS[$this->params[0]]) ) { $this->params[0] = 'L'; @@ -119,7 +119,7 @@ protected function setParameters(): void // hint if ( - ! isset($this->params[1]) + ! isset($this->params[1]) || ! isset(Data::ENC_MODES[$this->params[1]]) ) { $this->params[1] = '8B'; @@ -129,8 +129,8 @@ protected function setParameters(): void // version if ( - ! isset($this->params[2]) - || ($this->params[2] < 0) + ! isset($this->params[2]) + || ($this->params[2] < 0) || ($this->params[2] > Data::QRSPEC_VERSION_MAX) ) { $this->params[2] = 0; From 392e4f24b66e710133fa84e02cbf45c6c58a9630 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 12:38:48 +0000 Subject: [PATCH 089/100] code128 --- src/Type/Linear/CodeOneTwoEight.php | 32 ++++++++++--------- .../CodeOneTwoEight/CodeOneTwoEightA.php | 2 ++ .../CodeOneTwoEight/CodeOneTwoEightB.php | 2 ++ .../CodeOneTwoEight/CodeOneTwoEightC.php | 2 ++ src/Type/Linear/CodeOneTwoEight/Process.php | 14 +++++--- src/Type/Raw.php | 2 +- 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/Type/Linear/CodeOneTwoEight.php b/src/Type/Linear/CodeOneTwoEight.php index 05846eaa..53a07eb9 100644 --- a/src/Type/Linear/CodeOneTwoEight.php +++ b/src/Type/Linear/CodeOneTwoEight.php @@ -37,6 +37,8 @@ class CodeOneTwoEight extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\P /** * Get the coe point array * + * @return array + * * @throws BarcodeException in case of error */ protected function getCodeData(): array @@ -59,11 +61,11 @@ protected function getCodeData(): array /** * Process the A sequence * - * @param array $sequence Sequence to process - * @param array $code_data Array of codepoints to alter + * @param array> $sequence Sequence to process + * @param array $code_data Array of codepoints to alter * @param int $startid Start ID * @param int $key Sequence current key - * @param array $seq Sequence current value + * @param array{string, string, int} $seq Sequence current value * * @throws BarcodeException in case of error */ @@ -98,11 +100,11 @@ protected function processSequenceA( /** * Process the B sequence * - * @param array $sequence Sequence to process - * @param array $code_data Array of codepoints to alter + * @param array> $sequence Sequence to process + * @param array $code_data Array of codepoints to alter * @param int $startid Start ID * @param int $key Sequence current key - * @param array $seq Sequence current value + * @param array{string, string, int} $seq Sequence current value * * @throws BarcodeException in case of error */ @@ -125,11 +127,11 @@ protected function processSequenceB( /** * Process the B-A sequence * - * @param array $sequence Sequence to process - * @param array $code_data Array of codepoints to alter + * @param array> $sequence Sequence to process + * @param array $code_data Array of codepoints to alter * @param int $startid Start ID * @param int $key Sequence current key - * @param array $seq Sequence current value + * @param array{string, string, int} $seq Sequence current value * * @throws BarcodeException in case of error */ @@ -168,10 +170,10 @@ protected function processSequenceBA( /** * Process the B-B sequence * - * @param array $sequence Sequence to process - * @param array $code_data Array of codepoints to alter + * @param array> $sequence Sequence to process + * @param array $code_data Array of codepoints to alter * @param int $key Sequence current key - * @param array $seq Sequence current value + * @param array{string, string, int} $seq Sequence current value * * @throws BarcodeException in case of error */ @@ -199,11 +201,11 @@ protected function processSequenceBB( /** * Process the C sequence * - * @param array $sequence Sequence to process - * @param array $code_data Array of codepoints to alter + * @param array> $sequence Sequence to process + * @param array $code_data Array of codepoints to alter * @param int $startid Start ID * @param int $key Sequence current key - * @param array $seq Sequence current value + * @param array{string, string, int} $seq Sequence current value * * @throws BarcodeException in case of error */ diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php index 86eb37a4..61eb7e91 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightA.php @@ -44,6 +44,8 @@ class CodeOneTwoEightA extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight /** * Get the code point array * + * @return array + * * @throws BarcodeException in case of error */ protected function getCodeData(): array diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php index 5be600c6..622ac9d3 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightB.php @@ -44,6 +44,8 @@ class CodeOneTwoEightB extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight /** * Get the code point array * + * @return array + * * @throws BarcodeException in case of error */ protected function getCodeData(): array diff --git a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php index 2ecdcbc0..a67a602a 100644 --- a/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php +++ b/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php @@ -44,6 +44,8 @@ class CodeOneTwoEightC extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight /** * Get the code point array * + * @return array + * * @throws BarcodeException in case of error */ protected function getCodeData(): array diff --git a/src/Type/Linear/CodeOneTwoEight/Process.php b/src/Type/Linear/CodeOneTwoEight/Process.php index cc15a56f..17af0348 100644 --- a/src/Type/Linear/CodeOneTwoEight/Process.php +++ b/src/Type/Linear/CodeOneTwoEight/Process.php @@ -215,6 +215,8 @@ abstract class Process extends \Com\Tecnick\Barcode\Type\Linear * * @param string $code Code to parse * + * @return array + * * @throws BarcodeException in case of error */ protected function getNumericSequence(string $code): array @@ -267,7 +269,7 @@ protected function getNumericSequence(string $code): array * * @param string $code Code to split * - * @return array sequence + * @return array */ protected function get128ABsequence(string $code): array { @@ -307,7 +309,7 @@ protected function get128ABsequence(string $code): array /** * Get the A code point array * - * @param array $code_data Array of codepoints to alter + * @param array $code_data Array of codepoints to alter * @param string $code Code to process * @param int $len Number of characters to process * @@ -334,7 +336,7 @@ protected function getCodeDataA( /** * Get the B code point array * - * @param array $code_data Array of codepoints to alter + * @param array $code_data Array of codepoints to alter * @param string $code Code to process * @param int $len Number of characters to process * @@ -361,7 +363,7 @@ protected function getCodeDataB( /** * Get the C code point array * - * @param array $code_data Array of codepoints to alter + * @param array $code_data Array of codepoints to alter * @param string $code Code to process * * @throws BarcodeException in case of error @@ -399,8 +401,10 @@ protected function getCodeDataC( /** * Finalize code data * - * @param array $code_data Array of codepoints to alter + * @param array $code_data Array of codepoints to alter * @param int $startid Start ID code + * + * @return array Array of codepoints */ protected function finalizeCodeData( array $code_data, diff --git a/src/Type/Raw.php b/src/Type/Raw.php index 16dd3775..47c95223 100644 --- a/src/Type/Raw.php +++ b/src/Type/Raw.php @@ -33,7 +33,7 @@ class Raw extends \Com\Tecnick\Barcode\Type { /** - * Get the bars array + * Generate the bars array */ protected function setBars(): void { From 95d24a1789efb144e2958753ae743c97a4585047 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 13:40:36 +0000 Subject: [PATCH 090/100] linear --- src/Type/Linear/Imb.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Type/Linear/Imb.php b/src/Type/Linear/Imb.php index a6f80383..35dd712e 100644 --- a/src/Type/Linear/Imb.php +++ b/src/Type/Linear/Imb.php @@ -376,7 +376,7 @@ protected function getReversedUnsignedShort(int $num): int /** * Get the Frame Check Sequence * - * @param array $code_arr Array of hexadecimal values (13 bytes holding 102 bits right justified). + * @param array $code_arr Array of hexadecimal values (13 bytes holding 102 bits right justified). * * @return int 11 bit Frame Check Sequence as integer (decimal base) */ @@ -413,7 +413,7 @@ protected function getFrameCheckSequence(array $code_arr): int * @param int $type Table type: 2 for 2of13 table, 5 for 5of13table * @param int $size Table size (78 for n=2 and 1287 for n=5) * - * @return array requested table + * @return array requested table */ protected function getTables(int $type, int $size): array { @@ -472,6 +472,8 @@ protected function getRoutingCode(string $routing_code): string /** * Get the processed array of characters * + * @return array + * * @throws BarcodeException in case of error */ protected function getCharsArray(): array From aec026582cace03ecc3fee39bc607ab332ab7783 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 14:41:59 +0000 Subject: [PATCH 091/100] fixes --- src/Type/Square/PdfFourOneSeven.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index fd974107..bf782470 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -82,6 +82,19 @@ class PdfFourOneSeven extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\C /** * Information for macro block + * + * @var array{ + * 'file_id'?: string, + * 'option_0'?: string, + * 'option_1'?: string, + * 'option_2'?: string, + * 'option_3'?: string, + * 'option_4'?: string, + * 'option_5'?: string, + * 'option_6'?: string, + * 'segment_index'?: int, + * 'segment_total'?: int, + * } */ protected array $macro = []; @@ -93,12 +106,19 @@ protected function setParameters(): void parent::setParameters(); // aspect ratio - if (! empty($this->params[0]) && (($aspectratio = (float) $this->params[0]) >= 1)) { + if ( + ! empty($this->params[0]) + && (($aspectratio = (float) $this->params[0]) >= 1) + ) { $this->aspectratio = $aspectratio; } // error correction level (auto) - if (isset($this->params[1]) && (($ecl = (int) $this->params[1]) >= 0) && ($ecl <= 8)) { + if ( + isset($this->params[1]) + && (($ecl = (int) $this->params[1]) >= 0) + && ($ecl <= 8) + ) { $this->ecl = $ecl; } @@ -130,6 +150,7 @@ protected function setMacroBlockParam(): void && (is_string($this->params[$opt])) && ($this->params[$opt] !== '') ) { + /* @phpstan-ignore-next-line */ $this->macro['option_' . $idx] = strtr($this->params[$opt], "\xff", ','); } } @@ -155,6 +176,8 @@ protected function setBars(): void * Get macro control block codewords * * @param int $numcw Number of codewords + * + * @return array */ protected function getMacroBlock(int &$numcw): array { @@ -206,6 +229,8 @@ protected function getMacroBlock(int &$numcw): array * @param int $cols number of columns * @param int $ecl eroor correction level * + * @return array + * * @throws BarcodeException in case of error */ public function getCodewords( From 8fad6f2535338a388f0a1d69d43083c14cc44d91 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 14:47:21 +0000 Subject: [PATCH 092/100] fixes --- .../Square/PdfFourOneSeven/Compaction.php | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/src/Type/Square/PdfFourOneSeven/Compaction.php b/src/Type/Square/PdfFourOneSeven/Compaction.php index 84da4b9c..c76f635d 100644 --- a/src/Type/Square/PdfFourOneSeven/Compaction.php +++ b/src/Type/Square/PdfFourOneSeven/Compaction.php @@ -3,13 +3,13 @@ /** * Process.php * - * @since 2015-02-21 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode * * This file is part of tc-lib-barcode software library. */ @@ -21,18 +21,26 @@ * * Process for PdfFourOneSeven Barcode type class * - * @since 2015-02-21 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode */ abstract class Compaction extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven\Sequence { /** * Process Sub Text Compaction + * + * @param array $txtarr Array of characters and sub-mode switching characters + * @param int $submode Current submode + * @param int $sub New submode + * @param string $code Data to compact + * @param int $key Character code + * @param int $idx Current index + * @param int $codelen Code length */ protected function processTextCompactionSub( array &$txtarr, @@ -58,15 +66,15 @@ protected function processTextCompactionSub( $submode = $sub; } - // add characted code to array + // add character code to array $txtarr[] = $key; } /** * Process Text Compaction * - * @param string $code Data to compact - * @param array $codewords Codewords + * @param string $code Data to compact + * @param array $codewords Codewords */ protected function processTextCompaction(string $code, array &$codewords): void { @@ -109,8 +117,8 @@ protected function processTextCompaction(string $code, array &$codewords): void /** * Process Byte Compaction * - * @param string $code Data to compact - * @param array $codewords Codewords + * @param string $code Data to compact + * @param array $codewords Codewords */ protected function processByteCompaction(string $code, array &$codewords): void { @@ -155,8 +163,8 @@ protected function processByteCompaction(string $code, array &$codewords): void /** * Process Numeric Compaction * - * @param string $code Data to compact - * @param array $codewords Codewords + * @param string $code Data to compact + * @param array $codewords Codewords */ protected function processNumericCompaction(string $code, array &$codewords): void { @@ -181,11 +189,11 @@ protected function processNumericCompaction(string $code, array &$codewords): vo /** * Compact data by mode * - * @param int $mode Compaction mode number - * @param string $code Data to compact - * @param bool $addmode If true add the mode codeword in the first position + * @param int $mode Compaction mode number + * @param string $code Data to compact + * @param bool $addmode If true add the mode codeword in the first position * - * @return array of codewords + * @return array of codewords */ protected function getCompaction( int $mode, From ccbb9159987b30b4f0783ce05e24530d3b8f646c Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 15:01:35 +0000 Subject: [PATCH 093/100] pdf417 --- src/Type/Square/PdfFourOneSeven.php | 4 ++-- src/Type/Square/PdfFourOneSeven/Sequence.php | 24 +++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Type/Square/PdfFourOneSeven.php b/src/Type/Square/PdfFourOneSeven.php index bf782470..71d5c7f3 100644 --- a/src/Type/Square/PdfFourOneSeven.php +++ b/src/Type/Square/PdfFourOneSeven.php @@ -281,7 +281,7 @@ public function getCodewords( } // calculate padding - $pad = ($size - $nce); + $pad = (int) ($size - $nce); if ($pad > 0) { // add padding $codewords = array_merge($codewords, array_fill(0, $pad, 900)); @@ -293,7 +293,7 @@ public function getCodewords( } // Symbol Length Descriptor (number of data codewords including Symbol Length Descriptor and pad codewords) - $sld = ($size - $errsize); + $sld = (int) ($size - $errsize); // add symbol length description array_unshift($codewords, $sld); // calculate error correction diff --git a/src/Type/Square/PdfFourOneSeven/Sequence.php b/src/Type/Square/PdfFourOneSeven/Sequence.php index a55cf685..e3c0b762 100644 --- a/src/Type/Square/PdfFourOneSeven/Sequence.php +++ b/src/Type/Square/PdfFourOneSeven/Sequence.php @@ -61,16 +61,16 @@ protected function getErrorCorrectionLevel(int $ecl, int $numcw): int } } - return min($maxecl, $ecl); + return (int) min($maxecl, $ecl); } /** * Get the error correction codewords * - * @param array $codewords Array of codewords including Symbol Length Descriptor and pad + * @param array $codewords Array of codewords including Symbol Length Descriptor and pad * @param int $ecl Error correction level 0-8 * - * @return array of error correction codewords + * @return array of error correction codewords */ protected function getErrorCorrection(array $codewords, int $ecl): array { @@ -86,19 +86,19 @@ protected function getErrorCorrection(array $codewords, int $ecl): array foreach ($codewords as $codeword) { $tk1 = ($codeword + $ecw[$eclmaxid]) % 929; for ($idx = $eclmaxid; $idx > 0; --$idx) { - $tk2 = ($tk1 * $ecc[$idx]) % 929; - $tk3 = 929 - $tk2; - $ecw[$idx] = ($ecw[($idx - 1)] + $tk3) % 929; + $tk2 = (($tk1 * $ecc[$idx]) % 929); + $tk3 = (929 - $tk2); + $ecw[$idx] = (int) (($ecw[($idx - 1)] + $tk3) % 929); } - $tk2 = ($tk1 * $ecc[0]) % 929; - $tk3 = 929 - $tk2; - $ecw[0] = $tk3 % 929; + $tk2 = (($tk1 * $ecc[0]) % 929); + $tk3 = (929 - $tk2); + $ecw[0] = (int) ($tk3 % 929); } foreach ($ecw as $idx => $err) { if ($err != 0) { - $ecw[$idx] = 929 - $err; + $ecw[$idx] = (int) (929 - $err); } } @@ -108,7 +108,7 @@ protected function getErrorCorrection(array $codewords, int $ecl): array /** * Process a single sequence * - * @param array $sequence_array Sequence to process + * @param array $sequence_array Sequence to process * @param string $code Data to process * @param int $seq Current sequence * @param int $offset Current code offset @@ -156,6 +156,8 @@ protected function processSequence(array &$sequence_array, string $code, int $se * Get an array of sequences from input * * @param string $code Data to process + * + * @return array */ protected function getInputSequences(string $code): array { From 51e060e2713bfa6a53b6658ff697e305815251dc Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 15:13:32 +0000 Subject: [PATCH 094/100] data format --- src/Type/Square/Aztec/Data.php | 876 +++++++++++--------------------- src/Type/Square/QrCode/Data.php | 101 +--- 2 files changed, 304 insertions(+), 673 deletions(-) diff --git a/src/Type/Square/Aztec/Data.php b/src/Type/Square/Aztec/Data.php index e03289a4..a1edbcb6 100644 --- a/src/Type/Square/Aztec/Data.php +++ b/src/Type/Square/Aztec/Data.php @@ -65,17 +65,12 @@ class Data * Number of bits for each character encoding mode. */ public const MODE_BITS = [ - 5, - // 0 = MODE_UPPER - 5, - // 1 = MODE_LOWER - 4, - // 2 = MODE_DIGIT - 5, - // 3 = MODE_MIXED - 5, - // 4 = MODE_PUNCT - 8, + 5, // 0 = MODE_UPPER + 5, // 1 = MODE_LOWER + 4, // 2 = MODE_DIGIT + 5, // 3 = MODE_MIXED + 5, // 4 = MODE_PUNCT + 8, // 5 = MODE_BINARY ]; /** @@ -84,251 +79,137 @@ class Data public const CHAR_ENC = [ // MODE_UPPER (initial mode) 0 => [ - 32 => 1, - // ' ' (SP) - 65 => 2, - // 'A' - 66 => 3, - // 'B' - 67 => 4, - // 'C' - 68 => 5, - // 'D' - 69 => 6, - // 'E' - 70 => 7, - // 'F' - 71 => 8, - // 'G' - 72 => 9, - // 'H' - 73 => 10, - // 'I' - 74 => 11, - // 'J' - 75 => 12, - // 'K' - 76 => 13, - // 'L' - 77 => 14, - // 'M' - 78 => 15, - // 'N' - 79 => 16, - // 'O' - 80 => 17, - // 'P' - 81 => 18, - // 'Q' - 82 => 19, - // 'R' - 83 => 20, - // 'S' - 84 => 21, - // 'T' - 85 => 22, - // 'U' - 86 => 23, - // 'V' - 87 => 24, - // 'W' - 88 => 25, - // 'X' - 89 => 26, - // 'Y' - 90 => 27, + 32 => 1, // ' ' (SP) + 65 => 2, // 'A' + 66 => 3, // 'B' + 67 => 4, // 'C' + 68 => 5, // 'D' + 69 => 6, // 'E' + 70 => 7, // 'F' + 71 => 8, // 'G' + 72 => 9, // 'H' + 73 => 10, // 'I' + 74 => 11, // 'J' + 75 => 12, // 'K' + 76 => 13, // 'L' + 77 => 14, // 'M' + 78 => 15, // 'N' + 79 => 16, // 'O' + 80 => 17, // 'P' + 81 => 18, // 'Q' + 82 => 19, // 'R' + 83 => 20, // 'S' + 84 => 21, // 'T' + 85 => 22, // 'U' + 86 => 23, // 'V' + 87 => 24, // 'W' + 88 => 25, // 'X' + 89 => 26, // 'Y' + 90 => 27, // 'Z' ], // MODE_LOWER 1 => [ - 32 => 1, - // ' ' (SP) - 97 => 2, - // 'a' - 98 => 3, - // 'b' - 99 => 4, - // 'c' - 100 => 5, - // 'd' - 101 => 6, - // 'e' - 102 => 7, - // 'f' - 103 => 8, - // 'g' - 104 => 9, - // 'h' - 105 => 10, - // 'i' - 106 => 11, - // 'j' - 107 => 12, - // 'k' - 108 => 13, - // 'l' - 109 => 14, - // 'm' - 110 => 15, - // 'n' - 111 => 16, - // 'o' - 112 => 17, - // 'p' - 113 => 18, - // 'q' - 114 => 19, - // 'r' - 115 => 20, - // 's' - 116 => 21, - // 't' - 117 => 22, - // 'u' - 118 => 23, - // 'v' - 119 => 24, - // 'w' - 120 => 25, - // 'x' - 121 => 26, - // 'y' - 122 => 27, + 32 => 1, // ' ' (SP) + 97 => 2, // 'a' + 98 => 3, // 'b' + 99 => 4, // 'c' + 100 => 5, // 'd' + 101 => 6, // 'e' + 102 => 7, // 'f' + 103 => 8, // 'g' + 104 => 9, // 'h' + 105 => 10, // 'i' + 106 => 11, // 'j' + 107 => 12, // 'k' + 108 => 13, // 'l' + 109 => 14, // 'm' + 110 => 15, // 'n' + 111 => 16, // 'o' + 112 => 17, // 'p' + 113 => 18, // 'q' + 114 => 19, // 'r' + 115 => 20, // 's' + 116 => 21, // 't' + 117 => 22, // 'u' + 118 => 23, // 'v' + 119 => 24, // 'w' + 120 => 25, // 'x' + 121 => 26, // 'y' + 122 => 27, // 'z' ], // MODE_DIGIT 2 => [ - 32 => 1, - // ' ' (SP) - 44 => 12, - // ',' - 46 => 13, - // '.' - 48 => 2, - // '0' - 49 => 3, - // '1' - 50 => 4, - // '2' - 51 => 5, - // '3' - 52 => 6, - // '4' - 53 => 7, - // '5' - 54 => 8, - // '6' - 55 => 9, - // '7' - 56 => 10, - // '8' - 57 => 11, + 32 => 1, // ' ' (SP) + 44 => 12, // ',' + 46 => 13, // '.' + 48 => 2, // '0' + 49 => 3, // '1' + 50 => 4, // '2' + 51 => 5, // '3' + 52 => 6, // '4' + 53 => 7, // '5' + 54 => 8, // '6' + 55 => 9, // '7' + 56 => 10, // '8' + 57 => 11, // '9' ], // MODE_MIXED 3 => [ - 1 => 2, - // '^A' (SOH) - 2 => 3, - // '^B' (STX) - 3 => 4, - // '^C' (ETX) - 4 => 5, - // '^D' (EOT) - 5 => 6, - // '^E' (ENQ) - 6 => 7, - // '^F' (ACK) - 7 => 8, - // '^G' (BEL) - 8 => 9, - // '^H' (BS) - 9 => 10, - // '^I' (HT) - 10 => 11, - // '^J' (LF) - 11 => 12, - // '^K' (VT) - 12 => 13, - // '^L' (FF) - 13 => 14, - // '^M' (CR) - 27 => 15, - // '^[' (ESC) - 28 => 16, - // '^\' (FS) - 29 => 17, - // '^]' (GS) - 30 => 18, - // '^^' (RS) - 31 => 19, - // '^_' (US) - 64 => 20, - // '@' - 92 => 21, - // '\' - 94 => 22, - // '^' - 95 => 23, - // '_' - 96 => 24, - // '`' - 124 => 25, - // '|' - 126 => 26, - // '~' - 127 => 27, + 1 => 2, // '^A' (SOH) + 2 => 3, // '^B' (STX) + 3 => 4, // '^C' (ETX) + 4 => 5, // '^D' (EOT) + 5 => 6, // '^E' (ENQ) + 6 => 7, // '^F' (ACK) + 7 => 8, // '^G' (BEL) + 8 => 9, // '^H' (BS) + 9 => 10, // '^I' (HT) + 10 => 11, // '^J' (LF) + 11 => 12, // '^K' (VT) + 12 => 13, // '^L' (FF) + 13 => 14, // '^M' (CR) + 27 => 15, // '^[' (ESC) + 28 => 16, // '^\' (FS) + 29 => 17, // '^]' (GS) + 30 => 18, // '^^' (RS) + 31 => 19, // '^_' (US) + 64 => 20, // '@' + 92 => 21, // '\' + 94 => 22, // '^' + 95 => 23, // '_' + 96 => 24, // '`' + 124 => 25, // '|' + 126 => 26, // '~' + 127 => 27, // '^?' (DEL) ], // MODE_PUNCT 4 => [ - 13 => 1, - // '\r' (CR) - 33 => 6, - // '!' - 34 => 7, - // '"' - 35 => 8, - // '#' - 36 => 9, - // '$' - 37 => 10, - // '%' - 38 => 11, - // '&' - 39 => 12, - // ''' - 40 => 13, - // '(' - 41 => 14, - // ')' - 42 => 15, - // '*' - 43 => 16, - // '+' - 44 => 17, - // ',' - 45 => 18, - // '-' - 46 => 19, - // '.' - 47 => 20, - // '/' - 58 => 21, - // ':' - 59 => 22, - // ';' - 60 => 23, - // '<' - 61 => 24, - // '=' - 62 => 25, - // '>' - 63 => 26, - // '?' - 91 => 27, - // '[' - 93 => 28, - // ']' - 123 => 29, - // '{' - 125 => 30, + 13 => 1, // '\r' (CR) + 33 => 6, // '!' + 34 => 7, // '"' + 35 => 8, // '#' + 36 => 9, // '$' + 37 => 10, // '%' + 38 => 11, // '&' + 39 => 12, // ''' + 40 => 13, // '(' + 41 => 14, // ')' + 42 => 15, // '*' + 43 => 16, // '+' + 44 => 17, // ',' + 45 => 18, // '-' + 46 => 19, // '.' + 47 => 20, // '/' + 58 => 21, // ':' + 59 => 22, // ';' + 60 => 23, // '<' + 61 => 24, // '=' + 62 => 25, // '>' + 63 => 26, // '?' + 91 => 27, // '[' + 93 => 28, // ']' + 123 => 29, // '{' + 125 => 30, // '}' ], // MODE_BINARY (all 8-bit values are valid) 5 => [], @@ -342,233 +223,120 @@ class Data * - the comma ',' and dot '.' characters (44,46) that map for modes 2,4. */ public const CHAR_MODES = [ - 1 => 3, - // '^A' (SOH) - 2 => 3, - // '^B' (STX) - 3 => 3, - // '^C' (ETX) - 4 => 3, - // '^D' (EOT) - 5 => 3, - // '^E' (ENQ) - 6 => 3, - // '^F' (ACK) - 7 => 3, - // '^G' (BEL) - 8 => 3, - // '^H' (BS) - 9 => 3, - // '^I' (HT) - 10 => 3, - // '^J' (LF) - 11 => 3, - // '^K' (VT) - 12 => 3, - // '^L' (FF) - 13 => 3, - // '^M' (CR) [3,4] - 27 => 3, - // '^[' (ESC) - 28 => 3, - // '^\' (FS) - 29 => 3, - // '^]' (GS) - 30 => 3, - // '^^' (RS) - 31 => 3, - // '^_' (US) - 32 => 0, - // ' ' [0,1,2] - 33 => 4, - // '!' - 34 => 4, - // '"' - 35 => 4, - // '#' - 36 => 4, - // '$' - 37 => 4, - // '%' - 38 => 4, - // '&' - 39 => 4, - // ''' - 40 => 4, - // '(' - 41 => 4, - // ')' - 42 => 4, - // '*' - 43 => 4, - // '+'f - 44 => 2, - // ',' [2,4] - 45 => 4, - // '-' - 46 => 2, - // '.' [2,4] - 47 => 4, - // '/' - 48 => 2, - // '0' - 49 => 2, - // '1' - 50 => 2, - // '2' - 51 => 2, - // '3' - 52 => 2, - // '4' - 53 => 2, - // '5' - 54 => 2, - // '6' - 55 => 2, - // '7' - 56 => 2, - // '8' - 57 => 2, - // '9' - 58 => 4, - // ':' - 59 => 4, - // ';' - 60 => 4, - // '<' - 61 => 4, - // '=' - 62 => 4, - // '>' - 63 => 4, - // '?' - 64 => 3, - // '@' - 65 => 0, - // 'A' - 66 => 0, - // 'B' - 67 => 0, - // 'C' - 68 => 0, - // 'D' - 69 => 0, - // 'E' - 70 => 0, - // 'F' - 71 => 0, - // 'G' - 72 => 0, - // 'H' - 73 => 0, - // 'I' - 74 => 0, - // 'J' - 75 => 0, - // 'K' - 76 => 0, - // 'L' - 77 => 0, - // 'M' - 78 => 0, - // 'N' - 79 => 0, - // 'O' - 80 => 0, - // 'P' - 81 => 0, - // 'Q' - 82 => 0, - // 'R' - 83 => 0, - // 'S' - 84 => 0, - // 'T' - 85 => 0, - // 'U' - 86 => 0, - // 'V' - 87 => 0, - // 'W' - 88 => 0, - // 'X' - 89 => 0, - // 'Y' - 90 => 0, - // 'Z' - 91 => 4, - // '[' - 92 => 3, - // '\' - 93 => 4, - // ']' - 94 => 3, - // '^' - 95 => 3, - // '_' - 96 => 3, - // '`' - 97 => 1, - // 'a' - 98 => 1, - // 'b' - 99 => 1, - // 'c' - 100 => 1, - // 'd' - 101 => 1, - // 'e' - 102 => 1, - // 'f' - 103 => 1, - // 'g' - 104 => 1, - // 'h' - 105 => 1, - // 'i' - 106 => 1, - // 'j' - 107 => 1, - // 'k' - 108 => 1, - // 'l' - 109 => 1, - // 'm' - 110 => 1, - // 'n' - 111 => 1, - // 'o' - 112 => 1, - // 'p' - 113 => 1, - // 'q' - 114 => 1, - // 'r' - 115 => 1, - // 's' - 116 => 1, - // 't' - 117 => 1, - // 'u' - 118 => 1, - // 'v' - 119 => 1, - // 'w' - 120 => 1, - // 'x' - 121 => 1, - // 'y' - 122 => 1, - // 'z' - 123 => 4, - // '{' - 124 => 3, - // '|' - 125 => 4, - // '}' - 126 => 3, - // '~' - 127 => 3, + 1 => 3, // '^A' (SOH) + 2 => 3, // '^B' (STX) + 3 => 3, // '^C' (ETX) + 4 => 3, // '^D' (EOT) + 5 => 3, // '^E' (ENQ) + 6 => 3, // '^F' (ACK) + 7 => 3, // '^G' (BEL) + 8 => 3, // '^H' (BS) + 9 => 3, // '^I' (HT) + 10 => 3, // '^J' (LF) + 11 => 3, // '^K' (VT) + 12 => 3, // '^L' (FF) + 13 => 3, // '^M' (CR) [3,4] + 27 => 3, // '^[' (ESC) + 28 => 3, // '^\' (FS) + 29 => 3, // '^]' (GS) + 30 => 3, // '^^' (RS) + 31 => 3, // '^_' (US) + 32 => 0, // ' ' [0,1,2] + 33 => 4, // '!' + 34 => 4, // '"' + 35 => 4, // '#' + 36 => 4, // '$' + 37 => 4, // '%' + 38 => 4, // '&' + 39 => 4, // ''' + 40 => 4, // '(' + 41 => 4, // ')' + 42 => 4, // '*' + 43 => 4, // '+'f + 44 => 2, // ',' [2,4] + 45 => 4, // '-' + 46 => 2, // '.' [2,4] + 47 => 4, // '/' + 48 => 2, // '0' + 49 => 2, // '1' + 50 => 2, // '2' + 51 => 2, // '3' + 52 => 2, // '4' + 53 => 2, // '5' + 54 => 2, // '6' + 55 => 2, // '7' + 56 => 2, // '8' + 57 => 2, // '9' + 58 => 4, // ':' + 59 => 4, // ';' + 60 => 4, // '<' + 61 => 4, // '=' + 62 => 4, // '>' + 63 => 4, // '?' + 64 => 3, // '@' + 65 => 0, // 'A' + 66 => 0, // 'B' + 67 => 0, // 'C' + 68 => 0, // 'D' + 69 => 0, // 'E' + 70 => 0, // 'F' + 71 => 0, // 'G' + 72 => 0, // 'H' + 73 => 0, // 'I' + 74 => 0, // 'J' + 75 => 0, // 'K' + 76 => 0, // 'L' + 77 => 0, // 'M' + 78 => 0, // 'N' + 79 => 0, // 'O' + 80 => 0, // 'P' + 81 => 0, // 'Q' + 82 => 0, // 'R' + 83 => 0, // 'S' + 84 => 0, // 'T' + 85 => 0, // 'U' + 86 => 0, // 'V' + 87 => 0, // 'W' + 88 => 0, // 'X' + 89 => 0, // 'Y' + 90 => 0, // 'Z' + 91 => 4, // '[' + 92 => 3, // '\' + 93 => 4, // ']' + 94 => 3, // '^' + 95 => 3, // '_' + 96 => 3, // '`' + 97 => 1, // 'a' + 98 => 1, // 'b' + 99 => 1, // 'c' + 100 => 1, // 'd' + 101 => 1, // 'e' + 102 => 1, // 'f' + 103 => 1, // 'g' + 104 => 1, // 'h' + 105 => 1, // 'i' + 106 => 1, // 'j' + 107 => 1, // 'k' + 108 => 1, // 'l' + 109 => 1, // 'm' + 110 => 1, // 'n' + 111 => 1, // 'o' + 112 => 1, // 'p' + 113 => 1, // 'q' + 114 => 1, // 'r' + 115 => 1, // 's' + 116 => 1, // 't' + 117 => 1, // 'u' + 118 => 1, // 'v' + 119 => 1, // 'w' + 120 => 1, // 'x' + 121 => 1, // 'y' + 122 => 1, // 'z' + 123 => 4, // '{' + 124 => 3, // '|' + 125 => 4, // '}' + 126 => 3, // '~' + 127 => 3, // '^?' (DEL) ]; /** @@ -578,53 +346,38 @@ class Data public const LATCH_MAP = [ // MODE_UPPER 0 => [ - 1 => [[5, 28]], - // -> LOWER - 2 => [[5, 30]], - // -> DIGIT - 3 => [[5, 29]], - // -> MIXED - 4 => [[5, 29], [5, 30]], + 1 => [[5, 28]], // -> LOWER + 2 => [[5, 30]], // -> DIGIT + 3 => [[5, 29]], // -> MIXED + 4 => [[5, 29], [5, 30]], // -> MIXED -> PUNCT ], // MODE_LOWER 1 => [ - 0 => [[5, 30], [4, 14]], - // -> DIGIT -> UPPER - 2 => [[5, 30]], - // -> DIGIT - 3 => [[5, 29]], - // -> MIXED - 4 => [[5, 29], [5, 30]], + 0 => [[5, 30], [4, 14]], // -> DIGIT -> UPPER + 2 => [[5, 30]], // -> DIGIT + 3 => [[5, 29]], // -> MIXED + 4 => [[5, 29], [5, 30]], // -> MIXED -> PUNCT ], // MODE_DIGIT 2 => [ - 0 => [[4, 14]], - // -> UPPER - 1 => [[4, 14], [5, 28]], - // -> UPPER -> LOWER - 3 => [[4, 14], [5, 29]], - // -> UPPER -> MIXED - 4 => [[4, 14], [5, 29], [5, 30]], + 0 => [[4, 14]], // -> UPPER + 1 => [[4, 14], [5, 28]], // -> UPPER -> LOWER + 3 => [[4, 14], [5, 29]], // -> UPPER -> MIXED + 4 => [[4, 14], [5, 29], [5, 30]], // -> UPPER -> MIXED -> PUNCT ], // MODE_MIXED 3 => [ - 0 => [[5, 29]], - // -> UPPER - 1 => [[5, 28]], - // -> LOWER - 2 => [[5, 29], [5, 30]], - // -> UPPER -> DIGIT - 4 => [[5, 30]], + 0 => [[5, 29]], // -> UPPER + 1 => [[5, 28]], // -> LOWER + 2 => [[5, 29], [5, 30]], // -> UPPER -> DIGIT + 4 => [[5, 30]], // -> PUNCT ], // MODE_PUNCT 4 => [ - 0 => [[5, 31]], - // -> UPPER - 1 => [[5, 31], [5, 28]], - // -> UPPER -> LOWER - 2 => [[5, 31], [5, 30]], - // -> UPPER -> DIGIT - 3 => [[5, 31], [5, 29]], + 0 => [[5, 31]], // -> UPPER + 1 => [[5, 31], [5, 28]], // -> UPPER -> LOWER + 2 => [[5, 31], [5, 30]], // -> UPPER -> DIGIT + 3 => [[5, 31], [5, 29]], // -> UPPER -> MIXED ], ]; @@ -638,38 +391,32 @@ class Data 1 => [], 2 => [], 3 => [], - 4 => [[5, 0]], - // -> PUNCT - 5 => [[5, 31]], + 4 => [[5, 0]], // -> PUNCT + 5 => [[5, 31]], // -> BINARY ], // MODE_LOWER 1 => [ - 0 => [[5, 28]], - // -> UPPER + 0 => [[5, 28]], // -> UPPER 2 => [], 3 => [], - 4 => [[5, 0]], - // -> PUNCT - 5 => [[5, 31]], + 4 => [[5, 0]], // -> PUNCT + 5 => [[5, 31]], // -> BINARY ], // MODE_DIGIT 2 => [ - 0 => [[4, 15]], - // -> UPPER + 0 => [[4, 15]], // -> UPPER 1 => [], 3 => [], - 4 => [[4, 0]], - // -> PUNCT - 5 => [[4, 14], [5, 31]], + 4 => [[4, 0]], // -> PUNCT + 5 => [[4, 14], [5, 31]], // -> LATCH UPPER -> BINARY ], // MODE_MIXED 3 => [ 0 => [], 1 => [], 2 => [], - 4 => [[5, 0]], - // -> PUNCT - 5 => [[5, 31]], + 4 => [[5, 0]], // -> PUNCT + 5 => [[5, 31]], // -> BINARY ], // MODE_PUNCT 4 => [ @@ -677,7 +424,7 @@ class Data 1 => [], 2 => [], 3 => [], - 5 => [[5, 31], [5, 31]], + 5 => [[5, 31], [5, 31]], // -> LATCH UPPER -> BINARY ], ]; @@ -685,61 +432,34 @@ class Data * Extended Channel Interpretation (ECI) codes. */ public const ECI = [ - 0 => 'FNC1', - // Function 1 character - 2 => 'Cp437', - // Code page 437 - 3 => 'ISO-8859-1', - // ISO/IEC 8859-1 - Latin-1 (Default encoding) - 4 => 'ISO-8859-2', - // ISO/IEC 8859-2 - Latin-2 - 5 => 'ISO-8859-3', - // ISO/IEC 8859-3 - Latin-3 - 6 => 'ISO-8859-4', - // ISO/IEC 8859-4 - Latin-4 - 7 => 'ISO-8859-5', - // ISO/IEC 8859-5 - Latin/Cyrillic - 8 => 'ISO-8859-6', - // ISO/IEC 8859-6 - Latin/Arabic - 9 => 'ISO-8859-7', - // ISO/IEC 8859-7 - Latin/Greek - 10 => 'ISO-8859-8', - // ISO/IEC 8859-8 - Latin/Hebrew - 11 => 'ISO-8859-9', - // ISO/IEC 8859-9 - Latin-5 - 12 => 'ISO-8859-10', - // ISO/IEC 8859-10 - Latin-6 - 13 => 'ISO-8859-11', - // ISO/IEC 8859-11 - Latin/Thai - 15 => 'ISO-8859-13', - // ISO/IEC 8859-13 - Latin-7 - 16 => 'ISO-8859-14', - // ISO/IEC 8859-14 - Latin-8 (Celtic) - 17 => 'ISO-8859-15', - // ISO/IEC 8859-15 - Latin-9 - 18 => 'ISO-8859-16', - // ISO/IEC 8859-16 - Latin-10 - 20 => 'Shift JIS', - // - 21 => 'Cp1250', - // Windows-1250 - Superset of Latin-2 - 22 => 'Cp1251', - // Windows-1251 - Latin/Cyrillic - 23 => 'Cp1252', - // Windows-1252 - Superset of Latin-1 - 24 => 'Cp1256', - // Windows-1256 - Arabic - 25 => 'UTF-16BE', - // UnicodeBig, UnicodeBigUnmarked - 26 => 'UTF-8', - // - 27 => 'US-ASCII', - // - 28 => 'Big5', - // - 29 => 'GB18030', - // GB2312, EUC_CN, GBK - 30 => 'EUC-KR', + 0 => 'FNC1', // Function 1 character + 2 => 'Cp437', // Code page 437 + 3 => 'ISO-8859-1', // ISO/IEC 8859-1 - Latin-1 (Default encoding) + 4 => 'ISO-8859-2', // ISO/IEC 8859-2 - Latin-2 + 5 => 'ISO-8859-3', // ISO/IEC 8859-3 - Latin-3 + 6 => 'ISO-8859-4', // ISO/IEC 8859-4 - Latin-4 + 7 => 'ISO-8859-5', // ISO/IEC 8859-5 - Latin/Cyrillic + 8 => 'ISO-8859-6', // ISO/IEC 8859-6 - Latin/Arabic + 9 => 'ISO-8859-7', // ISO/IEC 8859-7 - Latin/Greek + 10 => 'ISO-8859-8', // ISO/IEC 8859-8 - Latin/Hebrew + 11 => 'ISO-8859-9', // ISO/IEC 8859-9 - Latin-5 + 12 => 'ISO-8859-10', // ISO/IEC 8859-10 - Latin-6 + 13 => 'ISO-8859-11', // ISO/IEC 8859-11 - Latin/Thai + 15 => 'ISO-8859-13', // ISO/IEC 8859-13 - Latin-7 + 16 => 'ISO-8859-14', // ISO/IEC 8859-14 - Latin-8 (Celtic) + 17 => 'ISO-8859-15', // ISO/IEC 8859-15 - Latin-9 + 18 => 'ISO-8859-16', // ISO/IEC 8859-16 - Latin-10 + 20 => 'Shift JIS', // + 21 => 'Cp1250', // Windows-1250 - Superset of Latin-2 + 22 => 'Cp1251', // Windows-1251 - Latin/Cyrillic + 23 => 'Cp1252', // Windows-1252 - Superset of Latin-1 + 24 => 'Cp1256', // Windows-1256 - Arabic + 25 => 'UTF-16BE', // UnicodeBig, UnicodeBigUnmarked + 26 => 'UTF-8', // + 27 => 'US-ASCII', // + 28 => 'Big5', // + 29 => 'GB18030', // GB2312, EUC_CN, GBK + 30 => 'EUC-KR', // ]; /** diff --git a/src/Type/Square/QrCode/Data.php b/src/Type/Square/QrCode/Data.php index f96a3aef..2d8e0300 100644 --- a/src/Type/Square/QrCode/Data.php +++ b/src/Type/Square/QrCode/Data.php @@ -284,92 +284,57 @@ class Data */ public const CAPACITY = [ [0, 0, 0, [0, 0, 0, 0]], - // [21, 26, 0, [7, 10, 13, 17]], - // 1 [25, 44, 7, [10, 16, 22, 28]], - // [29, 70, 7, [15, 26, 36, 44]], - // [33, 100, 7, [20, 36, 52, 64]], - // [37, 134, 7, [26, 48, 72, 88]], - // 5 [41, 172, 7, [36, 64, 96, 112]], - // [45, 196, 0, [40, 72, 108, 130]], - // [49, 242, 0, [48, 88, 132, 156]], - // [53, 292, 0, [60, 110, 160, 192]], - // [57, 346, 0, [72, 130, 192, 224]], - // 10 [61, 404, 0, [80, 150, 224, 264]], - // [65, 466, 0, [96, 176, 260, 308]], - // [69, 532, 0, [104, 198, 288, 352]], - // [73, 581, 3, [120, 216, 320, 384]], - // [77, 655, 3, [132, 240, 360, 432]], - // 15 [81, 733, 3, [144, 280, 408, 480]], - // [85, 815, 3, [168, 308, 448, 532]], - // [89, 901, 3, [180, 338, 504, 588]], - // [93, 991, 3, [196, 364, 546, 650]], - // [97, 1085, 3, [224, 416, 600, 700]], - // 20 [101, 1156, 4, [224, 442, 644, 750]], - // [105, 1258, 4, [252, 476, 690, 816]], - // [109, 1364, 4, [270, 504, 750, 900]], - // [113, 1474, 4, [300, 560, 810, 960]], - // [117, 1588, 4, [312, 588, 870, 1050]], - // 25 [121, 1706, 4, [336, 644, 952, 1110]], - // [125, 1828, 4, [360, 700, 1020, 1200]], - // [129, 1921, 3, [390, 728, 1050, 1260]], - // [133, 2051, 3, [420, 784, 1140, 1350]], - // [137, 2185, 3, [450, 812, 1200, 1440]], - // 30 [141, 2323, 3, [480, 868, 1290, 1530]], - // [145, 2465, 3, [510, 924, 1350, 1620]], - // [149, 2611, 3, [540, 980, 1440, 1710]], - // [153, 2761, 3, [570, 1036, 1530, 1800]], - // [157, 2876, 0, [570, 1064, 1590, 1890]], - // 35 [161, 3034, 0, [600, 1120, 1680, 1980]], - // [165, 3196, 0, [630, 1204, 1770, 2100]], - // [169, 3362, 0, [660, 1260, 1860, 2220]], - // [173, 3532, 0, [720, 1316, 1950, 2310]], - // [177, 3706, 0, [750, 1372, 2040, 2430]], ]; /** * Array Length indicator. */ - public const LEN_TABLE_BITS = [[10, 12, 14], [9, 11, 13], [8, 16, 16], [8, 10, 12]]; + public const LEN_TABLE_BITS = [ + [10, 12, 14], + [9, 11, 13], + [8, 16, 16], + [8, 10, 12], + ]; /** * Array Table of the error correction code (Reed-Solomon block). @@ -377,85 +342,45 @@ class Data */ public const ECC_TABLE = [ [[0, 0], [0, 0], [0, 0], [0, 0]], - // [[1, 0], [1, 0], [1, 0], [1, 0]], - // 1 [[1, 0], [1, 0], [1, 0], [1, 0]], - // [[1, 0], [1, 0], [2, 0], [2, 0]], - // [[1, 0], [2, 0], [2, 0], [4, 0]], - // [[1, 0], [2, 0], [2, 2], [2, 2]], - // 5 [[2, 0], [4, 0], [4, 0], [4, 0]], - // [[2, 0], [4, 0], [2, 4], [4, 1]], - // [[2, 0], [2, 2], [4, 2], [4, 2]], - // [[2, 0], [3, 2], [4, 4], [4, 4]], - // [[2, 2], [4, 1], [6, 2], [6, 2]], - // 10 [[4, 0], [1, 4], [4, 4], [3, 8]], - // [[2, 2], [6, 2], [4, 6], [7, 4]], - // [[4, 0], [8, 1], [8, 4], [12, 4]], - // [[3, 1], [4, 5], [11, 5], [11, 5]], - // [[5, 1], [5, 5], [5, 7], [11, 7]], - // 15 [[5, 1], [7, 3], [15, 2], [3, 13]], - // [[1, 5], [10, 1], [1, 15], [2, 17]], - // [[5, 1], [9, 4], [17, 1], [2, 19]], - // [[3, 4], [3, 11], [17, 4], [9, 16]], - // [[3, 5], [3, 13], [15, 5], [15, 10]], - // 20 [[4, 4], [17, 0], [17, 6], [19, 6]], - // [[2, 7], [17, 0], [7, 16], [34, 0]], - // [[4, 5], [4, 14], [11, 14], [16, 14]], - // [[6, 4], [6, 14], [11, 16], [30, 2]], - // [[8, 4], [8, 13], [7, 22], [22, 13]], - // 25 [[10, 2], [19, 4], [28, 6], [33, 4]], - // [[8, 4], [22, 3], [8, 26], [12, 28]], - // [[3, 10], [3, 23], [4, 31], [11, 31]], - // [[7, 7], [21, 7], [1, 37], [19, 26]], - // [[5, 10], [19, 10], [15, 25], [23, 25]], - // 30 [[13, 3], [2, 29], [42, 1], [23, 28]], - // [[17, 0], [10, 23], [10, 35], [19, 35]], - // [[17, 1], [14, 21], [29, 19], [11, 46]], - // [[13, 6], [14, 23], [44, 7], [59, 1]], - // [[12, 7], [12, 26], [39, 14], [22, 41]], - // 35 [[6, 14], [6, 34], [46, 10], [2, 64]], - // [[17, 4], [29, 14], [49, 10], [24, 46]], - // [[4, 18], [13, 32], [48, 14], [42, 32]], - // [[20, 4], [40, 7], [43, 22], [10, 67]], - // [[19, 6], [18, 31], [34, 34], [20, 61]], ]; @@ -472,43 +397,36 @@ class Data [22, 0], [26, 0], [30, 0], - // 1- 5 [34, 0], [22, 38], [24, 42], [26, 46], [28, 50], - // 6-10 [30, 54], [32, 58], [34, 62], [26, 46], [26, 48], - // 11-15 [26, 50], [30, 54], [30, 56], [30, 58], [34, 62], - // 16-20 [28, 50], [26, 50], [30, 54], [28, 54], [32, 58], - // 21-25 [30, 58], [34, 62], [26, 50], [30, 54], [26, 52], - // 26-30 [30, 56], [34, 60], [30, 58], [34, 62], [30, 54], - // 31-35 [24, 50], [28, 54], [32, 58], @@ -530,7 +448,6 @@ class Data 0x0c762, 0x0d847, 0x0e60d, - // 0x0f928, 0x10b78, 0x1145d, @@ -539,7 +456,6 @@ class Data 0x149a6, 0x15683, 0x168c9, - // 0x177ec, 0x18ec4, 0x191e1, @@ -548,7 +464,6 @@ class Data 0x1cc1a, 0x1d33f, 0x1ed75, - // 0x1f250, 0x209d5, 0x216f0, @@ -557,7 +472,6 @@ class Data 0x24b0b, 0x2542e, 0x26a64, - // 0x27541, 0x28c69, ]; @@ -567,11 +481,8 @@ class Data */ public const FORMAT_INFO = [ [0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976], - // [0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0], - // [0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed], - // [0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b], ]; } From 435b5c00342948d4fa6581ce76f0d233a91a802a Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 15:44:51 +0000 Subject: [PATCH 095/100] data comments --- src/Type/Square/Aztec/Data.php | 28 + src/Type/Square/Datamatrix/Data.php | 26 +- src/Type/Square/PdfFourOneSeven/Data.php | 8625 +++++++++++----------- src/Type/Square/QrCode/Data.php | 44 +- 4 files changed, 4423 insertions(+), 4300 deletions(-) diff --git a/src/Type/Square/Aztec/Data.php b/src/Type/Square/Aztec/Data.php index a1edbcb6..284753ea 100644 --- a/src/Type/Square/Aztec/Data.php +++ b/src/Type/Square/Aztec/Data.php @@ -33,36 +33,50 @@ class Data { /** * Code character encoding mode for uppercase letters. + * + * @var int */ public const MODE_UPPER = 0; /** * Code character encoding mode for lowercase letters. + * + * @var int */ public const MODE_LOWER = 1; /** * Code character encoding mode for digits. + * + * @var int */ public const MODE_DIGIT = 2; /** * Code character encoding mode for mixed cases. + * + * @var int */ public const MODE_MIXED = 3; /** * Code character encoding mode for punctuation. + * + * @var int */ public const MODE_PUNCT = 4; /** * Code character encoding mode for binary. + * + * @var int */ public const MODE_BINARY = 5; /** * Number of bits for each character encoding mode. + * + * @var array */ public const MODE_BITS = [ 5, // 0 = MODE_UPPER @@ -75,6 +89,8 @@ class Data /** * Code character encoding for each mode. + * + * @var array> */ public const CHAR_ENC = [ // MODE_UPPER (initial mode) @@ -221,6 +237,8 @@ class Data * - the space ' ' character (32) that maps for modes 0,1,2. * - the carriage return '\r' character (13) that maps for modes 3,4. * - the comma ',' and dot '.' characters (44,46) that map for modes 2,4. + * + * @var array */ public const CHAR_MODES = [ 1 => 3, // '^A' (SOH) @@ -342,6 +360,8 @@ class Data /** * Latch map for changing character encoding mode. * Numbers represent: [number of bits to change, latch code value]. + * + * @var array>> */ public const LATCH_MAP = [ // MODE_UPPER @@ -384,6 +404,8 @@ class Data /** * Shift map for changing character encoding mode. * Numbers represent: [number of bits to change, shift code value]. + * + * @var array>> */ public const SHIFT_MAP = [ // MODE_UPPER @@ -430,6 +452,8 @@ class Data /** * Extended Channel Interpretation (ECI) codes. + * + * @var array */ public const ECI = [ 0 => 'FNC1', // Function 1 character @@ -472,6 +496,8 @@ class Data * - 4: symbol data digits capacity; * - 5: symbol data text capacity; * - 6: symbol data bytes capacity. + * + * @var array */ public const SIZE_COMPACT = [ 1 => [15, 17, 6, 102, 13, 12, 6], @@ -490,6 +516,8 @@ class Data * - 4: symbol data digits capacity; * - 5: symbol data text capacity; * - 6: symbol data bytes capacity. + * + * @var array */ public const SIZE_FULL = [ 1 => [19, 21, 6, 126, 18, 15, 8], diff --git a/src/Type/Square/Datamatrix/Data.php b/src/Type/Square/Datamatrix/Data.php index 24a99366..22560c80 100644 --- a/src/Type/Square/Datamatrix/Data.php +++ b/src/Type/Square/Datamatrix/Data.php @@ -35,41 +35,57 @@ class Data { /** * ASCII encoding: ASCII character 0 to 127 (1 byte per CW) + * + * @var int */ public const ENC_ASCII = 0; /** * C40 encoding: Upper-case alphanumeric (3/2 bytes per CW) + * + * @var int */ public const ENC_C40 = 1; /** * TEXT encoding: Lower-case alphanumeric (3/2 bytes per CW) + * + * @var int */ public const ENC_TXT = 2; /** * X12 encoding: ANSI X12 (3/2 byte per CW) + * + * @var int */ public const ENC_X12 = 3; /** * EDIFACT encoding: ASCII character 32 to 94 (4/3 bytes per CW) + * + * @var int */ public const ENC_EDF = 4; /** * BASE 256 encoding: ASCII character 0 to 255 (1 byte per CW) + * + * @var int */ public const ENC_BASE256 = 5; /** * ASCII extended encoding: ASCII character 128 to 255 (1/2 byte per CW) + * + * @var int */ public const ENC_ASCII_EXT = 6; /** * ASCII number encoding: ASCII digits (2 bytes per CW) + * + * @var int */ public const ENC_ASCII_NUM = 7; @@ -93,6 +109,8 @@ class Data *
  • data codewords per block
  • *
  • error codewords per block
  • * + * + * @var array> */ public const SYMBATTR = [ 'S' => [ @@ -675,6 +693,8 @@ class Data /** * Map encodation modes whit character sets. + * + * @var array */ public const CHSET_ID = [ self::ENC_C40 => 'C40', @@ -684,6 +704,8 @@ class Data /** * Basic set of characters for each encodation mode. + * + * @var array> */ public const CHSET = [ 'C40' => [ @@ -960,11 +982,11 @@ class Data * @param string $shape Shape. * @param int $ncw Number of codewords. * - * @return array params + * @return array{int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int} * * @throws BarcodeException in case of error */ - public static function getPaddingSize($shape, $ncw) + public static function getPaddingSize(string $shape, int $ncw): array { foreach (Data::SYMBATTR[$shape] as $params) { if ($params[11] >= $ncw) { diff --git a/src/Type/Square/PdfFourOneSeven/Data.php b/src/Type/Square/PdfFourOneSeven/Data.php index a33f8ddf..ec4b200e 100644 --- a/src/Type/Square/PdfFourOneSeven/Data.php +++ b/src/Type/Square/PdfFourOneSeven/Data.php @@ -35,149 +35,162 @@ abstract class Data { /** * Start pattern + * + * @var string */ public const START_PATTERN = '11111111010101000'; /** * Stop pattern + * + * @var string */ public const STOP_PATTERN = '111111101000101001'; /** * Array of text Compaction Sub-Modes (values 0xFB - 0xFF are used for submode changers) + * + * @var array> */ - public const TEXT_SUB_MODES = [[ - // Alpha - 0x41, - 0x42, - 0x43, - 0x44, - 0x45, - 0x46, - 0x47, - 0x48, - 0x49, - 0x4a, - 0x4b, - 0x4c, - 0x4d, - 0x4e, - 0x4f, - 0x50, - 0x51, - 0x52, - 0x53, - 0x54, - 0x55, - 0x56, - 0x57, - 0x58, - 0x59, - 0x5a, - 0x20, - 0xFD, - 0xFE, - 0xFF, - ], [ - // Lower - 0x61, - 0x62, - 0x63, - 0x64, - 0x65, - 0x66, - 0x67, - 0x68, - 0x69, - 0x6a, - 0x6b, - 0x6c, - 0x6d, - 0x6e, - 0x6f, - 0x70, - 0x71, - 0x72, - 0x73, - 0x74, - 0x75, - 0x76, - 0x77, - 0x78, - 0x79, - 0x7a, - 0x20, - 0xFD, - 0xFE, - 0xFF, - ], [ - // Mixed - 0x30, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x26, - 0x0d, - 0x09, - 0x2c, - 0x3a, - 0x23, - 0x2d, - 0x2e, - 0x24, - 0x2f, - 0x2b, - 0x25, - 0x2a, - 0x3d, - 0x5e, - 0xFB, - 0x20, - 0xFD, - 0xFE, - 0xFF, - ], [ - // Puntuaction - 0x3b, - 0x3c, - 0x3e, - 0x40, - 0x5b, - 0x5c, - 0x5d, - 0x5f, - 0x60, - 0x7e, - 0x21, - 0x0d, - 0x09, - 0x2c, - 0x3a, - 0x0a, - 0x2d, - 0x2e, - 0x24, - 0x2f, - 0x22, - 0x7c, - 0x2a, - 0x28, - 0x29, - 0x3f, - 0x7b, - 0x7d, - 0x27, - 0xFF, - ]]; + public const TEXT_SUB_MODES = [ + [ + // Alpha + 0x41, + 0x42, + 0x43, + 0x44, + 0x45, + 0x46, + 0x47, + 0x48, + 0x49, + 0x4a, + 0x4b, + 0x4c, + 0x4d, + 0x4e, + 0x4f, + 0x50, + 0x51, + 0x52, + 0x53, + 0x54, + 0x55, + 0x56, + 0x57, + 0x58, + 0x59, + 0x5a, + 0x20, + 0xFD, + 0xFE, + 0xFF, + ], + [ + // Lower + 0x61, + 0x62, + 0x63, + 0x64, + 0x65, + 0x66, + 0x67, + 0x68, + 0x69, + 0x6a, + 0x6b, + 0x6c, + 0x6d, + 0x6e, + 0x6f, + 0x70, + 0x71, + 0x72, + 0x73, + 0x74, + 0x75, + 0x76, + 0x77, + 0x78, + 0x79, + 0x7a, + 0x20, + 0xFD, + 0xFE, + 0xFF, + ], + [ + // Mixed + 0x30, + 0x31, + 0x32, + 0x33, + 0x34, + 0x35, + 0x36, + 0x37, + 0x38, + 0x39, + 0x26, + 0x0d, + 0x09, + 0x2c, + 0x3a, + 0x23, + 0x2d, + 0x2e, + 0x24, + 0x2f, + 0x2b, + 0x25, + 0x2a, + 0x3d, + 0x5e, + 0xFB, + 0x20, + 0xFD, + 0xFE, + 0xFF, + ], + [ + // Puntuaction + 0x3b, + 0x3c, + 0x3e, + 0x40, + 0x5b, + 0x5c, + 0x5d, + 0x5f, + 0x60, + 0x7e, + 0x21, + 0x0d, + 0x09, + 0x2c, + 0x3a, + 0x0a, + 0x2d, + 0x2e, + 0x24, + 0x2f, + 0x22, + 0x7c, + 0x2a, + 0x28, + 0x29, + 0x3f, + 0x7b, + 0x7d, + 0x27, + 0xFF, + ], + ]; /** * Array of switching codes for Text Compaction Sub-Modes + * + * @var array> */ public const TEXT_LATCH = [ '01' => [27], @@ -214,4178 +227,4196 @@ abstract class Data * 926 : Identifier for a general purpose ECI format * 927 : Identifier for an ECI of a character set or code page * 928 : Macro marker codeword to indicate the beginning of a Macro PDF Control Block + * + * @var array> */ - public const CLUSTERS = [[ - // cluster 0 ----------------------------------------------------------------------- - 0x1d5c0, - 0x1eaf0, - 0x1f57c, - 0x1d4e0, - 0x1ea78, - 0x1f53e, - 0x1a8c0, - 0x1d470, - 0x1a860, - 0x15040, - // 10 - 0x1a830, - 0x15020, - 0x1adc0, - 0x1d6f0, - 0x1eb7c, - 0x1ace0, - 0x1d678, - 0x1eb3e, - 0x158c0, - 0x1ac70, - // 20 - 0x15860, - 0x15dc0, - 0x1aef0, - 0x1d77c, - 0x15ce0, - 0x1ae78, - 0x1d73e, - 0x15c70, - 0x1ae3c, - 0x15ef0, - // 30 - 0x1af7c, - 0x15e78, - 0x1af3e, - 0x15f7c, - 0x1f5fa, - 0x1d2e0, - 0x1e978, - 0x1f4be, - 0x1a4c0, - 0x1d270, - // 40 - 0x1e93c, - 0x1a460, - 0x1d238, - 0x14840, - 0x1a430, - 0x1d21c, - 0x14820, - 0x1a418, - 0x14810, - 0x1a6e0, - // 50 - 0x1d378, - 0x1e9be, - 0x14cc0, - 0x1a670, - 0x1d33c, - 0x14c60, - 0x1a638, - 0x1d31e, - 0x14c30, - 0x1a61c, - // 60 - 0x14ee0, - 0x1a778, - 0x1d3be, - 0x14e70, - 0x1a73c, - 0x14e38, - 0x1a71e, - 0x14f78, - 0x1a7be, - 0x14f3c, - // 70 - 0x14f1e, - 0x1a2c0, - 0x1d170, - 0x1e8bc, - 0x1a260, - 0x1d138, - 0x1e89e, - 0x14440, - 0x1a230, - 0x1d11c, - // 80 - 0x14420, - 0x1a218, - 0x14410, - 0x14408, - 0x146c0, - 0x1a370, - 0x1d1bc, - 0x14660, - 0x1a338, - 0x1d19e, - // 90 - 0x14630, - 0x1a31c, - 0x14618, - 0x1460c, - 0x14770, - 0x1a3bc, - 0x14738, - 0x1a39e, - 0x1471c, - 0x147bc, - // 100 - 0x1a160, - 0x1d0b8, - 0x1e85e, - 0x14240, - 0x1a130, - 0x1d09c, - 0x14220, - 0x1a118, - 0x1d08e, - 0x14210, - // 110 - 0x1a10c, - 0x14208, - 0x1a106, - 0x14360, - 0x1a1b8, - 0x1d0de, - 0x14330, - 0x1a19c, - 0x14318, - 0x1a18e, - // 120 - 0x1430c, - 0x14306, - 0x1a1de, - 0x1438e, - 0x14140, - 0x1a0b0, - 0x1d05c, - 0x14120, - 0x1a098, - 0x1d04e, - // 130 - 0x14110, - 0x1a08c, - 0x14108, - 0x1a086, - 0x14104, - 0x141b0, - 0x14198, - 0x1418c, - 0x140a0, - 0x1d02e, - // 140 - 0x1a04c, - 0x1a046, - 0x14082, - 0x1cae0, - 0x1e578, - 0x1f2be, - 0x194c0, - 0x1ca70, - 0x1e53c, - 0x19460, - // 150 - 0x1ca38, - 0x1e51e, - 0x12840, - 0x19430, - 0x12820, - 0x196e0, - 0x1cb78, - 0x1e5be, - 0x12cc0, - 0x19670, - // 160 - 0x1cb3c, - 0x12c60, - 0x19638, - 0x12c30, - 0x12c18, - 0x12ee0, - 0x19778, - 0x1cbbe, - 0x12e70, - 0x1973c, - // 170 - 0x12e38, - 0x12e1c, - 0x12f78, - 0x197be, - 0x12f3c, - 0x12fbe, - 0x1dac0, - 0x1ed70, - 0x1f6bc, - 0x1da60, - // 180 - 0x1ed38, - 0x1f69e, - 0x1b440, - 0x1da30, - 0x1ed1c, - 0x1b420, - 0x1da18, - 0x1ed0e, - 0x1b410, - 0x1da0c, - // 190 - 0x192c0, - 0x1c970, - 0x1e4bc, - 0x1b6c0, - 0x19260, - 0x1c938, - 0x1e49e, - 0x1b660, - 0x1db38, - 0x1ed9e, - // 200 - 0x16c40, - 0x12420, - 0x19218, - 0x1c90e, - 0x16c20, - 0x1b618, - 0x16c10, - 0x126c0, - 0x19370, - 0x1c9bc, - // 210 - 0x16ec0, - 0x12660, - 0x19338, - 0x1c99e, - 0x16e60, - 0x1b738, - 0x1db9e, - 0x16e30, - 0x12618, - 0x16e18, - // 220 - 0x12770, - 0x193bc, - 0x16f70, - 0x12738, - 0x1939e, - 0x16f38, - 0x1b79e, - 0x16f1c, - 0x127bc, - 0x16fbc, - // 230 - 0x1279e, - 0x16f9e, - 0x1d960, - 0x1ecb8, - 0x1f65e, - 0x1b240, - 0x1d930, - 0x1ec9c, - 0x1b220, - 0x1d918, - // 240 - 0x1ec8e, - 0x1b210, - 0x1d90c, - 0x1b208, - 0x1b204, - 0x19160, - 0x1c8b8, - 0x1e45e, - 0x1b360, - 0x19130, - // 250 - 0x1c89c, - 0x16640, - 0x12220, - 0x1d99c, - 0x1c88e, - 0x16620, - 0x12210, - 0x1910c, - 0x16610, - 0x1b30c, - // 260 - 0x19106, - 0x12204, - 0x12360, - 0x191b8, - 0x1c8de, - 0x16760, - 0x12330, - 0x1919c, - 0x16730, - 0x1b39c, - // 270 - 0x1918e, - 0x16718, - 0x1230c, - 0x12306, - 0x123b8, - 0x191de, - 0x167b8, - 0x1239c, - 0x1679c, - 0x1238e, - // 280 - 0x1678e, - 0x167de, - 0x1b140, - 0x1d8b0, - 0x1ec5c, - 0x1b120, - 0x1d898, - 0x1ec4e, - 0x1b110, - 0x1d88c, - // 290 - 0x1b108, - 0x1d886, - 0x1b104, - 0x1b102, - 0x12140, - 0x190b0, - 0x1c85c, - 0x16340, - 0x12120, - 0x19098, - // 300 - 0x1c84e, - 0x16320, - 0x1b198, - 0x1d8ce, - 0x16310, - 0x12108, - 0x19086, - 0x16308, - 0x1b186, - 0x16304, - // 310 - 0x121b0, - 0x190dc, - 0x163b0, - 0x12198, - 0x190ce, - 0x16398, - 0x1b1ce, - 0x1638c, - 0x12186, - 0x16386, - // 320 - 0x163dc, - 0x163ce, - 0x1b0a0, - 0x1d858, - 0x1ec2e, - 0x1b090, - 0x1d84c, - 0x1b088, - 0x1d846, - 0x1b084, - // 330 - 0x1b082, - 0x120a0, - 0x19058, - 0x1c82e, - 0x161a0, - 0x12090, - 0x1904c, - 0x16190, - 0x1b0cc, - 0x19046, - // 340 - 0x16188, - 0x12084, - 0x16184, - 0x12082, - 0x120d8, - 0x161d8, - 0x161cc, - 0x161c6, - 0x1d82c, - 0x1d826, - // 350 - 0x1b042, - 0x1902c, - 0x12048, - 0x160c8, - 0x160c4, - 0x160c2, - 0x18ac0, - 0x1c570, - 0x1e2bc, - 0x18a60, - // 360 - 0x1c538, - 0x11440, - 0x18a30, - 0x1c51c, - 0x11420, - 0x18a18, - 0x11410, - 0x11408, - 0x116c0, - 0x18b70, - // 370 - 0x1c5bc, - 0x11660, - 0x18b38, - 0x1c59e, - 0x11630, - 0x18b1c, - 0x11618, - 0x1160c, - 0x11770, - 0x18bbc, - // 380 - 0x11738, - 0x18b9e, - 0x1171c, - 0x117bc, - 0x1179e, - 0x1cd60, - 0x1e6b8, - 0x1f35e, - 0x19a40, - 0x1cd30, - // 390 - 0x1e69c, - 0x19a20, - 0x1cd18, - 0x1e68e, - 0x19a10, - 0x1cd0c, - 0x19a08, - 0x1cd06, - 0x18960, - 0x1c4b8, - // 400 - 0x1e25e, - 0x19b60, - 0x18930, - 0x1c49c, - 0x13640, - 0x11220, - 0x1cd9c, - 0x1c48e, - 0x13620, - 0x19b18, - // 410 - 0x1890c, - 0x13610, - 0x11208, - 0x13608, - 0x11360, - 0x189b8, - 0x1c4de, - 0x13760, - 0x11330, - 0x1cdde, - // 420 - 0x13730, - 0x19b9c, - 0x1898e, - 0x13718, - 0x1130c, - 0x1370c, - 0x113b8, - 0x189de, - 0x137b8, - 0x1139c, - // 430 - 0x1379c, - 0x1138e, - 0x113de, - 0x137de, - 0x1dd40, - 0x1eeb0, - 0x1f75c, - 0x1dd20, - 0x1ee98, - 0x1f74e, - // 440 - 0x1dd10, - 0x1ee8c, - 0x1dd08, - 0x1ee86, - 0x1dd04, - 0x19940, - 0x1ccb0, - 0x1e65c, - 0x1bb40, - 0x19920, - // 450 - 0x1eedc, - 0x1e64e, - 0x1bb20, - 0x1dd98, - 0x1eece, - 0x1bb10, - 0x19908, - 0x1cc86, - 0x1bb08, - 0x1dd86, - // 460 - 0x19902, - 0x11140, - 0x188b0, - 0x1c45c, - 0x13340, - 0x11120, - 0x18898, - 0x1c44e, - 0x17740, - 0x13320, - // 470 - 0x19998, - 0x1ccce, - 0x17720, - 0x1bb98, - 0x1ddce, - 0x18886, - 0x17710, - 0x13308, - 0x19986, - 0x17708, - // 480 - 0x11102, - 0x111b0, - 0x188dc, - 0x133b0, - 0x11198, - 0x188ce, - 0x177b0, - 0x13398, - 0x199ce, - 0x17798, - // 490 - 0x1bbce, - 0x11186, - 0x13386, - 0x111dc, - 0x133dc, - 0x111ce, - 0x177dc, - 0x133ce, - 0x1dca0, - 0x1ee58, - // 500 - 0x1f72e, - 0x1dc90, - 0x1ee4c, - 0x1dc88, - 0x1ee46, - 0x1dc84, - 0x1dc82, - 0x198a0, - 0x1cc58, - 0x1e62e, - // 510 - 0x1b9a0, - 0x19890, - 0x1ee6e, - 0x1b990, - 0x1dccc, - 0x1cc46, - 0x1b988, - 0x19884, - 0x1b984, - 0x19882, - // 520 - 0x1b982, - 0x110a0, - 0x18858, - 0x1c42e, - 0x131a0, - 0x11090, - 0x1884c, - 0x173a0, - 0x13190, - 0x198cc, - // 530 - 0x18846, - 0x17390, - 0x1b9cc, - 0x11084, - 0x17388, - 0x13184, - 0x11082, - 0x13182, - 0x110d8, - 0x1886e, - // 540 - 0x131d8, - 0x110cc, - 0x173d8, - 0x131cc, - 0x110c6, - 0x173cc, - 0x131c6, - 0x110ee, - 0x173ee, - 0x1dc50, - // 550 - 0x1ee2c, - 0x1dc48, - 0x1ee26, - 0x1dc44, - 0x1dc42, - 0x19850, - 0x1cc2c, - 0x1b8d0, - 0x19848, - 0x1cc26, - // 560 - 0x1b8c8, - 0x1dc66, - 0x1b8c4, - 0x19842, - 0x1b8c2, - 0x11050, - 0x1882c, - 0x130d0, - 0x11048, - 0x18826, - // 570 - 0x171d0, - 0x130c8, - 0x19866, - 0x171c8, - 0x1b8e6, - 0x11042, - 0x171c4, - 0x130c2, - 0x171c2, - 0x130ec, - // 580 - 0x171ec, - 0x171e6, - 0x1ee16, - 0x1dc22, - 0x1cc16, - 0x19824, - 0x19822, - 0x11028, - 0x13068, - 0x170e8, - // 590 - 0x11022, - 0x13062, - 0x18560, - 0x10a40, - 0x18530, - 0x10a20, - 0x18518, - 0x1c28e, - 0x10a10, - 0x1850c, - // 600 - 0x10a08, - 0x18506, - 0x10b60, - 0x185b8, - 0x1c2de, - 0x10b30, - 0x1859c, - 0x10b18, - 0x1858e, - 0x10b0c, - // 610 - 0x10b06, - 0x10bb8, - 0x185de, - 0x10b9c, - 0x10b8e, - 0x10bde, - 0x18d40, - 0x1c6b0, - 0x1e35c, - 0x18d20, - // 620 - 0x1c698, - 0x18d10, - 0x1c68c, - 0x18d08, - 0x1c686, - 0x18d04, - 0x10940, - 0x184b0, - 0x1c25c, - 0x11b40, - // 630 - 0x10920, - 0x1c6dc, - 0x1c24e, - 0x11b20, - 0x18d98, - 0x1c6ce, - 0x11b10, - 0x10908, - 0x18486, - 0x11b08, - // 640 - 0x18d86, - 0x10902, - 0x109b0, - 0x184dc, - 0x11bb0, - 0x10998, - 0x184ce, - 0x11b98, - 0x18dce, - 0x11b8c, - // 650 - 0x10986, - 0x109dc, - 0x11bdc, - 0x109ce, - 0x11bce, - 0x1cea0, - 0x1e758, - 0x1f3ae, - 0x1ce90, - 0x1e74c, - // 660 - 0x1ce88, - 0x1e746, - 0x1ce84, - 0x1ce82, - 0x18ca0, - 0x1c658, - 0x19da0, - 0x18c90, - 0x1c64c, - 0x19d90, - // 670 - 0x1cecc, - 0x1c646, - 0x19d88, - 0x18c84, - 0x19d84, - 0x18c82, - 0x19d82, - 0x108a0, - 0x18458, - 0x119a0, - // 680 - 0x10890, - 0x1c66e, - 0x13ba0, - 0x11990, - 0x18ccc, - 0x18446, - 0x13b90, - 0x19dcc, - 0x10884, - 0x13b88, - // 690 - 0x11984, - 0x10882, - 0x11982, - 0x108d8, - 0x1846e, - 0x119d8, - 0x108cc, - 0x13bd8, - 0x119cc, - 0x108c6, - // 700 - 0x13bcc, - 0x119c6, - 0x108ee, - 0x119ee, - 0x13bee, - 0x1ef50, - 0x1f7ac, - 0x1ef48, - 0x1f7a6, - 0x1ef44, - // 710 - 0x1ef42, - 0x1ce50, - 0x1e72c, - 0x1ded0, - 0x1ef6c, - 0x1e726, - 0x1dec8, - 0x1ef66, - 0x1dec4, - 0x1ce42, - // 720 - 0x1dec2, - 0x18c50, - 0x1c62c, - 0x19cd0, - 0x18c48, - 0x1c626, - 0x1bdd0, - 0x19cc8, - 0x1ce66, - 0x1bdc8, - // 730 - 0x1dee6, - 0x18c42, - 0x1bdc4, - 0x19cc2, - 0x1bdc2, - 0x10850, - 0x1842c, - 0x118d0, - 0x10848, - 0x18426, - // 740 - 0x139d0, - 0x118c8, - 0x18c66, - 0x17bd0, - 0x139c8, - 0x19ce6, - 0x10842, - 0x17bc8, - 0x1bde6, - 0x118c2, - // 750 - 0x17bc4, - 0x1086c, - 0x118ec, - 0x10866, - 0x139ec, - 0x118e6, - 0x17bec, - 0x139e6, - 0x17be6, - 0x1ef28, - // 760 - 0x1f796, - 0x1ef24, - 0x1ef22, - 0x1ce28, - 0x1e716, - 0x1de68, - 0x1ef36, - 0x1de64, - 0x1ce22, - 0x1de62, - // 770 - 0x18c28, - 0x1c616, - 0x19c68, - 0x18c24, - 0x1bce8, - 0x19c64, - 0x18c22, - 0x1bce4, - 0x19c62, - 0x1bce2, - // 780 - 0x10828, - 0x18416, - 0x11868, - 0x18c36, - 0x138e8, - 0x11864, - 0x10822, - 0x179e8, - 0x138e4, - 0x11862, - // 790 - 0x179e4, - 0x138e2, - 0x179e2, - 0x11876, - 0x179f6, - 0x1ef12, - 0x1de34, - 0x1de32, - 0x19c34, - 0x1bc74, - // 800 - 0x1bc72, - 0x11834, - 0x13874, - 0x178f4, - 0x178f2, - 0x10540, - 0x10520, - 0x18298, - 0x10510, - 0x10508, - // 810 - 0x10504, - 0x105b0, - 0x10598, - 0x1058c, - 0x10586, - 0x105dc, - 0x105ce, - 0x186a0, - 0x18690, - 0x1c34c, - // 820 - 0x18688, - 0x1c346, - 0x18684, - 0x18682, - 0x104a0, - 0x18258, - 0x10da0, - 0x186d8, - 0x1824c, - 0x10d90, - // 830 - 0x186cc, - 0x10d88, - 0x186c6, - 0x10d84, - 0x10482, - 0x10d82, - 0x104d8, - 0x1826e, - 0x10dd8, - 0x186ee, - // 840 - 0x10dcc, - 0x104c6, - 0x10dc6, - 0x104ee, - 0x10dee, - 0x1c750, - 0x1c748, - 0x1c744, - 0x1c742, - 0x18650, - // 850 - 0x18ed0, - 0x1c76c, - 0x1c326, - 0x18ec8, - 0x1c766, - 0x18ec4, - 0x18642, - 0x18ec2, - 0x10450, - 0x10cd0, - // 860 - 0x10448, - 0x18226, - 0x11dd0, - 0x10cc8, - 0x10444, - 0x11dc8, - 0x10cc4, - 0x10442, - 0x11dc4, - 0x10cc2, - // 870 - 0x1046c, - 0x10cec, - 0x10466, - 0x11dec, - 0x10ce6, - 0x11de6, - 0x1e7a8, - 0x1e7a4, - 0x1e7a2, - 0x1c728, - // 880 - 0x1cf68, - 0x1e7b6, - 0x1cf64, - 0x1c722, - 0x1cf62, - 0x18628, - 0x1c316, - 0x18e68, - 0x1c736, - 0x19ee8, - // 890 - 0x18e64, - 0x18622, - 0x19ee4, - 0x18e62, - 0x19ee2, - 0x10428, - 0x18216, - 0x10c68, - 0x18636, - 0x11ce8, - // 900 - 0x10c64, - 0x10422, - 0x13de8, - 0x11ce4, - 0x10c62, - 0x13de4, - 0x11ce2, - 0x10436, - 0x10c76, - 0x11cf6, - // 910 - 0x13df6, - 0x1f7d4, - 0x1f7d2, - 0x1e794, - 0x1efb4, - 0x1e792, - 0x1efb2, - 0x1c714, - 0x1cf34, - 0x1c712, - // 920 - 0x1df74, - 0x1cf32, - 0x1df72, - 0x18614, - 0x18e34, - 0x18612, - 0x19e74, - 0x18e32, - 0x1bef4, - ], [ - // cluster 3 ----------------------------------------------------------------------- - 0x1f560, - 0x1fab8, - 0x1ea40, - 0x1f530, - 0x1fa9c, - 0x1ea20, - 0x1f518, - 0x1fa8e, - 0x1ea10, - 0x1f50c, - // 10 - 0x1ea08, - 0x1f506, - 0x1ea04, - 0x1eb60, - 0x1f5b8, - 0x1fade, - 0x1d640, - 0x1eb30, - 0x1f59c, - 0x1d620, - // 20 - 0x1eb18, - 0x1f58e, - 0x1d610, - 0x1eb0c, - 0x1d608, - 0x1eb06, - 0x1d604, - 0x1d760, - 0x1ebb8, - 0x1f5de, - // 30 - 0x1ae40, - 0x1d730, - 0x1eb9c, - 0x1ae20, - 0x1d718, - 0x1eb8e, - 0x1ae10, - 0x1d70c, - 0x1ae08, - 0x1d706, - // 40 - 0x1ae04, - 0x1af60, - 0x1d7b8, - 0x1ebde, - 0x15e40, - 0x1af30, - 0x1d79c, - 0x15e20, - 0x1af18, - 0x1d78e, - // 50 - 0x15e10, - 0x1af0c, - 0x15e08, - 0x1af06, - 0x15f60, - 0x1afb8, - 0x1d7de, - 0x15f30, - 0x1af9c, - 0x15f18, - // 60 - 0x1af8e, - 0x15f0c, - 0x15fb8, - 0x1afde, - 0x15f9c, - 0x15f8e, - 0x1e940, - 0x1f4b0, - 0x1fa5c, - 0x1e920, - // 70 - 0x1f498, - 0x1fa4e, - 0x1e910, - 0x1f48c, - 0x1e908, - 0x1f486, - 0x1e904, - 0x1e902, - 0x1d340, - 0x1e9b0, - // 80 - 0x1f4dc, - 0x1d320, - 0x1e998, - 0x1f4ce, - 0x1d310, - 0x1e98c, - 0x1d308, - 0x1e986, - 0x1d304, - 0x1d302, - // 90 - 0x1a740, - 0x1d3b0, - 0x1e9dc, - 0x1a720, - 0x1d398, - 0x1e9ce, - 0x1a710, - 0x1d38c, - 0x1a708, - 0x1d386, - // 100 - 0x1a704, - 0x1a702, - 0x14f40, - 0x1a7b0, - 0x1d3dc, - 0x14f20, - 0x1a798, - 0x1d3ce, - 0x14f10, - 0x1a78c, - // 110 - 0x14f08, - 0x1a786, - 0x14f04, - 0x14fb0, - 0x1a7dc, - 0x14f98, - 0x1a7ce, - 0x14f8c, - 0x14f86, - 0x14fdc, - // 120 - 0x14fce, - 0x1e8a0, - 0x1f458, - 0x1fa2e, - 0x1e890, - 0x1f44c, - 0x1e888, - 0x1f446, - 0x1e884, - 0x1e882, - // 130 - 0x1d1a0, - 0x1e8d8, - 0x1f46e, - 0x1d190, - 0x1e8cc, - 0x1d188, - 0x1e8c6, - 0x1d184, - 0x1d182, - 0x1a3a0, - // 140 - 0x1d1d8, - 0x1e8ee, - 0x1a390, - 0x1d1cc, - 0x1a388, - 0x1d1c6, - 0x1a384, - 0x1a382, - 0x147a0, - 0x1a3d8, - // 150 - 0x1d1ee, - 0x14790, - 0x1a3cc, - 0x14788, - 0x1a3c6, - 0x14784, - 0x14782, - 0x147d8, - 0x1a3ee, - 0x147cc, - // 160 - 0x147c6, - 0x147ee, - 0x1e850, - 0x1f42c, - 0x1e848, - 0x1f426, - 0x1e844, - 0x1e842, - 0x1d0d0, - 0x1e86c, - // 170 - 0x1d0c8, - 0x1e866, - 0x1d0c4, - 0x1d0c2, - 0x1a1d0, - 0x1d0ec, - 0x1a1c8, - 0x1d0e6, - 0x1a1c4, - 0x1a1c2, - // 180 - 0x143d0, - 0x1a1ec, - 0x143c8, - 0x1a1e6, - 0x143c4, - 0x143c2, - 0x143ec, - 0x143e6, - 0x1e828, - 0x1f416, - // 190 - 0x1e824, - 0x1e822, - 0x1d068, - 0x1e836, - 0x1d064, - 0x1d062, - 0x1a0e8, - 0x1d076, - 0x1a0e4, - 0x1a0e2, - // 200 - 0x141e8, - 0x1a0f6, - 0x141e4, - 0x141e2, - 0x1e814, - 0x1e812, - 0x1d034, - 0x1d032, - 0x1a074, - 0x1a072, - // 210 - 0x1e540, - 0x1f2b0, - 0x1f95c, - 0x1e520, - 0x1f298, - 0x1f94e, - 0x1e510, - 0x1f28c, - 0x1e508, - 0x1f286, - // 220 - 0x1e504, - 0x1e502, - 0x1cb40, - 0x1e5b0, - 0x1f2dc, - 0x1cb20, - 0x1e598, - 0x1f2ce, - 0x1cb10, - 0x1e58c, - // 230 - 0x1cb08, - 0x1e586, - 0x1cb04, - 0x1cb02, - 0x19740, - 0x1cbb0, - 0x1e5dc, - 0x19720, - 0x1cb98, - 0x1e5ce, - // 240 - 0x19710, - 0x1cb8c, - 0x19708, - 0x1cb86, - 0x19704, - 0x19702, - 0x12f40, - 0x197b0, - 0x1cbdc, - 0x12f20, - // 250 - 0x19798, - 0x1cbce, - 0x12f10, - 0x1978c, - 0x12f08, - 0x19786, - 0x12f04, - 0x12fb0, - 0x197dc, - 0x12f98, - // 260 - 0x197ce, - 0x12f8c, - 0x12f86, - 0x12fdc, - 0x12fce, - 0x1f6a0, - 0x1fb58, - 0x16bf0, - 0x1f690, - 0x1fb4c, - // 270 - 0x169f8, - 0x1f688, - 0x1fb46, - 0x168fc, - 0x1f684, - 0x1f682, - 0x1e4a0, - 0x1f258, - 0x1f92e, - 0x1eda0, - // 280 - 0x1e490, - 0x1fb6e, - 0x1ed90, - 0x1f6cc, - 0x1f246, - 0x1ed88, - 0x1e484, - 0x1ed84, - 0x1e482, - 0x1ed82, - // 290 - 0x1c9a0, - 0x1e4d8, - 0x1f26e, - 0x1dba0, - 0x1c990, - 0x1e4cc, - 0x1db90, - 0x1edcc, - 0x1e4c6, - 0x1db88, - // 300 - 0x1c984, - 0x1db84, - 0x1c982, - 0x1db82, - 0x193a0, - 0x1c9d8, - 0x1e4ee, - 0x1b7a0, - 0x19390, - 0x1c9cc, - // 310 - 0x1b790, - 0x1dbcc, - 0x1c9c6, - 0x1b788, - 0x19384, - 0x1b784, - 0x19382, - 0x1b782, - 0x127a0, - 0x193d8, - // 320 - 0x1c9ee, - 0x16fa0, - 0x12790, - 0x193cc, - 0x16f90, - 0x1b7cc, - 0x193c6, - 0x16f88, - 0x12784, - 0x16f84, - // 330 - 0x12782, - 0x127d8, - 0x193ee, - 0x16fd8, - 0x127cc, - 0x16fcc, - 0x127c6, - 0x16fc6, - 0x127ee, - 0x1f650, - // 340 - 0x1fb2c, - 0x165f8, - 0x1f648, - 0x1fb26, - 0x164fc, - 0x1f644, - 0x1647e, - 0x1f642, - 0x1e450, - 0x1f22c, - // 350 - 0x1ecd0, - 0x1e448, - 0x1f226, - 0x1ecc8, - 0x1f666, - 0x1ecc4, - 0x1e442, - 0x1ecc2, - 0x1c8d0, - 0x1e46c, - // 360 - 0x1d9d0, - 0x1c8c8, - 0x1e466, - 0x1d9c8, - 0x1ece6, - 0x1d9c4, - 0x1c8c2, - 0x1d9c2, - 0x191d0, - 0x1c8ec, - // 370 - 0x1b3d0, - 0x191c8, - 0x1c8e6, - 0x1b3c8, - 0x1d9e6, - 0x1b3c4, - 0x191c2, - 0x1b3c2, - 0x123d0, - 0x191ec, - // 380 - 0x167d0, - 0x123c8, - 0x191e6, - 0x167c8, - 0x1b3e6, - 0x167c4, - 0x123c2, - 0x167c2, - 0x123ec, - 0x167ec, - // 390 - 0x123e6, - 0x167e6, - 0x1f628, - 0x1fb16, - 0x162fc, - 0x1f624, - 0x1627e, - 0x1f622, - 0x1e428, - 0x1f216, - // 400 - 0x1ec68, - 0x1f636, - 0x1ec64, - 0x1e422, - 0x1ec62, - 0x1c868, - 0x1e436, - 0x1d8e8, - 0x1c864, - 0x1d8e4, - // 410 - 0x1c862, - 0x1d8e2, - 0x190e8, - 0x1c876, - 0x1b1e8, - 0x1d8f6, - 0x1b1e4, - 0x190e2, - 0x1b1e2, - 0x121e8, - // 420 - 0x190f6, - 0x163e8, - 0x121e4, - 0x163e4, - 0x121e2, - 0x163e2, - 0x121f6, - 0x163f6, - 0x1f614, - 0x1617e, - // 430 - 0x1f612, - 0x1e414, - 0x1ec34, - 0x1e412, - 0x1ec32, - 0x1c834, - 0x1d874, - 0x1c832, - 0x1d872, - 0x19074, - // 440 - 0x1b0f4, - 0x19072, - 0x1b0f2, - 0x120f4, - 0x161f4, - 0x120f2, - 0x161f2, - 0x1f60a, - 0x1e40a, - 0x1ec1a, - // 450 - 0x1c81a, - 0x1d83a, - 0x1903a, - 0x1b07a, - 0x1e2a0, - 0x1f158, - 0x1f8ae, - 0x1e290, - 0x1f14c, - 0x1e288, - // 460 - 0x1f146, - 0x1e284, - 0x1e282, - 0x1c5a0, - 0x1e2d8, - 0x1f16e, - 0x1c590, - 0x1e2cc, - 0x1c588, - 0x1e2c6, - // 470 - 0x1c584, - 0x1c582, - 0x18ba0, - 0x1c5d8, - 0x1e2ee, - 0x18b90, - 0x1c5cc, - 0x18b88, - 0x1c5c6, - 0x18b84, - // 480 - 0x18b82, - 0x117a0, - 0x18bd8, - 0x1c5ee, - 0x11790, - 0x18bcc, - 0x11788, - 0x18bc6, - 0x11784, - 0x11782, - // 490 - 0x117d8, - 0x18bee, - 0x117cc, - 0x117c6, - 0x117ee, - 0x1f350, - 0x1f9ac, - 0x135f8, - 0x1f348, - 0x1f9a6, - // 500 - 0x134fc, - 0x1f344, - 0x1347e, - 0x1f342, - 0x1e250, - 0x1f12c, - 0x1e6d0, - 0x1e248, - 0x1f126, - 0x1e6c8, - // 510 - 0x1f366, - 0x1e6c4, - 0x1e242, - 0x1e6c2, - 0x1c4d0, - 0x1e26c, - 0x1cdd0, - 0x1c4c8, - 0x1e266, - 0x1cdc8, - // 520 - 0x1e6e6, - 0x1cdc4, - 0x1c4c2, - 0x1cdc2, - 0x189d0, - 0x1c4ec, - 0x19bd0, - 0x189c8, - 0x1c4e6, - 0x19bc8, - // 530 - 0x1cde6, - 0x19bc4, - 0x189c2, - 0x19bc2, - 0x113d0, - 0x189ec, - 0x137d0, - 0x113c8, - 0x189e6, - 0x137c8, - // 540 - 0x19be6, - 0x137c4, - 0x113c2, - 0x137c2, - 0x113ec, - 0x137ec, - 0x113e6, - 0x137e6, - 0x1fba8, - 0x175f0, - // 550 - 0x1bafc, - 0x1fba4, - 0x174f8, - 0x1ba7e, - 0x1fba2, - 0x1747c, - 0x1743e, - 0x1f328, - 0x1f996, - 0x132fc, - // 560 - 0x1f768, - 0x1fbb6, - 0x176fc, - 0x1327e, - 0x1f764, - 0x1f322, - 0x1767e, - 0x1f762, - 0x1e228, - 0x1f116, - // 570 - 0x1e668, - 0x1e224, - 0x1eee8, - 0x1f776, - 0x1e222, - 0x1eee4, - 0x1e662, - 0x1eee2, - 0x1c468, - 0x1e236, - // 580 - 0x1cce8, - 0x1c464, - 0x1dde8, - 0x1cce4, - 0x1c462, - 0x1dde4, - 0x1cce2, - 0x1dde2, - 0x188e8, - 0x1c476, - // 590 - 0x199e8, - 0x188e4, - 0x1bbe8, - 0x199e4, - 0x188e2, - 0x1bbe4, - 0x199e2, - 0x1bbe2, - 0x111e8, - 0x188f6, - // 600 - 0x133e8, - 0x111e4, - 0x177e8, - 0x133e4, - 0x111e2, - 0x177e4, - 0x133e2, - 0x177e2, - 0x111f6, - 0x133f6, - // 610 - 0x1fb94, - 0x172f8, - 0x1b97e, - 0x1fb92, - 0x1727c, - 0x1723e, - 0x1f314, - 0x1317e, - 0x1f734, - 0x1f312, - // 620 - 0x1737e, - 0x1f732, - 0x1e214, - 0x1e634, - 0x1e212, - 0x1ee74, - 0x1e632, - 0x1ee72, - 0x1c434, - 0x1cc74, - // 630 - 0x1c432, - 0x1dcf4, - 0x1cc72, - 0x1dcf2, - 0x18874, - 0x198f4, - 0x18872, - 0x1b9f4, - 0x198f2, - 0x1b9f2, - // 640 - 0x110f4, - 0x131f4, - 0x110f2, - 0x173f4, - 0x131f2, - 0x173f2, - 0x1fb8a, - 0x1717c, - 0x1713e, - 0x1f30a, - // 650 - 0x1f71a, - 0x1e20a, - 0x1e61a, - 0x1ee3a, - 0x1c41a, - 0x1cc3a, - 0x1dc7a, - 0x1883a, - 0x1987a, - 0x1b8fa, - // 660 - 0x1107a, - 0x130fa, - 0x171fa, - 0x170be, - 0x1e150, - 0x1f0ac, - 0x1e148, - 0x1f0a6, - 0x1e144, - 0x1e142, - // 670 - 0x1c2d0, - 0x1e16c, - 0x1c2c8, - 0x1e166, - 0x1c2c4, - 0x1c2c2, - 0x185d0, - 0x1c2ec, - 0x185c8, - 0x1c2e6, - // 680 - 0x185c4, - 0x185c2, - 0x10bd0, - 0x185ec, - 0x10bc8, - 0x185e6, - 0x10bc4, - 0x10bc2, - 0x10bec, - 0x10be6, - // 690 - 0x1f1a8, - 0x1f8d6, - 0x11afc, - 0x1f1a4, - 0x11a7e, - 0x1f1a2, - 0x1e128, - 0x1f096, - 0x1e368, - 0x1e124, - // 700 - 0x1e364, - 0x1e122, - 0x1e362, - 0x1c268, - 0x1e136, - 0x1c6e8, - 0x1c264, - 0x1c6e4, - 0x1c262, - 0x1c6e2, - // 710 - 0x184e8, - 0x1c276, - 0x18de8, - 0x184e4, - 0x18de4, - 0x184e2, - 0x18de2, - 0x109e8, - 0x184f6, - 0x11be8, - // 720 - 0x109e4, - 0x11be4, - 0x109e2, - 0x11be2, - 0x109f6, - 0x11bf6, - 0x1f9d4, - 0x13af8, - 0x19d7e, - 0x1f9d2, - // 730 - 0x13a7c, - 0x13a3e, - 0x1f194, - 0x1197e, - 0x1f3b4, - 0x1f192, - 0x13b7e, - 0x1f3b2, - 0x1e114, - 0x1e334, - // 740 - 0x1e112, - 0x1e774, - 0x1e332, - 0x1e772, - 0x1c234, - 0x1c674, - 0x1c232, - 0x1cef4, - 0x1c672, - 0x1cef2, - // 750 - 0x18474, - 0x18cf4, - 0x18472, - 0x19df4, - 0x18cf2, - 0x19df2, - 0x108f4, - 0x119f4, - 0x108f2, - 0x13bf4, - // 760 - 0x119f2, - 0x13bf2, - 0x17af0, - 0x1bd7c, - 0x17a78, - 0x1bd3e, - 0x17a3c, - 0x17a1e, - 0x1f9ca, - 0x1397c, - // 770 - 0x1fbda, - 0x17b7c, - 0x1393e, - 0x17b3e, - 0x1f18a, - 0x1f39a, - 0x1f7ba, - 0x1e10a, - 0x1e31a, - 0x1e73a, - // 780 - 0x1ef7a, - 0x1c21a, - 0x1c63a, - 0x1ce7a, - 0x1defa, - 0x1843a, - 0x18c7a, - 0x19cfa, - 0x1bdfa, - 0x1087a, - // 790 - 0x118fa, - 0x139fa, - 0x17978, - 0x1bcbe, - 0x1793c, - 0x1791e, - 0x138be, - 0x179be, - 0x178bc, - 0x1789e, - // 800 - 0x1785e, - 0x1e0a8, - 0x1e0a4, - 0x1e0a2, - 0x1c168, - 0x1e0b6, - 0x1c164, - 0x1c162, - 0x182e8, - 0x1c176, - // 810 - 0x182e4, - 0x182e2, - 0x105e8, - 0x182f6, - 0x105e4, - 0x105e2, - 0x105f6, - 0x1f0d4, - 0x10d7e, - 0x1f0d2, - // 820 - 0x1e094, - 0x1e1b4, - 0x1e092, - 0x1e1b2, - 0x1c134, - 0x1c374, - 0x1c132, - 0x1c372, - 0x18274, - 0x186f4, - // 830 - 0x18272, - 0x186f2, - 0x104f4, - 0x10df4, - 0x104f2, - 0x10df2, - 0x1f8ea, - 0x11d7c, - 0x11d3e, - 0x1f0ca, - // 840 - 0x1f1da, - 0x1e08a, - 0x1e19a, - 0x1e3ba, - 0x1c11a, - 0x1c33a, - 0x1c77a, - 0x1823a, - 0x1867a, - 0x18efa, - // 850 - 0x1047a, - 0x10cfa, - 0x11dfa, - 0x13d78, - 0x19ebe, - 0x13d3c, - 0x13d1e, - 0x11cbe, - 0x13dbe, - 0x17d70, - // 860 - 0x1bebc, - 0x17d38, - 0x1be9e, - 0x17d1c, - 0x17d0e, - 0x13cbc, - 0x17dbc, - 0x13c9e, - 0x17d9e, - 0x17cb8, - // 870 - 0x1be5e, - 0x17c9c, - 0x17c8e, - 0x13c5e, - 0x17cde, - 0x17c5c, - 0x17c4e, - 0x17c2e, - 0x1c0b4, - 0x1c0b2, - // 880 - 0x18174, - 0x18172, - 0x102f4, - 0x102f2, - 0x1e0da, - 0x1c09a, - 0x1c1ba, - 0x1813a, - 0x1837a, - 0x1027a, - // 890 - 0x106fa, - 0x10ebe, - 0x11ebc, - 0x11e9e, - 0x13eb8, - 0x19f5e, - 0x13e9c, - 0x13e8e, - 0x11e5e, - 0x13ede, - // 900 - 0x17eb0, - 0x1bf5c, - 0x17e98, - 0x1bf4e, - 0x17e8c, - 0x17e86, - 0x13e5c, - 0x17edc, - 0x13e4e, - 0x17ece, - // 910 - 0x17e58, - 0x1bf2e, - 0x17e4c, - 0x17e46, - 0x13e2e, - 0x17e6e, - 0x17e2c, - 0x17e26, - 0x10f5e, - 0x11f5c, - // 920 - 0x11f4e, - 0x13f58, - 0x19fae, - 0x13f4c, - 0x13f46, - 0x11f2e, - 0x13f6e, - 0x13f2c, - 0x13f26, - ], [ - // cluster 6 ----------------------------------------------------------------------- - 0x1abe0, - 0x1d5f8, - 0x153c0, - 0x1a9f0, - 0x1d4fc, - 0x151e0, - 0x1a8f8, - 0x1d47e, - 0x150f0, - 0x1a87c, - // 10 - 0x15078, - 0x1fad0, - 0x15be0, - 0x1adf8, - 0x1fac8, - 0x159f0, - 0x1acfc, - 0x1fac4, - 0x158f8, - 0x1ac7e, - // 20 - 0x1fac2, - 0x1587c, - 0x1f5d0, - 0x1faec, - 0x15df8, - 0x1f5c8, - 0x1fae6, - 0x15cfc, - 0x1f5c4, - 0x15c7e, - // 30 - 0x1f5c2, - 0x1ebd0, - 0x1f5ec, - 0x1ebc8, - 0x1f5e6, - 0x1ebc4, - 0x1ebc2, - 0x1d7d0, - 0x1ebec, - 0x1d7c8, - // 40 - 0x1ebe6, - 0x1d7c4, - 0x1d7c2, - 0x1afd0, - 0x1d7ec, - 0x1afc8, - 0x1d7e6, - 0x1afc4, - 0x14bc0, - 0x1a5f0, - // 50 - 0x1d2fc, - 0x149e0, - 0x1a4f8, - 0x1d27e, - 0x148f0, - 0x1a47c, - 0x14878, - 0x1a43e, - 0x1483c, - 0x1fa68, - // 60 - 0x14df0, - 0x1a6fc, - 0x1fa64, - 0x14cf8, - 0x1a67e, - 0x1fa62, - 0x14c7c, - 0x14c3e, - 0x1f4e8, - 0x1fa76, - // 70 - 0x14efc, - 0x1f4e4, - 0x14e7e, - 0x1f4e2, - 0x1e9e8, - 0x1f4f6, - 0x1e9e4, - 0x1e9e2, - 0x1d3e8, - 0x1e9f6, - // 80 - 0x1d3e4, - 0x1d3e2, - 0x1a7e8, - 0x1d3f6, - 0x1a7e4, - 0x1a7e2, - 0x145e0, - 0x1a2f8, - 0x1d17e, - 0x144f0, - // 90 - 0x1a27c, - 0x14478, - 0x1a23e, - 0x1443c, - 0x1441e, - 0x1fa34, - 0x146f8, - 0x1a37e, - 0x1fa32, - 0x1467c, - // 100 - 0x1463e, - 0x1f474, - 0x1477e, - 0x1f472, - 0x1e8f4, - 0x1e8f2, - 0x1d1f4, - 0x1d1f2, - 0x1a3f4, - 0x1a3f2, - // 110 - 0x142f0, - 0x1a17c, - 0x14278, - 0x1a13e, - 0x1423c, - 0x1421e, - 0x1fa1a, - 0x1437c, - 0x1433e, - 0x1f43a, - // 120 - 0x1e87a, - 0x1d0fa, - 0x14178, - 0x1a0be, - 0x1413c, - 0x1411e, - 0x141be, - 0x140bc, - 0x1409e, - 0x12bc0, - // 130 - 0x195f0, - 0x1cafc, - 0x129e0, - 0x194f8, - 0x1ca7e, - 0x128f0, - 0x1947c, - 0x12878, - 0x1943e, - 0x1283c, - // 140 - 0x1f968, - 0x12df0, - 0x196fc, - 0x1f964, - 0x12cf8, - 0x1967e, - 0x1f962, - 0x12c7c, - 0x12c3e, - 0x1f2e8, - // 150 - 0x1f976, - 0x12efc, - 0x1f2e4, - 0x12e7e, - 0x1f2e2, - 0x1e5e8, - 0x1f2f6, - 0x1e5e4, - 0x1e5e2, - 0x1cbe8, - // 160 - 0x1e5f6, - 0x1cbe4, - 0x1cbe2, - 0x197e8, - 0x1cbf6, - 0x197e4, - 0x197e2, - 0x1b5e0, - 0x1daf8, - 0x1ed7e, - // 170 - 0x169c0, - 0x1b4f0, - 0x1da7c, - 0x168e0, - 0x1b478, - 0x1da3e, - 0x16870, - 0x1b43c, - 0x16838, - 0x1b41e, - // 180 - 0x1681c, - 0x125e0, - 0x192f8, - 0x1c97e, - 0x16de0, - 0x124f0, - 0x1927c, - 0x16cf0, - 0x1b67c, - 0x1923e, - // 190 - 0x16c78, - 0x1243c, - 0x16c3c, - 0x1241e, - 0x16c1e, - 0x1f934, - 0x126f8, - 0x1937e, - 0x1fb74, - 0x1f932, - // 200 - 0x16ef8, - 0x1267c, - 0x1fb72, - 0x16e7c, - 0x1263e, - 0x16e3e, - 0x1f274, - 0x1277e, - 0x1f6f4, - 0x1f272, - // 210 - 0x16f7e, - 0x1f6f2, - 0x1e4f4, - 0x1edf4, - 0x1e4f2, - 0x1edf2, - 0x1c9f4, - 0x1dbf4, - 0x1c9f2, - 0x1dbf2, - // 220 - 0x193f4, - 0x193f2, - 0x165c0, - 0x1b2f0, - 0x1d97c, - 0x164e0, - 0x1b278, - 0x1d93e, - 0x16470, - 0x1b23c, - // 230 - 0x16438, - 0x1b21e, - 0x1641c, - 0x1640e, - 0x122f0, - 0x1917c, - 0x166f0, - 0x12278, - 0x1913e, - 0x16678, - // 240 - 0x1b33e, - 0x1663c, - 0x1221e, - 0x1661e, - 0x1f91a, - 0x1237c, - 0x1fb3a, - 0x1677c, - 0x1233e, - 0x1673e, - // 250 - 0x1f23a, - 0x1f67a, - 0x1e47a, - 0x1ecfa, - 0x1c8fa, - 0x1d9fa, - 0x191fa, - 0x162e0, - 0x1b178, - 0x1d8be, - // 260 - 0x16270, - 0x1b13c, - 0x16238, - 0x1b11e, - 0x1621c, - 0x1620e, - 0x12178, - 0x190be, - 0x16378, - 0x1213c, - // 270 - 0x1633c, - 0x1211e, - 0x1631e, - 0x121be, - 0x163be, - 0x16170, - 0x1b0bc, - 0x16138, - 0x1b09e, - 0x1611c, - // 280 - 0x1610e, - 0x120bc, - 0x161bc, - 0x1209e, - 0x1619e, - 0x160b8, - 0x1b05e, - 0x1609c, - 0x1608e, - 0x1205e, - // 290 - 0x160de, - 0x1605c, - 0x1604e, - 0x115e0, - 0x18af8, - 0x1c57e, - 0x114f0, - 0x18a7c, - 0x11478, - 0x18a3e, - // 300 - 0x1143c, - 0x1141e, - 0x1f8b4, - 0x116f8, - 0x18b7e, - 0x1f8b2, - 0x1167c, - 0x1163e, - 0x1f174, - 0x1177e, - // 310 - 0x1f172, - 0x1e2f4, - 0x1e2f2, - 0x1c5f4, - 0x1c5f2, - 0x18bf4, - 0x18bf2, - 0x135c0, - 0x19af0, - 0x1cd7c, - // 320 - 0x134e0, - 0x19a78, - 0x1cd3e, - 0x13470, - 0x19a3c, - 0x13438, - 0x19a1e, - 0x1341c, - 0x1340e, - 0x112f0, - // 330 - 0x1897c, - 0x136f0, - 0x11278, - 0x1893e, - 0x13678, - 0x19b3e, - 0x1363c, - 0x1121e, - 0x1361e, - 0x1f89a, - // 340 - 0x1137c, - 0x1f9ba, - 0x1377c, - 0x1133e, - 0x1373e, - 0x1f13a, - 0x1f37a, - 0x1e27a, - 0x1e6fa, - 0x1c4fa, - // 350 - 0x1cdfa, - 0x189fa, - 0x1bae0, - 0x1dd78, - 0x1eebe, - 0x174c0, - 0x1ba70, - 0x1dd3c, - 0x17460, - 0x1ba38, - // 360 - 0x1dd1e, - 0x17430, - 0x1ba1c, - 0x17418, - 0x1ba0e, - 0x1740c, - 0x132e0, - 0x19978, - 0x1ccbe, - 0x176e0, - // 370 - 0x13270, - 0x1993c, - 0x17670, - 0x1bb3c, - 0x1991e, - 0x17638, - 0x1321c, - 0x1761c, - 0x1320e, - 0x1760e, - // 380 - 0x11178, - 0x188be, - 0x13378, - 0x1113c, - 0x17778, - 0x1333c, - 0x1111e, - 0x1773c, - 0x1331e, - 0x1771e, - // 390 - 0x111be, - 0x133be, - 0x177be, - 0x172c0, - 0x1b970, - 0x1dcbc, - 0x17260, - 0x1b938, - 0x1dc9e, - 0x17230, - // 400 - 0x1b91c, - 0x17218, - 0x1b90e, - 0x1720c, - 0x17206, - 0x13170, - 0x198bc, - 0x17370, - 0x13138, - 0x1989e, - // 410 - 0x17338, - 0x1b99e, - 0x1731c, - 0x1310e, - 0x1730e, - 0x110bc, - 0x131bc, - 0x1109e, - 0x173bc, - 0x1319e, - // 420 - 0x1739e, - 0x17160, - 0x1b8b8, - 0x1dc5e, - 0x17130, - 0x1b89c, - 0x17118, - 0x1b88e, - 0x1710c, - 0x17106, - // 430 - 0x130b8, - 0x1985e, - 0x171b8, - 0x1309c, - 0x1719c, - 0x1308e, - 0x1718e, - 0x1105e, - 0x130de, - 0x171de, - // 440 - 0x170b0, - 0x1b85c, - 0x17098, - 0x1b84e, - 0x1708c, - 0x17086, - 0x1305c, - 0x170dc, - 0x1304e, - 0x170ce, - // 450 - 0x17058, - 0x1b82e, - 0x1704c, - 0x17046, - 0x1302e, - 0x1706e, - 0x1702c, - 0x17026, - 0x10af0, - 0x1857c, - // 460 - 0x10a78, - 0x1853e, - 0x10a3c, - 0x10a1e, - 0x10b7c, - 0x10b3e, - 0x1f0ba, - 0x1e17a, - 0x1c2fa, - 0x185fa, - // 470 - 0x11ae0, - 0x18d78, - 0x1c6be, - 0x11a70, - 0x18d3c, - 0x11a38, - 0x18d1e, - 0x11a1c, - 0x11a0e, - 0x10978, - // 480 - 0x184be, - 0x11b78, - 0x1093c, - 0x11b3c, - 0x1091e, - 0x11b1e, - 0x109be, - 0x11bbe, - 0x13ac0, - 0x19d70, - // 490 - 0x1cebc, - 0x13a60, - 0x19d38, - 0x1ce9e, - 0x13a30, - 0x19d1c, - 0x13a18, - 0x19d0e, - 0x13a0c, - 0x13a06, - // 500 - 0x11970, - 0x18cbc, - 0x13b70, - 0x11938, - 0x18c9e, - 0x13b38, - 0x1191c, - 0x13b1c, - 0x1190e, - 0x13b0e, - // 510 - 0x108bc, - 0x119bc, - 0x1089e, - 0x13bbc, - 0x1199e, - 0x13b9e, - 0x1bd60, - 0x1deb8, - 0x1ef5e, - 0x17a40, - // 520 - 0x1bd30, - 0x1de9c, - 0x17a20, - 0x1bd18, - 0x1de8e, - 0x17a10, - 0x1bd0c, - 0x17a08, - 0x1bd06, - 0x17a04, - // 530 - 0x13960, - 0x19cb8, - 0x1ce5e, - 0x17b60, - 0x13930, - 0x19c9c, - 0x17b30, - 0x1bd9c, - 0x19c8e, - 0x17b18, - // 540 - 0x1390c, - 0x17b0c, - 0x13906, - 0x17b06, - 0x118b8, - 0x18c5e, - 0x139b8, - 0x1189c, - 0x17bb8, - 0x1399c, - // 550 - 0x1188e, - 0x17b9c, - 0x1398e, - 0x17b8e, - 0x1085e, - 0x118de, - 0x139de, - 0x17bde, - 0x17940, - 0x1bcb0, - // 560 - 0x1de5c, - 0x17920, - 0x1bc98, - 0x1de4e, - 0x17910, - 0x1bc8c, - 0x17908, - 0x1bc86, - 0x17904, - 0x17902, - // 570 - 0x138b0, - 0x19c5c, - 0x179b0, - 0x13898, - 0x19c4e, - 0x17998, - 0x1bcce, - 0x1798c, - 0x13886, - 0x17986, - // 580 - 0x1185c, - 0x138dc, - 0x1184e, - 0x179dc, - 0x138ce, - 0x179ce, - 0x178a0, - 0x1bc58, - 0x1de2e, - 0x17890, - // 590 - 0x1bc4c, - 0x17888, - 0x1bc46, - 0x17884, - 0x17882, - 0x13858, - 0x19c2e, - 0x178d8, - 0x1384c, - 0x178cc, - // 600 - 0x13846, - 0x178c6, - 0x1182e, - 0x1386e, - 0x178ee, - 0x17850, - 0x1bc2c, - 0x17848, - 0x1bc26, - 0x17844, - // 610 - 0x17842, - 0x1382c, - 0x1786c, - 0x13826, - 0x17866, - 0x17828, - 0x1bc16, - 0x17824, - 0x17822, - 0x13816, - // 620 - 0x17836, - 0x10578, - 0x182be, - 0x1053c, - 0x1051e, - 0x105be, - 0x10d70, - 0x186bc, - 0x10d38, - 0x1869e, - // 630 - 0x10d1c, - 0x10d0e, - 0x104bc, - 0x10dbc, - 0x1049e, - 0x10d9e, - 0x11d60, - 0x18eb8, - 0x1c75e, - 0x11d30, - // 640 - 0x18e9c, - 0x11d18, - 0x18e8e, - 0x11d0c, - 0x11d06, - 0x10cb8, - 0x1865e, - 0x11db8, - 0x10c9c, - 0x11d9c, - // 650 - 0x10c8e, - 0x11d8e, - 0x1045e, - 0x10cde, - 0x11dde, - 0x13d40, - 0x19eb0, - 0x1cf5c, - 0x13d20, - 0x19e98, - // 660 - 0x1cf4e, - 0x13d10, - 0x19e8c, - 0x13d08, - 0x19e86, - 0x13d04, - 0x13d02, - 0x11cb0, - 0x18e5c, - 0x13db0, - // 670 - 0x11c98, - 0x18e4e, - 0x13d98, - 0x19ece, - 0x13d8c, - 0x11c86, - 0x13d86, - 0x10c5c, - 0x11cdc, - 0x10c4e, - // 680 - 0x13ddc, - 0x11cce, - 0x13dce, - 0x1bea0, - 0x1df58, - 0x1efae, - 0x1be90, - 0x1df4c, - 0x1be88, - 0x1df46, - // 690 - 0x1be84, - 0x1be82, - 0x13ca0, - 0x19e58, - 0x1cf2e, - 0x17da0, - 0x13c90, - 0x19e4c, - 0x17d90, - 0x1becc, - // 700 - 0x19e46, - 0x17d88, - 0x13c84, - 0x17d84, - 0x13c82, - 0x17d82, - 0x11c58, - 0x18e2e, - 0x13cd8, - 0x11c4c, - // 710 - 0x17dd8, - 0x13ccc, - 0x11c46, - 0x17dcc, - 0x13cc6, - 0x17dc6, - 0x10c2e, - 0x11c6e, - 0x13cee, - 0x17dee, - // 720 - 0x1be50, - 0x1df2c, - 0x1be48, - 0x1df26, - 0x1be44, - 0x1be42, - 0x13c50, - 0x19e2c, - 0x17cd0, - 0x13c48, - // 730 - 0x19e26, - 0x17cc8, - 0x1be66, - 0x17cc4, - 0x13c42, - 0x17cc2, - 0x11c2c, - 0x13c6c, - 0x11c26, - 0x17cec, - // 740 - 0x13c66, - 0x17ce6, - 0x1be28, - 0x1df16, - 0x1be24, - 0x1be22, - 0x13c28, - 0x19e16, - 0x17c68, - 0x13c24, - // 750 - 0x17c64, - 0x13c22, - 0x17c62, - 0x11c16, - 0x13c36, - 0x17c76, - 0x1be14, - 0x1be12, - 0x13c14, - 0x17c34, - // 760 - 0x13c12, - 0x17c32, - 0x102bc, - 0x1029e, - 0x106b8, - 0x1835e, - 0x1069c, - 0x1068e, - 0x1025e, - 0x106de, - // 770 - 0x10eb0, - 0x1875c, - 0x10e98, - 0x1874e, - 0x10e8c, - 0x10e86, - 0x1065c, - 0x10edc, - 0x1064e, - 0x10ece, - // 780 - 0x11ea0, - 0x18f58, - 0x1c7ae, - 0x11e90, - 0x18f4c, - 0x11e88, - 0x18f46, - 0x11e84, - 0x11e82, - 0x10e58, - // 790 - 0x1872e, - 0x11ed8, - 0x18f6e, - 0x11ecc, - 0x10e46, - 0x11ec6, - 0x1062e, - 0x10e6e, - 0x11eee, - 0x19f50, - // 800 - 0x1cfac, - 0x19f48, - 0x1cfa6, - 0x19f44, - 0x19f42, - 0x11e50, - 0x18f2c, - 0x13ed0, - 0x19f6c, - 0x18f26, - // 810 - 0x13ec8, - 0x11e44, - 0x13ec4, - 0x11e42, - 0x13ec2, - 0x10e2c, - 0x11e6c, - 0x10e26, - 0x13eec, - 0x11e66, - // 820 - 0x13ee6, - 0x1dfa8, - 0x1efd6, - 0x1dfa4, - 0x1dfa2, - 0x19f28, - 0x1cf96, - 0x1bf68, - 0x19f24, - 0x1bf64, - // 830 - 0x19f22, - 0x1bf62, - 0x11e28, - 0x18f16, - 0x13e68, - 0x11e24, - 0x17ee8, - 0x13e64, - 0x11e22, - 0x17ee4, - // 840 - 0x13e62, - 0x17ee2, - 0x10e16, - 0x11e36, - 0x13e76, - 0x17ef6, - 0x1df94, - 0x1df92, - 0x19f14, - 0x1bf34, - // 850 - 0x19f12, - 0x1bf32, - 0x11e14, - 0x13e34, - 0x11e12, - 0x17e74, - 0x13e32, - 0x17e72, - 0x1df8a, - 0x19f0a, - // 860 - 0x1bf1a, - 0x11e0a, - 0x13e1a, - 0x17e3a, - 0x1035c, - 0x1034e, - 0x10758, - 0x183ae, - 0x1074c, - 0x10746, - // 870 - 0x1032e, - 0x1076e, - 0x10f50, - 0x187ac, - 0x10f48, - 0x187a6, - 0x10f44, - 0x10f42, - 0x1072c, - 0x10f6c, - // 880 - 0x10726, - 0x10f66, - 0x18fa8, - 0x1c7d6, - 0x18fa4, - 0x18fa2, - 0x10f28, - 0x18796, - 0x11f68, - 0x18fb6, - // 890 - 0x11f64, - 0x10f22, - 0x11f62, - 0x10716, - 0x10f36, - 0x11f76, - 0x1cfd4, - 0x1cfd2, - 0x18f94, - 0x19fb4, - // 900 - 0x18f92, - 0x19fb2, - 0x10f14, - 0x11f34, - 0x10f12, - 0x13f74, - 0x11f32, - 0x13f72, - 0x1cfca, - 0x18f8a, - // 910 - 0x19f9a, - 0x10f0a, - 0x11f1a, - 0x13f3a, - 0x103ac, - 0x103a6, - 0x107a8, - 0x183d6, - 0x107a4, - 0x107a2, - // 920 - 0x10396, - 0x107b6, - 0x187d4, - 0x187d2, - 0x10794, - 0x10fb4, - 0x10792, - 0x10fb2, - 0x1c7ea, - ]]; + public const CLUSTERS = [ + [ + // cluster 0 ----------------------------------------------------------------------- + 0x1d5c0, + 0x1eaf0, + 0x1f57c, + 0x1d4e0, + 0x1ea78, + 0x1f53e, + 0x1a8c0, + 0x1d470, + 0x1a860, + 0x15040, + // 10 + 0x1a830, + 0x15020, + 0x1adc0, + 0x1d6f0, + 0x1eb7c, + 0x1ace0, + 0x1d678, + 0x1eb3e, + 0x158c0, + 0x1ac70, + // 20 + 0x15860, + 0x15dc0, + 0x1aef0, + 0x1d77c, + 0x15ce0, + 0x1ae78, + 0x1d73e, + 0x15c70, + 0x1ae3c, + 0x15ef0, + // 30 + 0x1af7c, + 0x15e78, + 0x1af3e, + 0x15f7c, + 0x1f5fa, + 0x1d2e0, + 0x1e978, + 0x1f4be, + 0x1a4c0, + 0x1d270, + // 40 + 0x1e93c, + 0x1a460, + 0x1d238, + 0x14840, + 0x1a430, + 0x1d21c, + 0x14820, + 0x1a418, + 0x14810, + 0x1a6e0, + // 50 + 0x1d378, + 0x1e9be, + 0x14cc0, + 0x1a670, + 0x1d33c, + 0x14c60, + 0x1a638, + 0x1d31e, + 0x14c30, + 0x1a61c, + // 60 + 0x14ee0, + 0x1a778, + 0x1d3be, + 0x14e70, + 0x1a73c, + 0x14e38, + 0x1a71e, + 0x14f78, + 0x1a7be, + 0x14f3c, + // 70 + 0x14f1e, + 0x1a2c0, + 0x1d170, + 0x1e8bc, + 0x1a260, + 0x1d138, + 0x1e89e, + 0x14440, + 0x1a230, + 0x1d11c, + // 80 + 0x14420, + 0x1a218, + 0x14410, + 0x14408, + 0x146c0, + 0x1a370, + 0x1d1bc, + 0x14660, + 0x1a338, + 0x1d19e, + // 90 + 0x14630, + 0x1a31c, + 0x14618, + 0x1460c, + 0x14770, + 0x1a3bc, + 0x14738, + 0x1a39e, + 0x1471c, + 0x147bc, + // 100 + 0x1a160, + 0x1d0b8, + 0x1e85e, + 0x14240, + 0x1a130, + 0x1d09c, + 0x14220, + 0x1a118, + 0x1d08e, + 0x14210, + // 110 + 0x1a10c, + 0x14208, + 0x1a106, + 0x14360, + 0x1a1b8, + 0x1d0de, + 0x14330, + 0x1a19c, + 0x14318, + 0x1a18e, + // 120 + 0x1430c, + 0x14306, + 0x1a1de, + 0x1438e, + 0x14140, + 0x1a0b0, + 0x1d05c, + 0x14120, + 0x1a098, + 0x1d04e, + // 130 + 0x14110, + 0x1a08c, + 0x14108, + 0x1a086, + 0x14104, + 0x141b0, + 0x14198, + 0x1418c, + 0x140a0, + 0x1d02e, + // 140 + 0x1a04c, + 0x1a046, + 0x14082, + 0x1cae0, + 0x1e578, + 0x1f2be, + 0x194c0, + 0x1ca70, + 0x1e53c, + 0x19460, + // 150 + 0x1ca38, + 0x1e51e, + 0x12840, + 0x19430, + 0x12820, + 0x196e0, + 0x1cb78, + 0x1e5be, + 0x12cc0, + 0x19670, + // 160 + 0x1cb3c, + 0x12c60, + 0x19638, + 0x12c30, + 0x12c18, + 0x12ee0, + 0x19778, + 0x1cbbe, + 0x12e70, + 0x1973c, + // 170 + 0x12e38, + 0x12e1c, + 0x12f78, + 0x197be, + 0x12f3c, + 0x12fbe, + 0x1dac0, + 0x1ed70, + 0x1f6bc, + 0x1da60, + // 180 + 0x1ed38, + 0x1f69e, + 0x1b440, + 0x1da30, + 0x1ed1c, + 0x1b420, + 0x1da18, + 0x1ed0e, + 0x1b410, + 0x1da0c, + // 190 + 0x192c0, + 0x1c970, + 0x1e4bc, + 0x1b6c0, + 0x19260, + 0x1c938, + 0x1e49e, + 0x1b660, + 0x1db38, + 0x1ed9e, + // 200 + 0x16c40, + 0x12420, + 0x19218, + 0x1c90e, + 0x16c20, + 0x1b618, + 0x16c10, + 0x126c0, + 0x19370, + 0x1c9bc, + // 210 + 0x16ec0, + 0x12660, + 0x19338, + 0x1c99e, + 0x16e60, + 0x1b738, + 0x1db9e, + 0x16e30, + 0x12618, + 0x16e18, + // 220 + 0x12770, + 0x193bc, + 0x16f70, + 0x12738, + 0x1939e, + 0x16f38, + 0x1b79e, + 0x16f1c, + 0x127bc, + 0x16fbc, + // 230 + 0x1279e, + 0x16f9e, + 0x1d960, + 0x1ecb8, + 0x1f65e, + 0x1b240, + 0x1d930, + 0x1ec9c, + 0x1b220, + 0x1d918, + // 240 + 0x1ec8e, + 0x1b210, + 0x1d90c, + 0x1b208, + 0x1b204, + 0x19160, + 0x1c8b8, + 0x1e45e, + 0x1b360, + 0x19130, + // 250 + 0x1c89c, + 0x16640, + 0x12220, + 0x1d99c, + 0x1c88e, + 0x16620, + 0x12210, + 0x1910c, + 0x16610, + 0x1b30c, + // 260 + 0x19106, + 0x12204, + 0x12360, + 0x191b8, + 0x1c8de, + 0x16760, + 0x12330, + 0x1919c, + 0x16730, + 0x1b39c, + // 270 + 0x1918e, + 0x16718, + 0x1230c, + 0x12306, + 0x123b8, + 0x191de, + 0x167b8, + 0x1239c, + 0x1679c, + 0x1238e, + // 280 + 0x1678e, + 0x167de, + 0x1b140, + 0x1d8b0, + 0x1ec5c, + 0x1b120, + 0x1d898, + 0x1ec4e, + 0x1b110, + 0x1d88c, + // 290 + 0x1b108, + 0x1d886, + 0x1b104, + 0x1b102, + 0x12140, + 0x190b0, + 0x1c85c, + 0x16340, + 0x12120, + 0x19098, + // 300 + 0x1c84e, + 0x16320, + 0x1b198, + 0x1d8ce, + 0x16310, + 0x12108, + 0x19086, + 0x16308, + 0x1b186, + 0x16304, + // 310 + 0x121b0, + 0x190dc, + 0x163b0, + 0x12198, + 0x190ce, + 0x16398, + 0x1b1ce, + 0x1638c, + 0x12186, + 0x16386, + // 320 + 0x163dc, + 0x163ce, + 0x1b0a0, + 0x1d858, + 0x1ec2e, + 0x1b090, + 0x1d84c, + 0x1b088, + 0x1d846, + 0x1b084, + // 330 + 0x1b082, + 0x120a0, + 0x19058, + 0x1c82e, + 0x161a0, + 0x12090, + 0x1904c, + 0x16190, + 0x1b0cc, + 0x19046, + // 340 + 0x16188, + 0x12084, + 0x16184, + 0x12082, + 0x120d8, + 0x161d8, + 0x161cc, + 0x161c6, + 0x1d82c, + 0x1d826, + // 350 + 0x1b042, + 0x1902c, + 0x12048, + 0x160c8, + 0x160c4, + 0x160c2, + 0x18ac0, + 0x1c570, + 0x1e2bc, + 0x18a60, + // 360 + 0x1c538, + 0x11440, + 0x18a30, + 0x1c51c, + 0x11420, + 0x18a18, + 0x11410, + 0x11408, + 0x116c0, + 0x18b70, + // 370 + 0x1c5bc, + 0x11660, + 0x18b38, + 0x1c59e, + 0x11630, + 0x18b1c, + 0x11618, + 0x1160c, + 0x11770, + 0x18bbc, + // 380 + 0x11738, + 0x18b9e, + 0x1171c, + 0x117bc, + 0x1179e, + 0x1cd60, + 0x1e6b8, + 0x1f35e, + 0x19a40, + 0x1cd30, + // 390 + 0x1e69c, + 0x19a20, + 0x1cd18, + 0x1e68e, + 0x19a10, + 0x1cd0c, + 0x19a08, + 0x1cd06, + 0x18960, + 0x1c4b8, + // 400 + 0x1e25e, + 0x19b60, + 0x18930, + 0x1c49c, + 0x13640, + 0x11220, + 0x1cd9c, + 0x1c48e, + 0x13620, + 0x19b18, + // 410 + 0x1890c, + 0x13610, + 0x11208, + 0x13608, + 0x11360, + 0x189b8, + 0x1c4de, + 0x13760, + 0x11330, + 0x1cdde, + // 420 + 0x13730, + 0x19b9c, + 0x1898e, + 0x13718, + 0x1130c, + 0x1370c, + 0x113b8, + 0x189de, + 0x137b8, + 0x1139c, + // 430 + 0x1379c, + 0x1138e, + 0x113de, + 0x137de, + 0x1dd40, + 0x1eeb0, + 0x1f75c, + 0x1dd20, + 0x1ee98, + 0x1f74e, + // 440 + 0x1dd10, + 0x1ee8c, + 0x1dd08, + 0x1ee86, + 0x1dd04, + 0x19940, + 0x1ccb0, + 0x1e65c, + 0x1bb40, + 0x19920, + // 450 + 0x1eedc, + 0x1e64e, + 0x1bb20, + 0x1dd98, + 0x1eece, + 0x1bb10, + 0x19908, + 0x1cc86, + 0x1bb08, + 0x1dd86, + // 460 + 0x19902, + 0x11140, + 0x188b0, + 0x1c45c, + 0x13340, + 0x11120, + 0x18898, + 0x1c44e, + 0x17740, + 0x13320, + // 470 + 0x19998, + 0x1ccce, + 0x17720, + 0x1bb98, + 0x1ddce, + 0x18886, + 0x17710, + 0x13308, + 0x19986, + 0x17708, + // 480 + 0x11102, + 0x111b0, + 0x188dc, + 0x133b0, + 0x11198, + 0x188ce, + 0x177b0, + 0x13398, + 0x199ce, + 0x17798, + // 490 + 0x1bbce, + 0x11186, + 0x13386, + 0x111dc, + 0x133dc, + 0x111ce, + 0x177dc, + 0x133ce, + 0x1dca0, + 0x1ee58, + // 500 + 0x1f72e, + 0x1dc90, + 0x1ee4c, + 0x1dc88, + 0x1ee46, + 0x1dc84, + 0x1dc82, + 0x198a0, + 0x1cc58, + 0x1e62e, + // 510 + 0x1b9a0, + 0x19890, + 0x1ee6e, + 0x1b990, + 0x1dccc, + 0x1cc46, + 0x1b988, + 0x19884, + 0x1b984, + 0x19882, + // 520 + 0x1b982, + 0x110a0, + 0x18858, + 0x1c42e, + 0x131a0, + 0x11090, + 0x1884c, + 0x173a0, + 0x13190, + 0x198cc, + // 530 + 0x18846, + 0x17390, + 0x1b9cc, + 0x11084, + 0x17388, + 0x13184, + 0x11082, + 0x13182, + 0x110d8, + 0x1886e, + // 540 + 0x131d8, + 0x110cc, + 0x173d8, + 0x131cc, + 0x110c6, + 0x173cc, + 0x131c6, + 0x110ee, + 0x173ee, + 0x1dc50, + // 550 + 0x1ee2c, + 0x1dc48, + 0x1ee26, + 0x1dc44, + 0x1dc42, + 0x19850, + 0x1cc2c, + 0x1b8d0, + 0x19848, + 0x1cc26, + // 560 + 0x1b8c8, + 0x1dc66, + 0x1b8c4, + 0x19842, + 0x1b8c2, + 0x11050, + 0x1882c, + 0x130d0, + 0x11048, + 0x18826, + // 570 + 0x171d0, + 0x130c8, + 0x19866, + 0x171c8, + 0x1b8e6, + 0x11042, + 0x171c4, + 0x130c2, + 0x171c2, + 0x130ec, + // 580 + 0x171ec, + 0x171e6, + 0x1ee16, + 0x1dc22, + 0x1cc16, + 0x19824, + 0x19822, + 0x11028, + 0x13068, + 0x170e8, + // 590 + 0x11022, + 0x13062, + 0x18560, + 0x10a40, + 0x18530, + 0x10a20, + 0x18518, + 0x1c28e, + 0x10a10, + 0x1850c, + // 600 + 0x10a08, + 0x18506, + 0x10b60, + 0x185b8, + 0x1c2de, + 0x10b30, + 0x1859c, + 0x10b18, + 0x1858e, + 0x10b0c, + // 610 + 0x10b06, + 0x10bb8, + 0x185de, + 0x10b9c, + 0x10b8e, + 0x10bde, + 0x18d40, + 0x1c6b0, + 0x1e35c, + 0x18d20, + // 620 + 0x1c698, + 0x18d10, + 0x1c68c, + 0x18d08, + 0x1c686, + 0x18d04, + 0x10940, + 0x184b0, + 0x1c25c, + 0x11b40, + // 630 + 0x10920, + 0x1c6dc, + 0x1c24e, + 0x11b20, + 0x18d98, + 0x1c6ce, + 0x11b10, + 0x10908, + 0x18486, + 0x11b08, + // 640 + 0x18d86, + 0x10902, + 0x109b0, + 0x184dc, + 0x11bb0, + 0x10998, + 0x184ce, + 0x11b98, + 0x18dce, + 0x11b8c, + // 650 + 0x10986, + 0x109dc, + 0x11bdc, + 0x109ce, + 0x11bce, + 0x1cea0, + 0x1e758, + 0x1f3ae, + 0x1ce90, + 0x1e74c, + // 660 + 0x1ce88, + 0x1e746, + 0x1ce84, + 0x1ce82, + 0x18ca0, + 0x1c658, + 0x19da0, + 0x18c90, + 0x1c64c, + 0x19d90, + // 670 + 0x1cecc, + 0x1c646, + 0x19d88, + 0x18c84, + 0x19d84, + 0x18c82, + 0x19d82, + 0x108a0, + 0x18458, + 0x119a0, + // 680 + 0x10890, + 0x1c66e, + 0x13ba0, + 0x11990, + 0x18ccc, + 0x18446, + 0x13b90, + 0x19dcc, + 0x10884, + 0x13b88, + // 690 + 0x11984, + 0x10882, + 0x11982, + 0x108d8, + 0x1846e, + 0x119d8, + 0x108cc, + 0x13bd8, + 0x119cc, + 0x108c6, + // 700 + 0x13bcc, + 0x119c6, + 0x108ee, + 0x119ee, + 0x13bee, + 0x1ef50, + 0x1f7ac, + 0x1ef48, + 0x1f7a6, + 0x1ef44, + // 710 + 0x1ef42, + 0x1ce50, + 0x1e72c, + 0x1ded0, + 0x1ef6c, + 0x1e726, + 0x1dec8, + 0x1ef66, + 0x1dec4, + 0x1ce42, + // 720 + 0x1dec2, + 0x18c50, + 0x1c62c, + 0x19cd0, + 0x18c48, + 0x1c626, + 0x1bdd0, + 0x19cc8, + 0x1ce66, + 0x1bdc8, + // 730 + 0x1dee6, + 0x18c42, + 0x1bdc4, + 0x19cc2, + 0x1bdc2, + 0x10850, + 0x1842c, + 0x118d0, + 0x10848, + 0x18426, + // 740 + 0x139d0, + 0x118c8, + 0x18c66, + 0x17bd0, + 0x139c8, + 0x19ce6, + 0x10842, + 0x17bc8, + 0x1bde6, + 0x118c2, + // 750 + 0x17bc4, + 0x1086c, + 0x118ec, + 0x10866, + 0x139ec, + 0x118e6, + 0x17bec, + 0x139e6, + 0x17be6, + 0x1ef28, + // 760 + 0x1f796, + 0x1ef24, + 0x1ef22, + 0x1ce28, + 0x1e716, + 0x1de68, + 0x1ef36, + 0x1de64, + 0x1ce22, + 0x1de62, + // 770 + 0x18c28, + 0x1c616, + 0x19c68, + 0x18c24, + 0x1bce8, + 0x19c64, + 0x18c22, + 0x1bce4, + 0x19c62, + 0x1bce2, + // 780 + 0x10828, + 0x18416, + 0x11868, + 0x18c36, + 0x138e8, + 0x11864, + 0x10822, + 0x179e8, + 0x138e4, + 0x11862, + // 790 + 0x179e4, + 0x138e2, + 0x179e2, + 0x11876, + 0x179f6, + 0x1ef12, + 0x1de34, + 0x1de32, + 0x19c34, + 0x1bc74, + // 800 + 0x1bc72, + 0x11834, + 0x13874, + 0x178f4, + 0x178f2, + 0x10540, + 0x10520, + 0x18298, + 0x10510, + 0x10508, + // 810 + 0x10504, + 0x105b0, + 0x10598, + 0x1058c, + 0x10586, + 0x105dc, + 0x105ce, + 0x186a0, + 0x18690, + 0x1c34c, + // 820 + 0x18688, + 0x1c346, + 0x18684, + 0x18682, + 0x104a0, + 0x18258, + 0x10da0, + 0x186d8, + 0x1824c, + 0x10d90, + // 830 + 0x186cc, + 0x10d88, + 0x186c6, + 0x10d84, + 0x10482, + 0x10d82, + 0x104d8, + 0x1826e, + 0x10dd8, + 0x186ee, + // 840 + 0x10dcc, + 0x104c6, + 0x10dc6, + 0x104ee, + 0x10dee, + 0x1c750, + 0x1c748, + 0x1c744, + 0x1c742, + 0x18650, + // 850 + 0x18ed0, + 0x1c76c, + 0x1c326, + 0x18ec8, + 0x1c766, + 0x18ec4, + 0x18642, + 0x18ec2, + 0x10450, + 0x10cd0, + // 860 + 0x10448, + 0x18226, + 0x11dd0, + 0x10cc8, + 0x10444, + 0x11dc8, + 0x10cc4, + 0x10442, + 0x11dc4, + 0x10cc2, + // 870 + 0x1046c, + 0x10cec, + 0x10466, + 0x11dec, + 0x10ce6, + 0x11de6, + 0x1e7a8, + 0x1e7a4, + 0x1e7a2, + 0x1c728, + // 880 + 0x1cf68, + 0x1e7b6, + 0x1cf64, + 0x1c722, + 0x1cf62, + 0x18628, + 0x1c316, + 0x18e68, + 0x1c736, + 0x19ee8, + // 890 + 0x18e64, + 0x18622, + 0x19ee4, + 0x18e62, + 0x19ee2, + 0x10428, + 0x18216, + 0x10c68, + 0x18636, + 0x11ce8, + // 900 + 0x10c64, + 0x10422, + 0x13de8, + 0x11ce4, + 0x10c62, + 0x13de4, + 0x11ce2, + 0x10436, + 0x10c76, + 0x11cf6, + // 910 + 0x13df6, + 0x1f7d4, + 0x1f7d2, + 0x1e794, + 0x1efb4, + 0x1e792, + 0x1efb2, + 0x1c714, + 0x1cf34, + 0x1c712, + // 920 + 0x1df74, + 0x1cf32, + 0x1df72, + 0x18614, + 0x18e34, + 0x18612, + 0x19e74, + 0x18e32, + 0x1bef4, + ], + [ + // cluster 3 ----------------------------------------------------------------------- + 0x1f560, + 0x1fab8, + 0x1ea40, + 0x1f530, + 0x1fa9c, + 0x1ea20, + 0x1f518, + 0x1fa8e, + 0x1ea10, + 0x1f50c, + // 10 + 0x1ea08, + 0x1f506, + 0x1ea04, + 0x1eb60, + 0x1f5b8, + 0x1fade, + 0x1d640, + 0x1eb30, + 0x1f59c, + 0x1d620, + // 20 + 0x1eb18, + 0x1f58e, + 0x1d610, + 0x1eb0c, + 0x1d608, + 0x1eb06, + 0x1d604, + 0x1d760, + 0x1ebb8, + 0x1f5de, + // 30 + 0x1ae40, + 0x1d730, + 0x1eb9c, + 0x1ae20, + 0x1d718, + 0x1eb8e, + 0x1ae10, + 0x1d70c, + 0x1ae08, + 0x1d706, + // 40 + 0x1ae04, + 0x1af60, + 0x1d7b8, + 0x1ebde, + 0x15e40, + 0x1af30, + 0x1d79c, + 0x15e20, + 0x1af18, + 0x1d78e, + // 50 + 0x15e10, + 0x1af0c, + 0x15e08, + 0x1af06, + 0x15f60, + 0x1afb8, + 0x1d7de, + 0x15f30, + 0x1af9c, + 0x15f18, + // 60 + 0x1af8e, + 0x15f0c, + 0x15fb8, + 0x1afde, + 0x15f9c, + 0x15f8e, + 0x1e940, + 0x1f4b0, + 0x1fa5c, + 0x1e920, + // 70 + 0x1f498, + 0x1fa4e, + 0x1e910, + 0x1f48c, + 0x1e908, + 0x1f486, + 0x1e904, + 0x1e902, + 0x1d340, + 0x1e9b0, + // 80 + 0x1f4dc, + 0x1d320, + 0x1e998, + 0x1f4ce, + 0x1d310, + 0x1e98c, + 0x1d308, + 0x1e986, + 0x1d304, + 0x1d302, + // 90 + 0x1a740, + 0x1d3b0, + 0x1e9dc, + 0x1a720, + 0x1d398, + 0x1e9ce, + 0x1a710, + 0x1d38c, + 0x1a708, + 0x1d386, + // 100 + 0x1a704, + 0x1a702, + 0x14f40, + 0x1a7b0, + 0x1d3dc, + 0x14f20, + 0x1a798, + 0x1d3ce, + 0x14f10, + 0x1a78c, + // 110 + 0x14f08, + 0x1a786, + 0x14f04, + 0x14fb0, + 0x1a7dc, + 0x14f98, + 0x1a7ce, + 0x14f8c, + 0x14f86, + 0x14fdc, + // 120 + 0x14fce, + 0x1e8a0, + 0x1f458, + 0x1fa2e, + 0x1e890, + 0x1f44c, + 0x1e888, + 0x1f446, + 0x1e884, + 0x1e882, + // 130 + 0x1d1a0, + 0x1e8d8, + 0x1f46e, + 0x1d190, + 0x1e8cc, + 0x1d188, + 0x1e8c6, + 0x1d184, + 0x1d182, + 0x1a3a0, + // 140 + 0x1d1d8, + 0x1e8ee, + 0x1a390, + 0x1d1cc, + 0x1a388, + 0x1d1c6, + 0x1a384, + 0x1a382, + 0x147a0, + 0x1a3d8, + // 150 + 0x1d1ee, + 0x14790, + 0x1a3cc, + 0x14788, + 0x1a3c6, + 0x14784, + 0x14782, + 0x147d8, + 0x1a3ee, + 0x147cc, + // 160 + 0x147c6, + 0x147ee, + 0x1e850, + 0x1f42c, + 0x1e848, + 0x1f426, + 0x1e844, + 0x1e842, + 0x1d0d0, + 0x1e86c, + // 170 + 0x1d0c8, + 0x1e866, + 0x1d0c4, + 0x1d0c2, + 0x1a1d0, + 0x1d0ec, + 0x1a1c8, + 0x1d0e6, + 0x1a1c4, + 0x1a1c2, + // 180 + 0x143d0, + 0x1a1ec, + 0x143c8, + 0x1a1e6, + 0x143c4, + 0x143c2, + 0x143ec, + 0x143e6, + 0x1e828, + 0x1f416, + // 190 + 0x1e824, + 0x1e822, + 0x1d068, + 0x1e836, + 0x1d064, + 0x1d062, + 0x1a0e8, + 0x1d076, + 0x1a0e4, + 0x1a0e2, + // 200 + 0x141e8, + 0x1a0f6, + 0x141e4, + 0x141e2, + 0x1e814, + 0x1e812, + 0x1d034, + 0x1d032, + 0x1a074, + 0x1a072, + // 210 + 0x1e540, + 0x1f2b0, + 0x1f95c, + 0x1e520, + 0x1f298, + 0x1f94e, + 0x1e510, + 0x1f28c, + 0x1e508, + 0x1f286, + // 220 + 0x1e504, + 0x1e502, + 0x1cb40, + 0x1e5b0, + 0x1f2dc, + 0x1cb20, + 0x1e598, + 0x1f2ce, + 0x1cb10, + 0x1e58c, + // 230 + 0x1cb08, + 0x1e586, + 0x1cb04, + 0x1cb02, + 0x19740, + 0x1cbb0, + 0x1e5dc, + 0x19720, + 0x1cb98, + 0x1e5ce, + // 240 + 0x19710, + 0x1cb8c, + 0x19708, + 0x1cb86, + 0x19704, + 0x19702, + 0x12f40, + 0x197b0, + 0x1cbdc, + 0x12f20, + // 250 + 0x19798, + 0x1cbce, + 0x12f10, + 0x1978c, + 0x12f08, + 0x19786, + 0x12f04, + 0x12fb0, + 0x197dc, + 0x12f98, + // 260 + 0x197ce, + 0x12f8c, + 0x12f86, + 0x12fdc, + 0x12fce, + 0x1f6a0, + 0x1fb58, + 0x16bf0, + 0x1f690, + 0x1fb4c, + // 270 + 0x169f8, + 0x1f688, + 0x1fb46, + 0x168fc, + 0x1f684, + 0x1f682, + 0x1e4a0, + 0x1f258, + 0x1f92e, + 0x1eda0, + // 280 + 0x1e490, + 0x1fb6e, + 0x1ed90, + 0x1f6cc, + 0x1f246, + 0x1ed88, + 0x1e484, + 0x1ed84, + 0x1e482, + 0x1ed82, + // 290 + 0x1c9a0, + 0x1e4d8, + 0x1f26e, + 0x1dba0, + 0x1c990, + 0x1e4cc, + 0x1db90, + 0x1edcc, + 0x1e4c6, + 0x1db88, + // 300 + 0x1c984, + 0x1db84, + 0x1c982, + 0x1db82, + 0x193a0, + 0x1c9d8, + 0x1e4ee, + 0x1b7a0, + 0x19390, + 0x1c9cc, + // 310 + 0x1b790, + 0x1dbcc, + 0x1c9c6, + 0x1b788, + 0x19384, + 0x1b784, + 0x19382, + 0x1b782, + 0x127a0, + 0x193d8, + // 320 + 0x1c9ee, + 0x16fa0, + 0x12790, + 0x193cc, + 0x16f90, + 0x1b7cc, + 0x193c6, + 0x16f88, + 0x12784, + 0x16f84, + // 330 + 0x12782, + 0x127d8, + 0x193ee, + 0x16fd8, + 0x127cc, + 0x16fcc, + 0x127c6, + 0x16fc6, + 0x127ee, + 0x1f650, + // 340 + 0x1fb2c, + 0x165f8, + 0x1f648, + 0x1fb26, + 0x164fc, + 0x1f644, + 0x1647e, + 0x1f642, + 0x1e450, + 0x1f22c, + // 350 + 0x1ecd0, + 0x1e448, + 0x1f226, + 0x1ecc8, + 0x1f666, + 0x1ecc4, + 0x1e442, + 0x1ecc2, + 0x1c8d0, + 0x1e46c, + // 360 + 0x1d9d0, + 0x1c8c8, + 0x1e466, + 0x1d9c8, + 0x1ece6, + 0x1d9c4, + 0x1c8c2, + 0x1d9c2, + 0x191d0, + 0x1c8ec, + // 370 + 0x1b3d0, + 0x191c8, + 0x1c8e6, + 0x1b3c8, + 0x1d9e6, + 0x1b3c4, + 0x191c2, + 0x1b3c2, + 0x123d0, + 0x191ec, + // 380 + 0x167d0, + 0x123c8, + 0x191e6, + 0x167c8, + 0x1b3e6, + 0x167c4, + 0x123c2, + 0x167c2, + 0x123ec, + 0x167ec, + // 390 + 0x123e6, + 0x167e6, + 0x1f628, + 0x1fb16, + 0x162fc, + 0x1f624, + 0x1627e, + 0x1f622, + 0x1e428, + 0x1f216, + // 400 + 0x1ec68, + 0x1f636, + 0x1ec64, + 0x1e422, + 0x1ec62, + 0x1c868, + 0x1e436, + 0x1d8e8, + 0x1c864, + 0x1d8e4, + // 410 + 0x1c862, + 0x1d8e2, + 0x190e8, + 0x1c876, + 0x1b1e8, + 0x1d8f6, + 0x1b1e4, + 0x190e2, + 0x1b1e2, + 0x121e8, + // 420 + 0x190f6, + 0x163e8, + 0x121e4, + 0x163e4, + 0x121e2, + 0x163e2, + 0x121f6, + 0x163f6, + 0x1f614, + 0x1617e, + // 430 + 0x1f612, + 0x1e414, + 0x1ec34, + 0x1e412, + 0x1ec32, + 0x1c834, + 0x1d874, + 0x1c832, + 0x1d872, + 0x19074, + // 440 + 0x1b0f4, + 0x19072, + 0x1b0f2, + 0x120f4, + 0x161f4, + 0x120f2, + 0x161f2, + 0x1f60a, + 0x1e40a, + 0x1ec1a, + // 450 + 0x1c81a, + 0x1d83a, + 0x1903a, + 0x1b07a, + 0x1e2a0, + 0x1f158, + 0x1f8ae, + 0x1e290, + 0x1f14c, + 0x1e288, + // 460 + 0x1f146, + 0x1e284, + 0x1e282, + 0x1c5a0, + 0x1e2d8, + 0x1f16e, + 0x1c590, + 0x1e2cc, + 0x1c588, + 0x1e2c6, + // 470 + 0x1c584, + 0x1c582, + 0x18ba0, + 0x1c5d8, + 0x1e2ee, + 0x18b90, + 0x1c5cc, + 0x18b88, + 0x1c5c6, + 0x18b84, + // 480 + 0x18b82, + 0x117a0, + 0x18bd8, + 0x1c5ee, + 0x11790, + 0x18bcc, + 0x11788, + 0x18bc6, + 0x11784, + 0x11782, + // 490 + 0x117d8, + 0x18bee, + 0x117cc, + 0x117c6, + 0x117ee, + 0x1f350, + 0x1f9ac, + 0x135f8, + 0x1f348, + 0x1f9a6, + // 500 + 0x134fc, + 0x1f344, + 0x1347e, + 0x1f342, + 0x1e250, + 0x1f12c, + 0x1e6d0, + 0x1e248, + 0x1f126, + 0x1e6c8, + // 510 + 0x1f366, + 0x1e6c4, + 0x1e242, + 0x1e6c2, + 0x1c4d0, + 0x1e26c, + 0x1cdd0, + 0x1c4c8, + 0x1e266, + 0x1cdc8, + // 520 + 0x1e6e6, + 0x1cdc4, + 0x1c4c2, + 0x1cdc2, + 0x189d0, + 0x1c4ec, + 0x19bd0, + 0x189c8, + 0x1c4e6, + 0x19bc8, + // 530 + 0x1cde6, + 0x19bc4, + 0x189c2, + 0x19bc2, + 0x113d0, + 0x189ec, + 0x137d0, + 0x113c8, + 0x189e6, + 0x137c8, + // 540 + 0x19be6, + 0x137c4, + 0x113c2, + 0x137c2, + 0x113ec, + 0x137ec, + 0x113e6, + 0x137e6, + 0x1fba8, + 0x175f0, + // 550 + 0x1bafc, + 0x1fba4, + 0x174f8, + 0x1ba7e, + 0x1fba2, + 0x1747c, + 0x1743e, + 0x1f328, + 0x1f996, + 0x132fc, + // 560 + 0x1f768, + 0x1fbb6, + 0x176fc, + 0x1327e, + 0x1f764, + 0x1f322, + 0x1767e, + 0x1f762, + 0x1e228, + 0x1f116, + // 570 + 0x1e668, + 0x1e224, + 0x1eee8, + 0x1f776, + 0x1e222, + 0x1eee4, + 0x1e662, + 0x1eee2, + 0x1c468, + 0x1e236, + // 580 + 0x1cce8, + 0x1c464, + 0x1dde8, + 0x1cce4, + 0x1c462, + 0x1dde4, + 0x1cce2, + 0x1dde2, + 0x188e8, + 0x1c476, + // 590 + 0x199e8, + 0x188e4, + 0x1bbe8, + 0x199e4, + 0x188e2, + 0x1bbe4, + 0x199e2, + 0x1bbe2, + 0x111e8, + 0x188f6, + // 600 + 0x133e8, + 0x111e4, + 0x177e8, + 0x133e4, + 0x111e2, + 0x177e4, + 0x133e2, + 0x177e2, + 0x111f6, + 0x133f6, + // 610 + 0x1fb94, + 0x172f8, + 0x1b97e, + 0x1fb92, + 0x1727c, + 0x1723e, + 0x1f314, + 0x1317e, + 0x1f734, + 0x1f312, + // 620 + 0x1737e, + 0x1f732, + 0x1e214, + 0x1e634, + 0x1e212, + 0x1ee74, + 0x1e632, + 0x1ee72, + 0x1c434, + 0x1cc74, + // 630 + 0x1c432, + 0x1dcf4, + 0x1cc72, + 0x1dcf2, + 0x18874, + 0x198f4, + 0x18872, + 0x1b9f4, + 0x198f2, + 0x1b9f2, + // 640 + 0x110f4, + 0x131f4, + 0x110f2, + 0x173f4, + 0x131f2, + 0x173f2, + 0x1fb8a, + 0x1717c, + 0x1713e, + 0x1f30a, + // 650 + 0x1f71a, + 0x1e20a, + 0x1e61a, + 0x1ee3a, + 0x1c41a, + 0x1cc3a, + 0x1dc7a, + 0x1883a, + 0x1987a, + 0x1b8fa, + // 660 + 0x1107a, + 0x130fa, + 0x171fa, + 0x170be, + 0x1e150, + 0x1f0ac, + 0x1e148, + 0x1f0a6, + 0x1e144, + 0x1e142, + // 670 + 0x1c2d0, + 0x1e16c, + 0x1c2c8, + 0x1e166, + 0x1c2c4, + 0x1c2c2, + 0x185d0, + 0x1c2ec, + 0x185c8, + 0x1c2e6, + // 680 + 0x185c4, + 0x185c2, + 0x10bd0, + 0x185ec, + 0x10bc8, + 0x185e6, + 0x10bc4, + 0x10bc2, + 0x10bec, + 0x10be6, + // 690 + 0x1f1a8, + 0x1f8d6, + 0x11afc, + 0x1f1a4, + 0x11a7e, + 0x1f1a2, + 0x1e128, + 0x1f096, + 0x1e368, + 0x1e124, + // 700 + 0x1e364, + 0x1e122, + 0x1e362, + 0x1c268, + 0x1e136, + 0x1c6e8, + 0x1c264, + 0x1c6e4, + 0x1c262, + 0x1c6e2, + // 710 + 0x184e8, + 0x1c276, + 0x18de8, + 0x184e4, + 0x18de4, + 0x184e2, + 0x18de2, + 0x109e8, + 0x184f6, + 0x11be8, + // 720 + 0x109e4, + 0x11be4, + 0x109e2, + 0x11be2, + 0x109f6, + 0x11bf6, + 0x1f9d4, + 0x13af8, + 0x19d7e, + 0x1f9d2, + // 730 + 0x13a7c, + 0x13a3e, + 0x1f194, + 0x1197e, + 0x1f3b4, + 0x1f192, + 0x13b7e, + 0x1f3b2, + 0x1e114, + 0x1e334, + // 740 + 0x1e112, + 0x1e774, + 0x1e332, + 0x1e772, + 0x1c234, + 0x1c674, + 0x1c232, + 0x1cef4, + 0x1c672, + 0x1cef2, + // 750 + 0x18474, + 0x18cf4, + 0x18472, + 0x19df4, + 0x18cf2, + 0x19df2, + 0x108f4, + 0x119f4, + 0x108f2, + 0x13bf4, + // 760 + 0x119f2, + 0x13bf2, + 0x17af0, + 0x1bd7c, + 0x17a78, + 0x1bd3e, + 0x17a3c, + 0x17a1e, + 0x1f9ca, + 0x1397c, + // 770 + 0x1fbda, + 0x17b7c, + 0x1393e, + 0x17b3e, + 0x1f18a, + 0x1f39a, + 0x1f7ba, + 0x1e10a, + 0x1e31a, + 0x1e73a, + // 780 + 0x1ef7a, + 0x1c21a, + 0x1c63a, + 0x1ce7a, + 0x1defa, + 0x1843a, + 0x18c7a, + 0x19cfa, + 0x1bdfa, + 0x1087a, + // 790 + 0x118fa, + 0x139fa, + 0x17978, + 0x1bcbe, + 0x1793c, + 0x1791e, + 0x138be, + 0x179be, + 0x178bc, + 0x1789e, + // 800 + 0x1785e, + 0x1e0a8, + 0x1e0a4, + 0x1e0a2, + 0x1c168, + 0x1e0b6, + 0x1c164, + 0x1c162, + 0x182e8, + 0x1c176, + // 810 + 0x182e4, + 0x182e2, + 0x105e8, + 0x182f6, + 0x105e4, + 0x105e2, + 0x105f6, + 0x1f0d4, + 0x10d7e, + 0x1f0d2, + // 820 + 0x1e094, + 0x1e1b4, + 0x1e092, + 0x1e1b2, + 0x1c134, + 0x1c374, + 0x1c132, + 0x1c372, + 0x18274, + 0x186f4, + // 830 + 0x18272, + 0x186f2, + 0x104f4, + 0x10df4, + 0x104f2, + 0x10df2, + 0x1f8ea, + 0x11d7c, + 0x11d3e, + 0x1f0ca, + // 840 + 0x1f1da, + 0x1e08a, + 0x1e19a, + 0x1e3ba, + 0x1c11a, + 0x1c33a, + 0x1c77a, + 0x1823a, + 0x1867a, + 0x18efa, + // 850 + 0x1047a, + 0x10cfa, + 0x11dfa, + 0x13d78, + 0x19ebe, + 0x13d3c, + 0x13d1e, + 0x11cbe, + 0x13dbe, + 0x17d70, + // 860 + 0x1bebc, + 0x17d38, + 0x1be9e, + 0x17d1c, + 0x17d0e, + 0x13cbc, + 0x17dbc, + 0x13c9e, + 0x17d9e, + 0x17cb8, + // 870 + 0x1be5e, + 0x17c9c, + 0x17c8e, + 0x13c5e, + 0x17cde, + 0x17c5c, + 0x17c4e, + 0x17c2e, + 0x1c0b4, + 0x1c0b2, + // 880 + 0x18174, + 0x18172, + 0x102f4, + 0x102f2, + 0x1e0da, + 0x1c09a, + 0x1c1ba, + 0x1813a, + 0x1837a, + 0x1027a, + // 890 + 0x106fa, + 0x10ebe, + 0x11ebc, + 0x11e9e, + 0x13eb8, + 0x19f5e, + 0x13e9c, + 0x13e8e, + 0x11e5e, + 0x13ede, + // 900 + 0x17eb0, + 0x1bf5c, + 0x17e98, + 0x1bf4e, + 0x17e8c, + 0x17e86, + 0x13e5c, + 0x17edc, + 0x13e4e, + 0x17ece, + // 910 + 0x17e58, + 0x1bf2e, + 0x17e4c, + 0x17e46, + 0x13e2e, + 0x17e6e, + 0x17e2c, + 0x17e26, + 0x10f5e, + 0x11f5c, + // 920 + 0x11f4e, + 0x13f58, + 0x19fae, + 0x13f4c, + 0x13f46, + 0x11f2e, + 0x13f6e, + 0x13f2c, + 0x13f26, + ], + [ + // cluster 6 ----------------------------------------------------------------------- + 0x1abe0, + 0x1d5f8, + 0x153c0, + 0x1a9f0, + 0x1d4fc, + 0x151e0, + 0x1a8f8, + 0x1d47e, + 0x150f0, + 0x1a87c, + // 10 + 0x15078, + 0x1fad0, + 0x15be0, + 0x1adf8, + 0x1fac8, + 0x159f0, + 0x1acfc, + 0x1fac4, + 0x158f8, + 0x1ac7e, + // 20 + 0x1fac2, + 0x1587c, + 0x1f5d0, + 0x1faec, + 0x15df8, + 0x1f5c8, + 0x1fae6, + 0x15cfc, + 0x1f5c4, + 0x15c7e, + // 30 + 0x1f5c2, + 0x1ebd0, + 0x1f5ec, + 0x1ebc8, + 0x1f5e6, + 0x1ebc4, + 0x1ebc2, + 0x1d7d0, + 0x1ebec, + 0x1d7c8, + // 40 + 0x1ebe6, + 0x1d7c4, + 0x1d7c2, + 0x1afd0, + 0x1d7ec, + 0x1afc8, + 0x1d7e6, + 0x1afc4, + 0x14bc0, + 0x1a5f0, + // 50 + 0x1d2fc, + 0x149e0, + 0x1a4f8, + 0x1d27e, + 0x148f0, + 0x1a47c, + 0x14878, + 0x1a43e, + 0x1483c, + 0x1fa68, + // 60 + 0x14df0, + 0x1a6fc, + 0x1fa64, + 0x14cf8, + 0x1a67e, + 0x1fa62, + 0x14c7c, + 0x14c3e, + 0x1f4e8, + 0x1fa76, + // 70 + 0x14efc, + 0x1f4e4, + 0x14e7e, + 0x1f4e2, + 0x1e9e8, + 0x1f4f6, + 0x1e9e4, + 0x1e9e2, + 0x1d3e8, + 0x1e9f6, + // 80 + 0x1d3e4, + 0x1d3e2, + 0x1a7e8, + 0x1d3f6, + 0x1a7e4, + 0x1a7e2, + 0x145e0, + 0x1a2f8, + 0x1d17e, + 0x144f0, + // 90 + 0x1a27c, + 0x14478, + 0x1a23e, + 0x1443c, + 0x1441e, + 0x1fa34, + 0x146f8, + 0x1a37e, + 0x1fa32, + 0x1467c, + // 100 + 0x1463e, + 0x1f474, + 0x1477e, + 0x1f472, + 0x1e8f4, + 0x1e8f2, + 0x1d1f4, + 0x1d1f2, + 0x1a3f4, + 0x1a3f2, + // 110 + 0x142f0, + 0x1a17c, + 0x14278, + 0x1a13e, + 0x1423c, + 0x1421e, + 0x1fa1a, + 0x1437c, + 0x1433e, + 0x1f43a, + // 120 + 0x1e87a, + 0x1d0fa, + 0x14178, + 0x1a0be, + 0x1413c, + 0x1411e, + 0x141be, + 0x140bc, + 0x1409e, + 0x12bc0, + // 130 + 0x195f0, + 0x1cafc, + 0x129e0, + 0x194f8, + 0x1ca7e, + 0x128f0, + 0x1947c, + 0x12878, + 0x1943e, + 0x1283c, + // 140 + 0x1f968, + 0x12df0, + 0x196fc, + 0x1f964, + 0x12cf8, + 0x1967e, + 0x1f962, + 0x12c7c, + 0x12c3e, + 0x1f2e8, + // 150 + 0x1f976, + 0x12efc, + 0x1f2e4, + 0x12e7e, + 0x1f2e2, + 0x1e5e8, + 0x1f2f6, + 0x1e5e4, + 0x1e5e2, + 0x1cbe8, + // 160 + 0x1e5f6, + 0x1cbe4, + 0x1cbe2, + 0x197e8, + 0x1cbf6, + 0x197e4, + 0x197e2, + 0x1b5e0, + 0x1daf8, + 0x1ed7e, + // 170 + 0x169c0, + 0x1b4f0, + 0x1da7c, + 0x168e0, + 0x1b478, + 0x1da3e, + 0x16870, + 0x1b43c, + 0x16838, + 0x1b41e, + // 180 + 0x1681c, + 0x125e0, + 0x192f8, + 0x1c97e, + 0x16de0, + 0x124f0, + 0x1927c, + 0x16cf0, + 0x1b67c, + 0x1923e, + // 190 + 0x16c78, + 0x1243c, + 0x16c3c, + 0x1241e, + 0x16c1e, + 0x1f934, + 0x126f8, + 0x1937e, + 0x1fb74, + 0x1f932, + // 200 + 0x16ef8, + 0x1267c, + 0x1fb72, + 0x16e7c, + 0x1263e, + 0x16e3e, + 0x1f274, + 0x1277e, + 0x1f6f4, + 0x1f272, + // 210 + 0x16f7e, + 0x1f6f2, + 0x1e4f4, + 0x1edf4, + 0x1e4f2, + 0x1edf2, + 0x1c9f4, + 0x1dbf4, + 0x1c9f2, + 0x1dbf2, + // 220 + 0x193f4, + 0x193f2, + 0x165c0, + 0x1b2f0, + 0x1d97c, + 0x164e0, + 0x1b278, + 0x1d93e, + 0x16470, + 0x1b23c, + // 230 + 0x16438, + 0x1b21e, + 0x1641c, + 0x1640e, + 0x122f0, + 0x1917c, + 0x166f0, + 0x12278, + 0x1913e, + 0x16678, + // 240 + 0x1b33e, + 0x1663c, + 0x1221e, + 0x1661e, + 0x1f91a, + 0x1237c, + 0x1fb3a, + 0x1677c, + 0x1233e, + 0x1673e, + // 250 + 0x1f23a, + 0x1f67a, + 0x1e47a, + 0x1ecfa, + 0x1c8fa, + 0x1d9fa, + 0x191fa, + 0x162e0, + 0x1b178, + 0x1d8be, + // 260 + 0x16270, + 0x1b13c, + 0x16238, + 0x1b11e, + 0x1621c, + 0x1620e, + 0x12178, + 0x190be, + 0x16378, + 0x1213c, + // 270 + 0x1633c, + 0x1211e, + 0x1631e, + 0x121be, + 0x163be, + 0x16170, + 0x1b0bc, + 0x16138, + 0x1b09e, + 0x1611c, + // 280 + 0x1610e, + 0x120bc, + 0x161bc, + 0x1209e, + 0x1619e, + 0x160b8, + 0x1b05e, + 0x1609c, + 0x1608e, + 0x1205e, + // 290 + 0x160de, + 0x1605c, + 0x1604e, + 0x115e0, + 0x18af8, + 0x1c57e, + 0x114f0, + 0x18a7c, + 0x11478, + 0x18a3e, + // 300 + 0x1143c, + 0x1141e, + 0x1f8b4, + 0x116f8, + 0x18b7e, + 0x1f8b2, + 0x1167c, + 0x1163e, + 0x1f174, + 0x1177e, + // 310 + 0x1f172, + 0x1e2f4, + 0x1e2f2, + 0x1c5f4, + 0x1c5f2, + 0x18bf4, + 0x18bf2, + 0x135c0, + 0x19af0, + 0x1cd7c, + // 320 + 0x134e0, + 0x19a78, + 0x1cd3e, + 0x13470, + 0x19a3c, + 0x13438, + 0x19a1e, + 0x1341c, + 0x1340e, + 0x112f0, + // 330 + 0x1897c, + 0x136f0, + 0x11278, + 0x1893e, + 0x13678, + 0x19b3e, + 0x1363c, + 0x1121e, + 0x1361e, + 0x1f89a, + // 340 + 0x1137c, + 0x1f9ba, + 0x1377c, + 0x1133e, + 0x1373e, + 0x1f13a, + 0x1f37a, + 0x1e27a, + 0x1e6fa, + 0x1c4fa, + // 350 + 0x1cdfa, + 0x189fa, + 0x1bae0, + 0x1dd78, + 0x1eebe, + 0x174c0, + 0x1ba70, + 0x1dd3c, + 0x17460, + 0x1ba38, + // 360 + 0x1dd1e, + 0x17430, + 0x1ba1c, + 0x17418, + 0x1ba0e, + 0x1740c, + 0x132e0, + 0x19978, + 0x1ccbe, + 0x176e0, + // 370 + 0x13270, + 0x1993c, + 0x17670, + 0x1bb3c, + 0x1991e, + 0x17638, + 0x1321c, + 0x1761c, + 0x1320e, + 0x1760e, + // 380 + 0x11178, + 0x188be, + 0x13378, + 0x1113c, + 0x17778, + 0x1333c, + 0x1111e, + 0x1773c, + 0x1331e, + 0x1771e, + // 390 + 0x111be, + 0x133be, + 0x177be, + 0x172c0, + 0x1b970, + 0x1dcbc, + 0x17260, + 0x1b938, + 0x1dc9e, + 0x17230, + // 400 + 0x1b91c, + 0x17218, + 0x1b90e, + 0x1720c, + 0x17206, + 0x13170, + 0x198bc, + 0x17370, + 0x13138, + 0x1989e, + // 410 + 0x17338, + 0x1b99e, + 0x1731c, + 0x1310e, + 0x1730e, + 0x110bc, + 0x131bc, + 0x1109e, + 0x173bc, + 0x1319e, + // 420 + 0x1739e, + 0x17160, + 0x1b8b8, + 0x1dc5e, + 0x17130, + 0x1b89c, + 0x17118, + 0x1b88e, + 0x1710c, + 0x17106, + // 430 + 0x130b8, + 0x1985e, + 0x171b8, + 0x1309c, + 0x1719c, + 0x1308e, + 0x1718e, + 0x1105e, + 0x130de, + 0x171de, + // 440 + 0x170b0, + 0x1b85c, + 0x17098, + 0x1b84e, + 0x1708c, + 0x17086, + 0x1305c, + 0x170dc, + 0x1304e, + 0x170ce, + // 450 + 0x17058, + 0x1b82e, + 0x1704c, + 0x17046, + 0x1302e, + 0x1706e, + 0x1702c, + 0x17026, + 0x10af0, + 0x1857c, + // 460 + 0x10a78, + 0x1853e, + 0x10a3c, + 0x10a1e, + 0x10b7c, + 0x10b3e, + 0x1f0ba, + 0x1e17a, + 0x1c2fa, + 0x185fa, + // 470 + 0x11ae0, + 0x18d78, + 0x1c6be, + 0x11a70, + 0x18d3c, + 0x11a38, + 0x18d1e, + 0x11a1c, + 0x11a0e, + 0x10978, + // 480 + 0x184be, + 0x11b78, + 0x1093c, + 0x11b3c, + 0x1091e, + 0x11b1e, + 0x109be, + 0x11bbe, + 0x13ac0, + 0x19d70, + // 490 + 0x1cebc, + 0x13a60, + 0x19d38, + 0x1ce9e, + 0x13a30, + 0x19d1c, + 0x13a18, + 0x19d0e, + 0x13a0c, + 0x13a06, + // 500 + 0x11970, + 0x18cbc, + 0x13b70, + 0x11938, + 0x18c9e, + 0x13b38, + 0x1191c, + 0x13b1c, + 0x1190e, + 0x13b0e, + // 510 + 0x108bc, + 0x119bc, + 0x1089e, + 0x13bbc, + 0x1199e, + 0x13b9e, + 0x1bd60, + 0x1deb8, + 0x1ef5e, + 0x17a40, + // 520 + 0x1bd30, + 0x1de9c, + 0x17a20, + 0x1bd18, + 0x1de8e, + 0x17a10, + 0x1bd0c, + 0x17a08, + 0x1bd06, + 0x17a04, + // 530 + 0x13960, + 0x19cb8, + 0x1ce5e, + 0x17b60, + 0x13930, + 0x19c9c, + 0x17b30, + 0x1bd9c, + 0x19c8e, + 0x17b18, + // 540 + 0x1390c, + 0x17b0c, + 0x13906, + 0x17b06, + 0x118b8, + 0x18c5e, + 0x139b8, + 0x1189c, + 0x17bb8, + 0x1399c, + // 550 + 0x1188e, + 0x17b9c, + 0x1398e, + 0x17b8e, + 0x1085e, + 0x118de, + 0x139de, + 0x17bde, + 0x17940, + 0x1bcb0, + // 560 + 0x1de5c, + 0x17920, + 0x1bc98, + 0x1de4e, + 0x17910, + 0x1bc8c, + 0x17908, + 0x1bc86, + 0x17904, + 0x17902, + // 570 + 0x138b0, + 0x19c5c, + 0x179b0, + 0x13898, + 0x19c4e, + 0x17998, + 0x1bcce, + 0x1798c, + 0x13886, + 0x17986, + // 580 + 0x1185c, + 0x138dc, + 0x1184e, + 0x179dc, + 0x138ce, + 0x179ce, + 0x178a0, + 0x1bc58, + 0x1de2e, + 0x17890, + // 590 + 0x1bc4c, + 0x17888, + 0x1bc46, + 0x17884, + 0x17882, + 0x13858, + 0x19c2e, + 0x178d8, + 0x1384c, + 0x178cc, + // 600 + 0x13846, + 0x178c6, + 0x1182e, + 0x1386e, + 0x178ee, + 0x17850, + 0x1bc2c, + 0x17848, + 0x1bc26, + 0x17844, + // 610 + 0x17842, + 0x1382c, + 0x1786c, + 0x13826, + 0x17866, + 0x17828, + 0x1bc16, + 0x17824, + 0x17822, + 0x13816, + // 620 + 0x17836, + 0x10578, + 0x182be, + 0x1053c, + 0x1051e, + 0x105be, + 0x10d70, + 0x186bc, + 0x10d38, + 0x1869e, + // 630 + 0x10d1c, + 0x10d0e, + 0x104bc, + 0x10dbc, + 0x1049e, + 0x10d9e, + 0x11d60, + 0x18eb8, + 0x1c75e, + 0x11d30, + // 640 + 0x18e9c, + 0x11d18, + 0x18e8e, + 0x11d0c, + 0x11d06, + 0x10cb8, + 0x1865e, + 0x11db8, + 0x10c9c, + 0x11d9c, + // 650 + 0x10c8e, + 0x11d8e, + 0x1045e, + 0x10cde, + 0x11dde, + 0x13d40, + 0x19eb0, + 0x1cf5c, + 0x13d20, + 0x19e98, + // 660 + 0x1cf4e, + 0x13d10, + 0x19e8c, + 0x13d08, + 0x19e86, + 0x13d04, + 0x13d02, + 0x11cb0, + 0x18e5c, + 0x13db0, + // 670 + 0x11c98, + 0x18e4e, + 0x13d98, + 0x19ece, + 0x13d8c, + 0x11c86, + 0x13d86, + 0x10c5c, + 0x11cdc, + 0x10c4e, + // 680 + 0x13ddc, + 0x11cce, + 0x13dce, + 0x1bea0, + 0x1df58, + 0x1efae, + 0x1be90, + 0x1df4c, + 0x1be88, + 0x1df46, + // 690 + 0x1be84, + 0x1be82, + 0x13ca0, + 0x19e58, + 0x1cf2e, + 0x17da0, + 0x13c90, + 0x19e4c, + 0x17d90, + 0x1becc, + // 700 + 0x19e46, + 0x17d88, + 0x13c84, + 0x17d84, + 0x13c82, + 0x17d82, + 0x11c58, + 0x18e2e, + 0x13cd8, + 0x11c4c, + // 710 + 0x17dd8, + 0x13ccc, + 0x11c46, + 0x17dcc, + 0x13cc6, + 0x17dc6, + 0x10c2e, + 0x11c6e, + 0x13cee, + 0x17dee, + // 720 + 0x1be50, + 0x1df2c, + 0x1be48, + 0x1df26, + 0x1be44, + 0x1be42, + 0x13c50, + 0x19e2c, + 0x17cd0, + 0x13c48, + // 730 + 0x19e26, + 0x17cc8, + 0x1be66, + 0x17cc4, + 0x13c42, + 0x17cc2, + 0x11c2c, + 0x13c6c, + 0x11c26, + 0x17cec, + // 740 + 0x13c66, + 0x17ce6, + 0x1be28, + 0x1df16, + 0x1be24, + 0x1be22, + 0x13c28, + 0x19e16, + 0x17c68, + 0x13c24, + // 750 + 0x17c64, + 0x13c22, + 0x17c62, + 0x11c16, + 0x13c36, + 0x17c76, + 0x1be14, + 0x1be12, + 0x13c14, + 0x17c34, + // 760 + 0x13c12, + 0x17c32, + 0x102bc, + 0x1029e, + 0x106b8, + 0x1835e, + 0x1069c, + 0x1068e, + 0x1025e, + 0x106de, + // 770 + 0x10eb0, + 0x1875c, + 0x10e98, + 0x1874e, + 0x10e8c, + 0x10e86, + 0x1065c, + 0x10edc, + 0x1064e, + 0x10ece, + // 780 + 0x11ea0, + 0x18f58, + 0x1c7ae, + 0x11e90, + 0x18f4c, + 0x11e88, + 0x18f46, + 0x11e84, + 0x11e82, + 0x10e58, + // 790 + 0x1872e, + 0x11ed8, + 0x18f6e, + 0x11ecc, + 0x10e46, + 0x11ec6, + 0x1062e, + 0x10e6e, + 0x11eee, + 0x19f50, + // 800 + 0x1cfac, + 0x19f48, + 0x1cfa6, + 0x19f44, + 0x19f42, + 0x11e50, + 0x18f2c, + 0x13ed0, + 0x19f6c, + 0x18f26, + // 810 + 0x13ec8, + 0x11e44, + 0x13ec4, + 0x11e42, + 0x13ec2, + 0x10e2c, + 0x11e6c, + 0x10e26, + 0x13eec, + 0x11e66, + // 820 + 0x13ee6, + 0x1dfa8, + 0x1efd6, + 0x1dfa4, + 0x1dfa2, + 0x19f28, + 0x1cf96, + 0x1bf68, + 0x19f24, + 0x1bf64, + // 830 + 0x19f22, + 0x1bf62, + 0x11e28, + 0x18f16, + 0x13e68, + 0x11e24, + 0x17ee8, + 0x13e64, + 0x11e22, + 0x17ee4, + // 840 + 0x13e62, + 0x17ee2, + 0x10e16, + 0x11e36, + 0x13e76, + 0x17ef6, + 0x1df94, + 0x1df92, + 0x19f14, + 0x1bf34, + // 850 + 0x19f12, + 0x1bf32, + 0x11e14, + 0x13e34, + 0x11e12, + 0x17e74, + 0x13e32, + 0x17e72, + 0x1df8a, + 0x19f0a, + // 860 + 0x1bf1a, + 0x11e0a, + 0x13e1a, + 0x17e3a, + 0x1035c, + 0x1034e, + 0x10758, + 0x183ae, + 0x1074c, + 0x10746, + // 870 + 0x1032e, + 0x1076e, + 0x10f50, + 0x187ac, + 0x10f48, + 0x187a6, + 0x10f44, + 0x10f42, + 0x1072c, + 0x10f6c, + // 880 + 0x10726, + 0x10f66, + 0x18fa8, + 0x1c7d6, + 0x18fa4, + 0x18fa2, + 0x10f28, + 0x18796, + 0x11f68, + 0x18fb6, + // 890 + 0x11f64, + 0x10f22, + 0x11f62, + 0x10716, + 0x10f36, + 0x11f76, + 0x1cfd4, + 0x1cfd2, + 0x18f94, + 0x19fb4, + // 900 + 0x18f92, + 0x19fb2, + 0x10f14, + 0x11f34, + 0x10f12, + 0x13f74, + 0x11f32, + 0x13f72, + 0x1cfca, + 0x18f8a, + // 910 + 0x19f9a, + 0x10f0a, + 0x11f1a, + 0x13f3a, + 0x103ac, + 0x103a6, + 0x107a8, + 0x183d6, + 0x107a4, + 0x107a2, + // 920 + 0x10396, + 0x107b6, + 0x187d4, + 0x187d2, + 0x10794, + 0x10fb4, + 0x10792, + 0x10fb2, + 0x1c7ea, + ], + ]; /** * Array of factors of the Reed-Solomon polynomial equations used for error correction; * One sub array for each correction level (0-8). + * + * @var array> */ - public const RS_FACTORS = [[ - // ECL 0 (2 factors) ------------------------------------------------------------------------------- - 0x01b, - 0x395, - ], [ - // ECL 1 (4 factors) ------------------------------------------------------------------------------- - 0x20a, - 0x238, - 0x2d3, - 0x329, - ], [ - // ECL 2 (8 factors) ------------------------------------------------------------------------------- - 0x0ed, - 0x134, - 0x1b4, - 0x11c, - 0x286, - 0x28d, - 0x1ac, - 0x17b, - ], [ - // ECL 3 (16 factors) ------------------------------------------------------------------------------ - 0x112, - 0x232, - 0x0e8, - 0x2f3, - 0x257, - 0x20c, - 0x321, - 0x084, - 0x127, - 0x074, - 0x1ba, - 0x1ac, - 0x127, - 0x02a, - 0x0b0, - 0x041, - ], [ - // ECL 4 (32 factors) ------------------------------------------------------------------------------ - 0x169, - 0x23f, - 0x39a, - 0x20d, - 0x0b0, - 0x24a, - 0x280, - 0x141, - 0x218, - 0x2e6, - 0x2a5, - 0x2e6, - 0x2af, - 0x11c, - 0x0c1, - 0x205, - // 16 - 0x111, - 0x1ee, - 0x107, - 0x093, - 0x251, - 0x320, - 0x23b, - 0x140, - 0x323, - 0x085, - 0x0e7, - 0x186, - 0x2ad, - 0x14a, - 0x03f, - 0x19a, - ], [ - // ECL 5 (64 factors) ------------------------------------------------------------------------------ - 0x21b, - 0x1a6, - 0x006, - 0x05d, - 0x35e, - 0x303, - 0x1c5, - 0x06a, - 0x262, - 0x11f, - 0x06b, - 0x1f9, - 0x2dd, - 0x36d, - 0x17d, - 0x264, - // 16 - 0x2d3, - 0x1dc, - 0x1ce, - 0x0ac, - 0x1ae, - 0x261, - 0x35a, - 0x336, - 0x21f, - 0x178, - 0x1ff, - 0x190, - 0x2a0, - 0x2fa, - 0x11b, - 0x0b8, - // 32 - 0x1b8, - 0x023, - 0x207, - 0x01f, - 0x1cc, - 0x252, - 0x0e1, - 0x217, - 0x205, - 0x160, - 0x25d, - 0x09e, - 0x28b, - 0x0c9, - 0x1e8, - 0x1f6, - // 48 - 0x288, - 0x2dd, - 0x2cd, - 0x053, - 0x194, - 0x061, - 0x118, - 0x303, - 0x348, - 0x275, - 0x004, - 0x17d, - 0x34b, - 0x26f, - 0x108, - 0x21f, - ], [ - // ECL 6 (128 factors) ----------------------------------------------------------------------------- - 0x209, - 0x136, - 0x360, - 0x223, - 0x35a, - 0x244, - 0x128, - 0x17b, - 0x035, - 0x30b, - 0x381, - 0x1bc, - 0x190, - 0x39d, - 0x2ed, - 0x19f, - // 16 - 0x336, - 0x05d, - 0x0d9, - 0x0d0, - 0x3a0, - 0x0f4, - 0x247, - 0x26c, - 0x0f6, - 0x094, - 0x1bf, - 0x277, - 0x124, - 0x38c, - 0x1ea, - 0x2c0, - // 32 - 0x204, - 0x102, - 0x1c9, - 0x38b, - 0x252, - 0x2d3, - 0x2a2, - 0x124, - 0x110, - 0x060, - 0x2ac, - 0x1b0, - 0x2ae, - 0x25e, - 0x35c, - 0x239, - // 48 - 0x0c1, - 0x0db, - 0x081, - 0x0ba, - 0x0ec, - 0x11f, - 0x0c0, - 0x307, - 0x116, - 0x0ad, - 0x028, - 0x17b, - 0x2c8, - 0x1cf, - 0x286, - 0x308, - // 64 - 0x0ab, - 0x1eb, - 0x129, - 0x2fb, - 0x09c, - 0x2dc, - 0x05f, - 0x10e, - 0x1bf, - 0x05a, - 0x1fb, - 0x030, - 0x0e4, - 0x335, - 0x328, - 0x382, - // 80 - 0x310, - 0x297, - 0x273, - 0x17a, - 0x17e, - 0x106, - 0x17c, - 0x25a, - 0x2f2, - 0x150, - 0x059, - 0x266, - 0x057, - 0x1b0, - 0x29e, - 0x268, - // 96 - 0x09d, - 0x176, - 0x0f2, - 0x2d6, - 0x258, - 0x10d, - 0x177, - 0x382, - 0x34d, - 0x1c6, - 0x162, - 0x082, - 0x32e, - 0x24b, - 0x324, - 0x022, - // 112 - 0x0d3, - 0x14a, - 0x21b, - 0x129, - 0x33b, - 0x361, - 0x025, - 0x205, - 0x342, - 0x13b, - 0x226, - 0x056, - 0x321, - 0x004, - 0x06c, - 0x21b, - ], [ - // ECL 7 (256 factors) ----------------------------------------------------------------------------- - 0x20c, - 0x37e, - 0x04b, - 0x2fe, - 0x372, - 0x359, - 0x04a, - 0x0cc, - 0x052, - 0x24a, - 0x2c4, - 0x0fa, - 0x389, - 0x312, - 0x08a, - 0x2d0, - // 16 - 0x35a, - 0x0c2, - 0x137, - 0x391, - 0x113, - 0x0be, - 0x177, - 0x352, - 0x1b6, - 0x2dd, - 0x0c2, - 0x118, - 0x0c9, - 0x118, - 0x33c, - 0x2f5, - // 32 - 0x2c6, - 0x32e, - 0x397, - 0x059, - 0x044, - 0x239, - 0x00b, - 0x0cc, - 0x31c, - 0x25d, - 0x21c, - 0x391, - 0x321, - 0x2bc, - 0x31f, - 0x089, - // 48 - 0x1b7, - 0x1a2, - 0x250, - 0x29c, - 0x161, - 0x35b, - 0x172, - 0x2b6, - 0x145, - 0x0f0, - 0x0d8, - 0x101, - 0x11c, - 0x225, - 0x0d1, - 0x374, - // 64 - 0x13b, - 0x046, - 0x149, - 0x319, - 0x1ea, - 0x112, - 0x36d, - 0x0a2, - 0x2ed, - 0x32c, - 0x2ac, - 0x1cd, - 0x14e, - 0x178, - 0x351, - 0x209, - // 80 - 0x133, - 0x123, - 0x323, - 0x2c8, - 0x013, - 0x166, - 0x18f, - 0x38c, - 0x067, - 0x1ff, - 0x033, - 0x008, - 0x205, - 0x0e1, - 0x121, - 0x1d6, - // 96 - 0x27d, - 0x2db, - 0x042, - 0x0ff, - 0x395, - 0x10d, - 0x1cf, - 0x33e, - 0x2da, - 0x1b1, - 0x350, - 0x249, - 0x088, - 0x21a, - 0x38a, - 0x05a, - // 112 - 0x002, - 0x122, - 0x2e7, - 0x0c7, - 0x28f, - 0x387, - 0x149, - 0x031, - 0x322, - 0x244, - 0x163, - 0x24c, - 0x0bc, - 0x1ce, - 0x00a, - 0x086, - // 128 - 0x274, - 0x140, - 0x1df, - 0x082, - 0x2e3, - 0x047, - 0x107, - 0x13e, - 0x176, - 0x259, - 0x0c0, - 0x25d, - 0x08e, - 0x2a1, - 0x2af, - 0x0ea, - // 144 - 0x2d2, - 0x180, - 0x0b1, - 0x2f0, - 0x25f, - 0x280, - 0x1c7, - 0x0c1, - 0x2b1, - 0x2c3, - 0x325, - 0x281, - 0x030, - 0x03c, - 0x2dc, - 0x26d, - // 160 - 0x37f, - 0x220, - 0x105, - 0x354, - 0x28f, - 0x135, - 0x2b9, - 0x2f3, - 0x2f4, - 0x03c, - 0x0e7, - 0x305, - 0x1b2, - 0x1a5, - 0x2d6, - 0x210, - // 176 - 0x1f7, - 0x076, - 0x031, - 0x31b, - 0x020, - 0x090, - 0x1f4, - 0x0ee, - 0x344, - 0x18a, - 0x118, - 0x236, - 0x13f, - 0x009, - 0x287, - 0x226, - // 192 - 0x049, - 0x392, - 0x156, - 0x07e, - 0x020, - 0x2a9, - 0x14b, - 0x318, - 0x26c, - 0x03c, - 0x261, - 0x1b9, - 0x0b4, - 0x317, - 0x37d, - 0x2f2, - // 208 - 0x25d, - 0x17f, - 0x0e4, - 0x2ed, - 0x2f8, - 0x0d5, - 0x036, - 0x129, - 0x086, - 0x036, - 0x342, - 0x12b, - 0x39a, - 0x0bf, - 0x38e, - 0x214, - // 224 - 0x261, - 0x33d, - 0x0bd, - 0x014, - 0x0a7, - 0x01d, - 0x368, - 0x1c1, - 0x053, - 0x192, - 0x029, - 0x290, - 0x1f9, - 0x243, - 0x1e1, - 0x0ad, - // 240 - 0x194, - 0x0fb, - 0x2b0, - 0x05f, - 0x1f1, - 0x22b, - 0x282, - 0x21f, - 0x133, - 0x09f, - 0x39c, - 0x22e, - 0x288, - 0x037, - 0x1f1, - 0x00a, - ], [ - // ECL 8 (512 factors) ----------------------------------------------------------------------------- - 0x160, - 0x04d, - 0x175, - 0x1f8, - 0x023, - 0x257, - 0x1ac, - 0x0cf, - 0x199, - 0x23e, - 0x076, - 0x1f2, - 0x11d, - 0x17c, - 0x15e, - 0x1ec, - // 16 - 0x0c5, - 0x109, - 0x398, - 0x09b, - 0x392, - 0x12b, - 0x0e5, - 0x283, - 0x126, - 0x367, - 0x132, - 0x058, - 0x057, - 0x0c1, - 0x160, - 0x30d, - // 32 - 0x34e, - 0x04b, - 0x147, - 0x208, - 0x1b3, - 0x21f, - 0x0cb, - 0x29a, - 0x0f9, - 0x15a, - 0x30d, - 0x26d, - 0x280, - 0x10c, - 0x31a, - 0x216, - // 48 - 0x21b, - 0x30d, - 0x198, - 0x186, - 0x284, - 0x066, - 0x1dc, - 0x1f3, - 0x122, - 0x278, - 0x221, - 0x025, - 0x35a, - 0x394, - 0x228, - 0x029, - // 64 - 0x21e, - 0x121, - 0x07a, - 0x110, - 0x17f, - 0x320, - 0x1e5, - 0x062, - 0x2f0, - 0x1d8, - 0x2f9, - 0x06b, - 0x310, - 0x35c, - 0x292, - 0x2e5, - // 80 - 0x122, - 0x0cc, - 0x2a9, - 0x197, - 0x357, - 0x055, - 0x063, - 0x03e, - 0x1e2, - 0x0b4, - 0x014, - 0x129, - 0x1c3, - 0x251, - 0x391, - 0x08e, - // 96 - 0x328, - 0x2ac, - 0x11f, - 0x218, - 0x231, - 0x04c, - 0x28d, - 0x383, - 0x2d9, - 0x237, - 0x2e8, - 0x186, - 0x201, - 0x0c0, - 0x204, - 0x102, - // 112 - 0x0f0, - 0x206, - 0x31a, - 0x18b, - 0x300, - 0x350, - 0x033, - 0x262, - 0x180, - 0x0a8, - 0x0be, - 0x33a, - 0x148, - 0x254, - 0x312, - 0x12f, - // 128 - 0x23a, - 0x17d, - 0x19f, - 0x281, - 0x09c, - 0x0ed, - 0x097, - 0x1ad, - 0x213, - 0x0cf, - 0x2a4, - 0x2c6, - 0x059, - 0x0a8, - 0x130, - 0x192, - // 144 - 0x028, - 0x2c4, - 0x23f, - 0x0a2, - 0x360, - 0x0e5, - 0x041, - 0x35d, - 0x349, - 0x200, - 0x0a4, - 0x1dd, - 0x0dd, - 0x05c, - 0x166, - 0x311, - // 160 - 0x120, - 0x165, - 0x352, - 0x344, - 0x33b, - 0x2e0, - 0x2c3, - 0x05e, - 0x008, - 0x1ee, - 0x072, - 0x209, - 0x002, - 0x1f3, - 0x353, - 0x21f, - // 176 - 0x098, - 0x2d9, - 0x303, - 0x05f, - 0x0f8, - 0x169, - 0x242, - 0x143, - 0x358, - 0x31d, - 0x121, - 0x033, - 0x2ac, - 0x1d2, - 0x215, - 0x334, - // 192 - 0x29d, - 0x02d, - 0x386, - 0x1c4, - 0x0a7, - 0x156, - 0x0f4, - 0x0ad, - 0x023, - 0x1cf, - 0x28b, - 0x033, - 0x2bb, - 0x24f, - 0x1c4, - 0x242, - // 208 - 0x025, - 0x07c, - 0x12a, - 0x14c, - 0x228, - 0x02b, - 0x1ab, - 0x077, - 0x296, - 0x309, - 0x1db, - 0x352, - 0x2fc, - 0x16c, - 0x242, - 0x38f, - // 224 - 0x11b, - 0x2c7, - 0x1d8, - 0x1a4, - 0x0f5, - 0x120, - 0x252, - 0x18a, - 0x1ff, - 0x147, - 0x24d, - 0x309, - 0x2bb, - 0x2b0, - 0x02b, - 0x198, - // 240 - 0x34a, - 0x17f, - 0x2d1, - 0x209, - 0x230, - 0x284, - 0x2ca, - 0x22f, - 0x03e, - 0x091, - 0x369, - 0x297, - 0x2c9, - 0x09f, - 0x2a0, - 0x2d9, - // 256 - 0x270, - 0x03b, - 0x0c1, - 0x1a1, - 0x09e, - 0x0d1, - 0x233, - 0x234, - 0x157, - 0x2b5, - 0x06d, - 0x260, - 0x233, - 0x16d, - 0x0b5, - 0x304, - // 272 - 0x2a5, - 0x136, - 0x0f8, - 0x161, - 0x2c4, - 0x19a, - 0x243, - 0x366, - 0x269, - 0x349, - 0x278, - 0x35c, - 0x121, - 0x218, - 0x023, - 0x309, - // 288 - 0x26a, - 0x24a, - 0x1a8, - 0x341, - 0x04d, - 0x255, - 0x15a, - 0x10d, - 0x2f5, - 0x278, - 0x2b7, - 0x2ef, - 0x14b, - 0x0f7, - 0x0b8, - 0x02d, - // 304 - 0x313, - 0x2a8, - 0x012, - 0x042, - 0x197, - 0x171, - 0x036, - 0x1ec, - 0x0e4, - 0x265, - 0x33e, - 0x39a, - 0x1b5, - 0x207, - 0x284, - 0x389, - // 320 - 0x315, - 0x1a4, - 0x131, - 0x1b9, - 0x0cf, - 0x12c, - 0x37c, - 0x33b, - 0x08d, - 0x219, - 0x17d, - 0x296, - 0x201, - 0x038, - 0x0fc, - 0x155, - // 336 - 0x0f2, - 0x31d, - 0x346, - 0x345, - 0x2d0, - 0x0e0, - 0x133, - 0x277, - 0x03d, - 0x057, - 0x230, - 0x136, - 0x2f4, - 0x299, - 0x18d, - 0x328, - // 352 - 0x353, - 0x135, - 0x1d9, - 0x31b, - 0x17a, - 0x01f, - 0x287, - 0x393, - 0x1cb, - 0x326, - 0x24e, - 0x2db, - 0x1a9, - 0x0d8, - 0x224, - 0x0f9, - // 368 - 0x141, - 0x371, - 0x2bb, - 0x217, - 0x2a1, - 0x30e, - 0x0d2, - 0x32f, - 0x389, - 0x12f, - 0x34b, - 0x39a, - 0x119, - 0x049, - 0x1d5, - 0x317, - // 384 - 0x294, - 0x0a2, - 0x1f2, - 0x134, - 0x09b, - 0x1a6, - 0x38b, - 0x331, - 0x0bb, - 0x03e, - 0x010, - 0x1a9, - 0x217, - 0x150, - 0x11e, - 0x1b5, - // 400 - 0x177, - 0x111, - 0x262, - 0x128, - 0x0b7, - 0x39b, - 0x074, - 0x29b, - 0x2ef, - 0x161, - 0x03e, - 0x16e, - 0x2b3, - 0x17b, - 0x2af, - 0x34a, - // 416 - 0x025, - 0x165, - 0x2d0, - 0x2e6, - 0x14a, - 0x005, - 0x027, - 0x39b, - 0x137, - 0x1a8, - 0x0f2, - 0x2ed, - 0x141, - 0x036, - 0x29d, - 0x13c, - // 432 - 0x156, - 0x12b, - 0x216, - 0x069, - 0x29b, - 0x1e8, - 0x280, - 0x2a0, - 0x240, - 0x21c, - 0x13c, - 0x1e6, - 0x2d1, - 0x262, - 0x02e, - 0x290, - // 448 - 0x1bf, - 0x0ab, - 0x268, - 0x1d0, - 0x0be, - 0x213, - 0x129, - 0x141, - 0x2fa, - 0x2f0, - 0x215, - 0x0af, - 0x086, - 0x00e, - 0x17d, - 0x1b1, - // 464 - 0x2cd, - 0x02d, - 0x06f, - 0x014, - 0x254, - 0x11c, - 0x2e0, - 0x08a, - 0x286, - 0x19b, - 0x36d, - 0x29d, - 0x08d, - 0x397, - 0x02d, - 0x30c, - // 480 - 0x197, - 0x0a4, - 0x14c, - 0x383, - 0x0a5, - 0x2d6, - 0x258, - 0x145, - 0x1f2, - 0x28f, - 0x165, - 0x2f0, - 0x300, - 0x0df, - 0x351, - 0x287, - // 496 - 0x03f, - 0x136, - 0x35f, - 0x0fb, - 0x16e, - 0x130, - 0x11a, - 0x2e2, - 0x2a3, - 0x19a, - 0x185, - 0x0f4, - 0x01f, - 0x079, - 0x12f, - 0x107, - ]]; + public const RS_FACTORS = [ + [ + // ECL 0 (2 factors) ------------------------------------------------------------------------------- + 0x01b, + 0x395, + ], + [ + // ECL 1 (4 factors) ------------------------------------------------------------------------------- + 0x20a, + 0x238, + 0x2d3, + 0x329, + ], + [ + // ECL 2 (8 factors) ------------------------------------------------------------------------------- + 0x0ed, + 0x134, + 0x1b4, + 0x11c, + 0x286, + 0x28d, + 0x1ac, + 0x17b, + ], + [ + // ECL 3 (16 factors) ------------------------------------------------------------------------------ + 0x112, + 0x232, + 0x0e8, + 0x2f3, + 0x257, + 0x20c, + 0x321, + 0x084, + 0x127, + 0x074, + 0x1ba, + 0x1ac, + 0x127, + 0x02a, + 0x0b0, + 0x041, + ], + [ + // ECL 4 (32 factors) ------------------------------------------------------------------------------ + 0x169, + 0x23f, + 0x39a, + 0x20d, + 0x0b0, + 0x24a, + 0x280, + 0x141, + 0x218, + 0x2e6, + 0x2a5, + 0x2e6, + 0x2af, + 0x11c, + 0x0c1, + 0x205, + // 16 + 0x111, + 0x1ee, + 0x107, + 0x093, + 0x251, + 0x320, + 0x23b, + 0x140, + 0x323, + 0x085, + 0x0e7, + 0x186, + 0x2ad, + 0x14a, + 0x03f, + 0x19a, + ], + [ + // ECL 5 (64 factors) ------------------------------------------------------------------------------ + 0x21b, + 0x1a6, + 0x006, + 0x05d, + 0x35e, + 0x303, + 0x1c5, + 0x06a, + 0x262, + 0x11f, + 0x06b, + 0x1f9, + 0x2dd, + 0x36d, + 0x17d, + 0x264, + // 16 + 0x2d3, + 0x1dc, + 0x1ce, + 0x0ac, + 0x1ae, + 0x261, + 0x35a, + 0x336, + 0x21f, + 0x178, + 0x1ff, + 0x190, + 0x2a0, + 0x2fa, + 0x11b, + 0x0b8, + // 32 + 0x1b8, + 0x023, + 0x207, + 0x01f, + 0x1cc, + 0x252, + 0x0e1, + 0x217, + 0x205, + 0x160, + 0x25d, + 0x09e, + 0x28b, + 0x0c9, + 0x1e8, + 0x1f6, + // 48 + 0x288, + 0x2dd, + 0x2cd, + 0x053, + 0x194, + 0x061, + 0x118, + 0x303, + 0x348, + 0x275, + 0x004, + 0x17d, + 0x34b, + 0x26f, + 0x108, + 0x21f, + ], + [ + // ECL 6 (128 factors) ----------------------------------------------------------------------------- + 0x209, + 0x136, + 0x360, + 0x223, + 0x35a, + 0x244, + 0x128, + 0x17b, + 0x035, + 0x30b, + 0x381, + 0x1bc, + 0x190, + 0x39d, + 0x2ed, + 0x19f, + // 16 + 0x336, + 0x05d, + 0x0d9, + 0x0d0, + 0x3a0, + 0x0f4, + 0x247, + 0x26c, + 0x0f6, + 0x094, + 0x1bf, + 0x277, + 0x124, + 0x38c, + 0x1ea, + 0x2c0, + // 32 + 0x204, + 0x102, + 0x1c9, + 0x38b, + 0x252, + 0x2d3, + 0x2a2, + 0x124, + 0x110, + 0x060, + 0x2ac, + 0x1b0, + 0x2ae, + 0x25e, + 0x35c, + 0x239, + // 48 + 0x0c1, + 0x0db, + 0x081, + 0x0ba, + 0x0ec, + 0x11f, + 0x0c0, + 0x307, + 0x116, + 0x0ad, + 0x028, + 0x17b, + 0x2c8, + 0x1cf, + 0x286, + 0x308, + // 64 + 0x0ab, + 0x1eb, + 0x129, + 0x2fb, + 0x09c, + 0x2dc, + 0x05f, + 0x10e, + 0x1bf, + 0x05a, + 0x1fb, + 0x030, + 0x0e4, + 0x335, + 0x328, + 0x382, + // 80 + 0x310, + 0x297, + 0x273, + 0x17a, + 0x17e, + 0x106, + 0x17c, + 0x25a, + 0x2f2, + 0x150, + 0x059, + 0x266, + 0x057, + 0x1b0, + 0x29e, + 0x268, + // 96 + 0x09d, + 0x176, + 0x0f2, + 0x2d6, + 0x258, + 0x10d, + 0x177, + 0x382, + 0x34d, + 0x1c6, + 0x162, + 0x082, + 0x32e, + 0x24b, + 0x324, + 0x022, + // 112 + 0x0d3, + 0x14a, + 0x21b, + 0x129, + 0x33b, + 0x361, + 0x025, + 0x205, + 0x342, + 0x13b, + 0x226, + 0x056, + 0x321, + 0x004, + 0x06c, + 0x21b, + ], + [ + // ECL 7 (256 factors) ----------------------------------------------------------------------------- + 0x20c, + 0x37e, + 0x04b, + 0x2fe, + 0x372, + 0x359, + 0x04a, + 0x0cc, + 0x052, + 0x24a, + 0x2c4, + 0x0fa, + 0x389, + 0x312, + 0x08a, + 0x2d0, + // 16 + 0x35a, + 0x0c2, + 0x137, + 0x391, + 0x113, + 0x0be, + 0x177, + 0x352, + 0x1b6, + 0x2dd, + 0x0c2, + 0x118, + 0x0c9, + 0x118, + 0x33c, + 0x2f5, + // 32 + 0x2c6, + 0x32e, + 0x397, + 0x059, + 0x044, + 0x239, + 0x00b, + 0x0cc, + 0x31c, + 0x25d, + 0x21c, + 0x391, + 0x321, + 0x2bc, + 0x31f, + 0x089, + // 48 + 0x1b7, + 0x1a2, + 0x250, + 0x29c, + 0x161, + 0x35b, + 0x172, + 0x2b6, + 0x145, + 0x0f0, + 0x0d8, + 0x101, + 0x11c, + 0x225, + 0x0d1, + 0x374, + // 64 + 0x13b, + 0x046, + 0x149, + 0x319, + 0x1ea, + 0x112, + 0x36d, + 0x0a2, + 0x2ed, + 0x32c, + 0x2ac, + 0x1cd, + 0x14e, + 0x178, + 0x351, + 0x209, + // 80 + 0x133, + 0x123, + 0x323, + 0x2c8, + 0x013, + 0x166, + 0x18f, + 0x38c, + 0x067, + 0x1ff, + 0x033, + 0x008, + 0x205, + 0x0e1, + 0x121, + 0x1d6, + // 96 + 0x27d, + 0x2db, + 0x042, + 0x0ff, + 0x395, + 0x10d, + 0x1cf, + 0x33e, + 0x2da, + 0x1b1, + 0x350, + 0x249, + 0x088, + 0x21a, + 0x38a, + 0x05a, + // 112 + 0x002, + 0x122, + 0x2e7, + 0x0c7, + 0x28f, + 0x387, + 0x149, + 0x031, + 0x322, + 0x244, + 0x163, + 0x24c, + 0x0bc, + 0x1ce, + 0x00a, + 0x086, + // 128 + 0x274, + 0x140, + 0x1df, + 0x082, + 0x2e3, + 0x047, + 0x107, + 0x13e, + 0x176, + 0x259, + 0x0c0, + 0x25d, + 0x08e, + 0x2a1, + 0x2af, + 0x0ea, + // 144 + 0x2d2, + 0x180, + 0x0b1, + 0x2f0, + 0x25f, + 0x280, + 0x1c7, + 0x0c1, + 0x2b1, + 0x2c3, + 0x325, + 0x281, + 0x030, + 0x03c, + 0x2dc, + 0x26d, + // 160 + 0x37f, + 0x220, + 0x105, + 0x354, + 0x28f, + 0x135, + 0x2b9, + 0x2f3, + 0x2f4, + 0x03c, + 0x0e7, + 0x305, + 0x1b2, + 0x1a5, + 0x2d6, + 0x210, + // 176 + 0x1f7, + 0x076, + 0x031, + 0x31b, + 0x020, + 0x090, + 0x1f4, + 0x0ee, + 0x344, + 0x18a, + 0x118, + 0x236, + 0x13f, + 0x009, + 0x287, + 0x226, + // 192 + 0x049, + 0x392, + 0x156, + 0x07e, + 0x020, + 0x2a9, + 0x14b, + 0x318, + 0x26c, + 0x03c, + 0x261, + 0x1b9, + 0x0b4, + 0x317, + 0x37d, + 0x2f2, + // 208 + 0x25d, + 0x17f, + 0x0e4, + 0x2ed, + 0x2f8, + 0x0d5, + 0x036, + 0x129, + 0x086, + 0x036, + 0x342, + 0x12b, + 0x39a, + 0x0bf, + 0x38e, + 0x214, + // 224 + 0x261, + 0x33d, + 0x0bd, + 0x014, + 0x0a7, + 0x01d, + 0x368, + 0x1c1, + 0x053, + 0x192, + 0x029, + 0x290, + 0x1f9, + 0x243, + 0x1e1, + 0x0ad, + // 240 + 0x194, + 0x0fb, + 0x2b0, + 0x05f, + 0x1f1, + 0x22b, + 0x282, + 0x21f, + 0x133, + 0x09f, + 0x39c, + 0x22e, + 0x288, + 0x037, + 0x1f1, + 0x00a, + ], + [ + // ECL 8 (512 factors) ----------------------------------------------------------------------------- + 0x160, + 0x04d, + 0x175, + 0x1f8, + 0x023, + 0x257, + 0x1ac, + 0x0cf, + 0x199, + 0x23e, + 0x076, + 0x1f2, + 0x11d, + 0x17c, + 0x15e, + 0x1ec, + // 16 + 0x0c5, + 0x109, + 0x398, + 0x09b, + 0x392, + 0x12b, + 0x0e5, + 0x283, + 0x126, + 0x367, + 0x132, + 0x058, + 0x057, + 0x0c1, + 0x160, + 0x30d, + // 32 + 0x34e, + 0x04b, + 0x147, + 0x208, + 0x1b3, + 0x21f, + 0x0cb, + 0x29a, + 0x0f9, + 0x15a, + 0x30d, + 0x26d, + 0x280, + 0x10c, + 0x31a, + 0x216, + // 48 + 0x21b, + 0x30d, + 0x198, + 0x186, + 0x284, + 0x066, + 0x1dc, + 0x1f3, + 0x122, + 0x278, + 0x221, + 0x025, + 0x35a, + 0x394, + 0x228, + 0x029, + // 64 + 0x21e, + 0x121, + 0x07a, + 0x110, + 0x17f, + 0x320, + 0x1e5, + 0x062, + 0x2f0, + 0x1d8, + 0x2f9, + 0x06b, + 0x310, + 0x35c, + 0x292, + 0x2e5, + // 80 + 0x122, + 0x0cc, + 0x2a9, + 0x197, + 0x357, + 0x055, + 0x063, + 0x03e, + 0x1e2, + 0x0b4, + 0x014, + 0x129, + 0x1c3, + 0x251, + 0x391, + 0x08e, + // 96 + 0x328, + 0x2ac, + 0x11f, + 0x218, + 0x231, + 0x04c, + 0x28d, + 0x383, + 0x2d9, + 0x237, + 0x2e8, + 0x186, + 0x201, + 0x0c0, + 0x204, + 0x102, + // 112 + 0x0f0, + 0x206, + 0x31a, + 0x18b, + 0x300, + 0x350, + 0x033, + 0x262, + 0x180, + 0x0a8, + 0x0be, + 0x33a, + 0x148, + 0x254, + 0x312, + 0x12f, + // 128 + 0x23a, + 0x17d, + 0x19f, + 0x281, + 0x09c, + 0x0ed, + 0x097, + 0x1ad, + 0x213, + 0x0cf, + 0x2a4, + 0x2c6, + 0x059, + 0x0a8, + 0x130, + 0x192, + // 144 + 0x028, + 0x2c4, + 0x23f, + 0x0a2, + 0x360, + 0x0e5, + 0x041, + 0x35d, + 0x349, + 0x200, + 0x0a4, + 0x1dd, + 0x0dd, + 0x05c, + 0x166, + 0x311, + // 160 + 0x120, + 0x165, + 0x352, + 0x344, + 0x33b, + 0x2e0, + 0x2c3, + 0x05e, + 0x008, + 0x1ee, + 0x072, + 0x209, + 0x002, + 0x1f3, + 0x353, + 0x21f, + // 176 + 0x098, + 0x2d9, + 0x303, + 0x05f, + 0x0f8, + 0x169, + 0x242, + 0x143, + 0x358, + 0x31d, + 0x121, + 0x033, + 0x2ac, + 0x1d2, + 0x215, + 0x334, + // 192 + 0x29d, + 0x02d, + 0x386, + 0x1c4, + 0x0a7, + 0x156, + 0x0f4, + 0x0ad, + 0x023, + 0x1cf, + 0x28b, + 0x033, + 0x2bb, + 0x24f, + 0x1c4, + 0x242, + // 208 + 0x025, + 0x07c, + 0x12a, + 0x14c, + 0x228, + 0x02b, + 0x1ab, + 0x077, + 0x296, + 0x309, + 0x1db, + 0x352, + 0x2fc, + 0x16c, + 0x242, + 0x38f, + // 224 + 0x11b, + 0x2c7, + 0x1d8, + 0x1a4, + 0x0f5, + 0x120, + 0x252, + 0x18a, + 0x1ff, + 0x147, + 0x24d, + 0x309, + 0x2bb, + 0x2b0, + 0x02b, + 0x198, + // 240 + 0x34a, + 0x17f, + 0x2d1, + 0x209, + 0x230, + 0x284, + 0x2ca, + 0x22f, + 0x03e, + 0x091, + 0x369, + 0x297, + 0x2c9, + 0x09f, + 0x2a0, + 0x2d9, + // 256 + 0x270, + 0x03b, + 0x0c1, + 0x1a1, + 0x09e, + 0x0d1, + 0x233, + 0x234, + 0x157, + 0x2b5, + 0x06d, + 0x260, + 0x233, + 0x16d, + 0x0b5, + 0x304, + // 272 + 0x2a5, + 0x136, + 0x0f8, + 0x161, + 0x2c4, + 0x19a, + 0x243, + 0x366, + 0x269, + 0x349, + 0x278, + 0x35c, + 0x121, + 0x218, + 0x023, + 0x309, + // 288 + 0x26a, + 0x24a, + 0x1a8, + 0x341, + 0x04d, + 0x255, + 0x15a, + 0x10d, + 0x2f5, + 0x278, + 0x2b7, + 0x2ef, + 0x14b, + 0x0f7, + 0x0b8, + 0x02d, + // 304 + 0x313, + 0x2a8, + 0x012, + 0x042, + 0x197, + 0x171, + 0x036, + 0x1ec, + 0x0e4, + 0x265, + 0x33e, + 0x39a, + 0x1b5, + 0x207, + 0x284, + 0x389, + // 320 + 0x315, + 0x1a4, + 0x131, + 0x1b9, + 0x0cf, + 0x12c, + 0x37c, + 0x33b, + 0x08d, + 0x219, + 0x17d, + 0x296, + 0x201, + 0x038, + 0x0fc, + 0x155, + // 336 + 0x0f2, + 0x31d, + 0x346, + 0x345, + 0x2d0, + 0x0e0, + 0x133, + 0x277, + 0x03d, + 0x057, + 0x230, + 0x136, + 0x2f4, + 0x299, + 0x18d, + 0x328, + // 352 + 0x353, + 0x135, + 0x1d9, + 0x31b, + 0x17a, + 0x01f, + 0x287, + 0x393, + 0x1cb, + 0x326, + 0x24e, + 0x2db, + 0x1a9, + 0x0d8, + 0x224, + 0x0f9, + // 368 + 0x141, + 0x371, + 0x2bb, + 0x217, + 0x2a1, + 0x30e, + 0x0d2, + 0x32f, + 0x389, + 0x12f, + 0x34b, + 0x39a, + 0x119, + 0x049, + 0x1d5, + 0x317, + // 384 + 0x294, + 0x0a2, + 0x1f2, + 0x134, + 0x09b, + 0x1a6, + 0x38b, + 0x331, + 0x0bb, + 0x03e, + 0x010, + 0x1a9, + 0x217, + 0x150, + 0x11e, + 0x1b5, + // 400 + 0x177, + 0x111, + 0x262, + 0x128, + 0x0b7, + 0x39b, + 0x074, + 0x29b, + 0x2ef, + 0x161, + 0x03e, + 0x16e, + 0x2b3, + 0x17b, + 0x2af, + 0x34a, + // 416 + 0x025, + 0x165, + 0x2d0, + 0x2e6, + 0x14a, + 0x005, + 0x027, + 0x39b, + 0x137, + 0x1a8, + 0x0f2, + 0x2ed, + 0x141, + 0x036, + 0x29d, + 0x13c, + // 432 + 0x156, + 0x12b, + 0x216, + 0x069, + 0x29b, + 0x1e8, + 0x280, + 0x2a0, + 0x240, + 0x21c, + 0x13c, + 0x1e6, + 0x2d1, + 0x262, + 0x02e, + 0x290, + // 448 + 0x1bf, + 0x0ab, + 0x268, + 0x1d0, + 0x0be, + 0x213, + 0x129, + 0x141, + 0x2fa, + 0x2f0, + 0x215, + 0x0af, + 0x086, + 0x00e, + 0x17d, + 0x1b1, + // 464 + 0x2cd, + 0x02d, + 0x06f, + 0x014, + 0x254, + 0x11c, + 0x2e0, + 0x08a, + 0x286, + 0x19b, + 0x36d, + 0x29d, + 0x08d, + 0x397, + 0x02d, + 0x30c, + // 480 + 0x197, + 0x0a4, + 0x14c, + 0x383, + 0x0a5, + 0x2d6, + 0x258, + 0x145, + 0x1f2, + 0x28f, + 0x165, + 0x2f0, + 0x300, + 0x0df, + 0x351, + 0x287, + // 496 + 0x03f, + 0x136, + 0x35f, + 0x0fb, + 0x16e, + 0x130, + 0x11a, + 0x2e2, + 0x2a3, + 0x19a, + 0x185, + 0x0f4, + 0x01f, + 0x079, + 0x12f, + 0x107, + ], + ]; } diff --git a/src/Type/Square/QrCode/Data.php b/src/Type/Square/QrCode/Data.php index 2d8e0300..860a2890 100644 --- a/src/Type/Square/QrCode/Data.php +++ b/src/Type/Square/QrCode/Data.php @@ -33,11 +33,15 @@ class Data { /** * Maximum QR Code version. + * + * @var int */ public const QRSPEC_VERSION_MAX = 40; /** * Maximum matrix size for maximum version (version 40 is 177*177 matrix). + * + * @var int */ public const QRSPEC_WIDTH_MAX = 177; @@ -45,21 +49,29 @@ class Data /** * Matrix index to get width from CAPACITY array. + * + * @var int */ public const QRCAP_WIDTH = 0; /** * Matrix index to get number of words from CAPACITY array. + * + * @var int */ public const QRCAP_WORDS = 1; /** * Matrix index to get remainder from CAPACITY array. + * + * @var int */ public const QRCAP_REMINDER = 2; /** * Matrix index to get error correction level from CAPACITY array. + * + * @var int */ public const QRCAP_EC = 3; @@ -69,11 +81,15 @@ class Data /** * Number of header bits for structured mode + * + * @var int */ public const STRUCTURE_HEADER_BITS = 20; /** * Max number of symbols for structured mode + * + * @var int */ public const MAX_STRUCTURED_SYMBOLS = 16; @@ -83,22 +99,30 @@ class Data /** * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column) + * + * @var int */ public const N1 = 3; /** * Down point base value for case 2 mask pattern (module block of same color) + * + * @var int */ public const N2 = 3; /** * Down point base value for case 3 mask pattern - * (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column) + * (1:1:3:1:1 (dark:bright:dark:bright:dark) pattern in a line or a column) + * + * @var int */ public const N3 = 40; /** * Down point base value for case 4 mask pattern (ration of dark modules in whole) + * + * @var int */ public const N4 = 10; @@ -111,6 +135,8 @@ class Data * 8B : Encoding mode 8bit byte data. In theory, 2953 characters or less can be stored in a QRcode. * KJ : Encoding mode KANJI. A KANJI character (multibyte character) is encoded to 13bit length. * ST : Encoding mode STRUCTURED + * + * @var array */ public const ENC_MODES = [ 'NL' => -1, @@ -129,6 +155,8 @@ class Data * M : About 15% or less errors can be corrected. * Q : About 25% or less errors can be corrected. * H : About 30% or less errors can be corrected. + * + * @var array */ public const ECC_LEVELS = [ 'L' => 0, @@ -139,6 +167,8 @@ class Data /** * Alphabet-numeric conversion table. + * + * @var array */ public const AN_TABLE = [ -1, @@ -281,6 +311,8 @@ class Data /** * Array Table of the capacity of symbols. * See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004. + * + * @var array */ public const CAPACITY = [ [0, 0, 0, [0, 0, 0, 0]], @@ -328,6 +360,8 @@ class Data /** * Array Length indicator. + * + * @var array */ public const LEN_TABLE_BITS = [ [10, 12, 14], @@ -339,6 +373,8 @@ class Data /** * Array Table of the error correction code (Reed-Solomon block). * See Table 12-16 (pp.30-36), JIS X0510:2004. + * + * @var array */ public const ECC_TABLE = [ [[0, 0], [0, 0], [0, 0], [0, 0]], @@ -389,6 +425,8 @@ class Data * This array includes only the second and the third position of the alignment patterns. * Rest of them can be calculated from the distance between them. * See Table 1 in Appendix E (pp.71) of JIS X0510:2004. + * + * @var array */ public const ALIGN_PATTERN = [ [0, 0], @@ -438,6 +476,8 @@ class Data * Array Version information pattern (BCH coded). * See Table 1 in Appendix D (pp.68) of JIS X0510:2004. * size: [QRSPEC_VERSION_MAX - 6] + * + * @var array */ public const VERSION_PATTERN = [ 0x07c94, @@ -478,6 +518,8 @@ class Data /** * Array Format information + * + * @var array */ public const FORMAT_INFO = [ [0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976], From c7e4e43b5d546d755bb9104547e1c2967ea7a431 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Tue, 21 Nov 2023 16:19:31 +0000 Subject: [PATCH 096/100] aztec --- src/Type/Square/Aztec/Bitstream.php | 29 ++++++++----- src/Type/Square/Aztec/Codeword.php | 15 +++---- src/Type/Square/Aztec/Encode.php | 6 ++- src/Type/Square/Aztec/ErrorCorrection.php | 50 +++++++++++++++-------- src/Type/Square/Aztec/Layers.php | 7 +++- 5 files changed, 69 insertions(+), 38 deletions(-) diff --git a/src/Type/Square/Aztec/Bitstream.php b/src/Type/Square/Aztec/Bitstream.php index fb7952ab..907aa830 100644 --- a/src/Type/Square/Aztec/Bitstream.php +++ b/src/Type/Square/Aztec/Bitstream.php @@ -16,6 +16,8 @@ namespace Com\Tecnick\Barcode\Type\Square\Aztec; +use Com\Tecnick\Barcode\Exception as BarcodeException; + /** * Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream * @@ -46,7 +48,12 @@ protected function highLevelEncoding( string $hint = 'A' ): void { $this->addFLG($eci); - $chars = array_values(unpack('C*', $code)); + $chrarr = unpack('C*', $code); + if ($chrarr === false) { + throw new BarcodeException('Unable to unpack the code'); + } + + $chars = array_values($chrarr); $chrlen = count($chars); if ($hint == 'B') { $this->binaryEncode($chars, $chrlen); @@ -59,7 +66,7 @@ protected function highLevelEncoding( /** * Forced binary encoding for the given characters. * - * @param array $chars Integer ASCII values of the characters to encode. + * @param array $chars Integer ASCII values of the characters to encode. * @param int $chrlen Lenght of the $chars array. */ protected function binaryEncode(array $chars, int $chrlen): void @@ -100,7 +107,7 @@ protected function binaryEncode(array $chars, int $chrlen): void /** * Automatic encoding for the given characters. * - * @param array $chars Integer ASCII values of the characters to encode. + * @param array $chars Integer ASCII values of the characters to encode. * @param int $chrlen Lenght of the $chars array. */ protected function autoEncode(array $chars, int $chrlen): void @@ -122,7 +129,7 @@ protected function autoEncode(array $chars, int $chrlen): void /** * Process mode characters. * - * @param array $chars The array of characters. + * @param array $chars The array of characters. * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. */ @@ -151,7 +158,7 @@ protected function processModeChars(array &$chars, int &$idx, int $chrlen): void /** * Count consecutive characters in the same mode. * - * @param array $chars The array of characters. + * @param array $chars The array of characters. * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. * @param int $mode The current mode. @@ -185,7 +192,7 @@ protected function countModeChars( /** * Process consecutive binary characters. * - * @param array $chars The array of characters. + * @param array $chars The array of characters. * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. * @@ -240,7 +247,7 @@ protected function processBinaryChars( /** * Count consecutive binary characters. * - * @param array $chars The array of characters. + * @param array $chars The array of characters. * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. * @@ -271,7 +278,7 @@ protected function countBinaryChars( /** * Process consecutive special Punctuation Pairs. * - * @param array $chars The array of characters. + * @param array $chars The array of characters. * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. * @@ -327,7 +334,7 @@ protected function processPunctPairs( /** * Count consecutive special Punctuation Pairs. * - * @param array $chars The array of characters. + * @param array $chars The array of characters. * @param int $idx The current character index. * @param int $chrlen The total number of characters to process. */ @@ -357,9 +364,11 @@ protected function countPunctPairs( * Counts the number of consecutive charcters that are in both PUNCT or DIGIT modes. * Returns the array with the codewords. * - * @param array &$chars The string to count the characters in. + * @param array &$chars The string to count the characters in. * @param int $idx The starting index to count from. * @param int $chrlen The length of the string to count. + * + * @return array The array of codewords. */ protected function countPunctAndDigitChars( array &$chars, diff --git a/src/Type/Square/Aztec/Codeword.php b/src/Type/Square/Aztec/Codeword.php index 874b1aa3..523891ee 100644 --- a/src/Type/Square/Aztec/Codeword.php +++ b/src/Type/Square/Aztec/Codeword.php @@ -38,19 +38,18 @@ abstract class Codeword /** * Array containing the high-level encoding bitstream. + * + * @var array */ protected array $bitstream = []; /** * Temporary array of codewords. + * + * @var array */ protected array $tmpCdws = []; - /** - * Array of data words. - */ - protected array $words = []; - /** * Count the total number of bits in the bitstream. */ @@ -131,7 +130,7 @@ protected function punctPairMode(int $ord, int $next): int /** * Append a new Codeword as a big-endian bit sequence. * - * @param array $bitstream Array of bits to append to. + * @param array $bitstream Array of bits to append to. * @param int $totbits Number of bits in the bitstream. * @param int $wsize The number of bits in the codeword. * @param int $value The value of the codeword. @@ -152,9 +151,11 @@ protected function appendWordToBitstream( /** * Convert the bitstream to words. * - * @param array $bitstream Array of bits to convert. + * @param array $bitstream Array of bits to convert. * @param int $totbits Number of bits in the bitstream. * @param int $wsize The word size. + * + * @return array Array of words. */ protected function bitstreamToWords( array $bitstream, diff --git a/src/Type/Square/Aztec/Encode.php b/src/Type/Square/Aztec/Encode.php index 5ccdb0a3..a96b6742 100644 --- a/src/Type/Square/Aztec/Encode.php +++ b/src/Type/Square/Aztec/Encode.php @@ -35,6 +35,8 @@ class Encode extends \Com\Tecnick\Barcode\Type\Square\Aztec\Bitstream { /** * Bidimensional grid containing the encoded data. + * + * @var array> */ protected array $grid = []; @@ -74,6 +76,8 @@ public function __construct( /** * Returns the bidimensional grid containing the encoded data. + * + * @return array> */ public function getGrid(): array { @@ -83,7 +87,7 @@ public function getGrid(): array /** * Returns the Check Codewords array for the given data words. * - * @param array $bitstream Array of bits. + * @param array $bitstream Array of bits. * @param int $totbits Number of bits in the bitstream. * @param int $nbits Number of bits per layer. * @param int $wsize Word size. diff --git a/src/Type/Square/Aztec/ErrorCorrection.php b/src/Type/Square/Aztec/ErrorCorrection.php index bd172e9b..318ff3d7 100644 --- a/src/Type/Square/Aztec/ErrorCorrection.php +++ b/src/Type/Square/Aztec/ErrorCorrection.php @@ -33,22 +33,22 @@ class ErrorCorrection { /** * Galois Field primitive by word size. + * + * @var array */ protected const GF = [ - 4 => 19, - // 10011 GF(16) (x^4 + x + 1) Mode message - 6 => 67, - // 1000011 GF(64) (x^6 + x + 1) 01–02 layers - 8 => 301, - // 100101101 GF(256) (x^8 + x^5 + x^3 + x^2 + 1) 03–08 layers - 10 => 1033, - // 10000001001 GF(1024) (x^10 + x^3 + 1) 09–22 layers - 12 => 4201, + 4 => 19, // 10011 GF(16) (x^4 + x + 1) Mode message + 6 => 67, // 1000011 GF(64) (x^6 + x + 1) 01–02 layers + 8 => 301, // 100101101 GF(256) (x^8 + x^5 + x^3 + x^2 + 1) 03–08 layers + 10 => 1033, // 10000001001 GF(1024) (x^10 + x^3 + 1) 09–22 layers + 12 => 4201, // 1000001101001 GF(4096) (x^12 + x^6 + x^5 + x^3 + 1) 23–32 layers ]; /** * Map the log and exp (inverse log) tables by word size. * NOTE: It is equal to 2^word_size. + * + * @var array */ protected const TSIZE = [ 4 => 16, @@ -60,11 +60,15 @@ class ErrorCorrection /** * Log table. + * + * @var array */ protected array $tlog = []; /** * Exponential (inverse log) table. + * + * @var array */ protected array $texp = []; @@ -86,8 +90,10 @@ public function __construct(int $wsize) /** * Returns the Reed-Solomon Error Correction Codewords added to the input data. * - * @param array $data Array of data codewords to process. + * @param array $data Array of data codewords to process. * @param int $necc Number of error correction bytes. + * + * @return array */ public function checkwords(array $data, int $necc): array { @@ -125,10 +131,10 @@ protected function genTables(int $wsize): void /** * Calculates the coefficients of the error correction polynomial. * - * @param array $data Array of data codewords to process. + * @param array $data Array of data codewords to process. * @param int $necc Number of error correction bytes. * - * @return array Array of coefficients. + * @return array Array of coefficients. */ protected function getCoefficients(array $data, int $necc): array { @@ -153,8 +159,10 @@ protected function getCoefficients(array $data, int $necc): array /** * Returns the product of two coefficient arrays. * - * @param array $acf First array of coefficients. - * @param array $bcf Second array of coefficients. + * @param array $acf First array of coefficients. + * @param array $bcf Second array of coefficients. + * + * @return array Array of coefficients. */ protected function multiplyCoeff(array $acf, array $bcf): array { @@ -188,7 +196,9 @@ protected function multiply(int $aval, int $bval): int /** * Left-trim coefficients array. * - * @param array $coeff Array of coefficients. + * @param array $coeff Array of coefficients. + * + * @return array Array of coefficients. */ protected function trimCoefficients(array $coeff): array { @@ -202,9 +212,11 @@ protected function trimCoefficients(array $coeff): array /** * Returns the product of a polynomial by a monomial. * - * @param array $coeff Array of polynomial coefficients. + * @param array $coeff Array of polynomial coefficients. * @param int $mon Monomial. * @param int $deg Degree of the monomial. + * + * @return array Array of coefficients. */ protected function multiplyByMonomial(array $coeff, int $mon, int $deg): array { @@ -223,8 +235,10 @@ protected function multiplyByMonomial(array $coeff, int $mon, int $deg): array /** * Adds or subtracts two coefficient arrays. * - * @param array $smaller The smaller array of coefficients. - * @param array $larger The larger array of coefficients. + * @param array $smaller The smaller array of coefficients. + * @param array $larger The larger array of coefficients. + * + * @return array Array of coefficients. */ protected function addOrSubtract(array $smaller, array $larger): array { diff --git a/src/Type/Square/Aztec/Layers.php b/src/Type/Square/Aztec/Layers.php index 6bf5347d..0dd4a90b 100644 --- a/src/Type/Square/Aztec/Layers.php +++ b/src/Type/Square/Aztec/Layers.php @@ -43,13 +43,16 @@ abstract class Layers extends \Com\Tecnick\Barcode\Type\Square\Aztec\Codeword /** * Size data for the selected layer. + * + * @var array{int, int, int, int, int, int, int} */ - protected array $layer = []; + protected array $layer = [0, 0, 0, 0, 0, 0, 0]; /** * Returns the minimum number of layers required. * - * @param array $data Either the Data::SIZE_COMPACT or Data::SIZE_FULL array. + * @param array $data + * Either the Data::SIZE_COMPACT or Data::SIZE_FULL array. * @param int $numbits The number of bits to encode. */ protected function getMinLayers(array $data, int $numbits): int From 8ae53b6f326d6b86ba93dfd0a6c4a23c9599a559 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Wed, 22 Nov 2023 08:19:49 +0000 Subject: [PATCH 097/100] datamatrix complete --- src/Type/Square/Datamatrix.php | 47 ++++++++++++------- src/Type/Square/Datamatrix/Data.php | 14 ++++++ src/Type/Square/Datamatrix/Encode.php | 32 +++++++++++++ src/Type/Square/Datamatrix/EncodeTxt.php | 27 +++++++++++ .../Square/Datamatrix/ErrorCorrection.php | 12 ++--- src/Type/Square/Datamatrix/Modes.php | 10 +--- src/Type/Square/Datamatrix/Placement.php | 34 ++++++++++---- src/Type/Square/Datamatrix/Steps.php | 36 ++++++++++++++ 8 files changed, 171 insertions(+), 41 deletions(-) diff --git a/src/Type/Square/Datamatrix.php b/src/Type/Square/Datamatrix.php index aca80ade..0f4ac6fc 100644 --- a/src/Type/Square/Datamatrix.php +++ b/src/Type/Square/Datamatrix.php @@ -3,13 +3,13 @@ /** * Datamatrix.php * - * @since 2015-02-21 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode * * This file is part of tc-lib-barcode software library. */ @@ -26,13 +26,13 @@ * Datamatrix Barcode type class * DATAMATRIX (ISO/IEC 16022) * - * @since 2015-02-21 - * @category Library - * @package Barcode - * @author Nicola Asuni - * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-barcode + * @since 2015-02-21 + * @category Library + * @package Barcode + * @author Nicola Asuni + * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-barcode */ class Datamatrix extends \Com\Tecnick\Barcode\Type\Square { @@ -45,11 +45,15 @@ class Datamatrix extends \Com\Tecnick\Barcode\Type\Square /** * Array of codewords. + * + * @var array */ protected array $cdw = []; /** * Binary grid + * + * @var array> */ protected array $grid = []; @@ -129,7 +133,7 @@ protected function addPadding(int $size, int $ncw): void /** * Get the codewords * - * @return array params + * @return array{int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int} params * * @throws BarcodeException in case of error */ @@ -162,6 +166,15 @@ protected function getCodewords(): array /** * Set the grid + * + * @param int $idx Index + * @param array $places Places + * @param int $row Row + * @param int $col Column + * @param int $rdx Region data row index + * @param int $cdx Region data column index + * @param int $rdri Region data row max index + * @param int $rdci Region data column max index */ protected function setGrid( int &$idx, @@ -207,7 +220,7 @@ protected function setGrid( * * @param string $data data to encode * - * @return array of codewords + * @return array Codewords * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ @@ -268,8 +281,6 @@ protected function setBars(): void { $this->dmx = new Encode($this->shape); $params = $this->getCodewords(); - // initialize empty arrays - $this->grid = array_fill(0, ($params[2] * $params[3]), 0); // get placement map $places = $this->dmx->getPlacementMap($params[2], $params[3]); // fill the grid with data diff --git a/src/Type/Square/Datamatrix/Data.php b/src/Type/Square/Datamatrix/Data.php index 22560c80..bdaa9b8e 100644 --- a/src/Type/Square/Datamatrix/Data.php +++ b/src/Type/Square/Datamatrix/Data.php @@ -89,6 +89,20 @@ class Data */ public const ENC_ASCII_NUM = 7; + /** + * Switch codewords. + * + * @var array + */ + public const SWITCHCDW = [ + Data::ENC_ASCII => 254, + Data::ENC_C40 => 230, + Data::ENC_TXT => 239, + Data::ENC_X12 => 238, + Data::ENC_EDF => 240, + Data::ENC_BASE256 => 231, + ]; + /** * Table of Data Matrix ECC 200 Symbol Attributes: *
    • SHAPE
        diff --git a/src/Type/Square/Datamatrix/Encode.php b/src/Type/Square/Datamatrix/Encode.php index a7041f54..15df0c9c 100644 --- a/src/Type/Square/Datamatrix/Encode.php +++ b/src/Type/Square/Datamatrix/Encode.php @@ -44,6 +44,13 @@ public function __construct(string $shape = 'S') /** * Encode ASCII + * + * @param array $cdw Codewords array + * @param int $cdw_num Codewords number + * @param int $pos Current position + * @param int $data_length Data length + * @param string $data Data string + * @param int $enc Current encoding */ public function encodeASCII( array &$cdw, @@ -96,6 +103,15 @@ public function encodeASCII( /** * Encode EDF4 * + * @param int $epos Current position + * @param array $cdw Codewords array + * @param int $cdw_num Codewords number + * @param int $pos Current position + * @param int $data_length Data length + * @param int $field_length Field length + * @param int $enc Current encoding + * @param array $temp_cw Temporary codewords array + * * @return bool true to break the loop */ public function encodeEDFfour( @@ -161,6 +177,14 @@ public function encodeEDFfour( /** * Encode EDF + * + * @param array $cdw Codewords array + * @param int $cdw_num Codewords number + * @param int $pos Current position + * @param int $data_length Data length + * @param int $field_length Field length + * @param string $data Data string + * @param int $enc Current encoding */ public function encodeEDF( array &$cdw, @@ -206,6 +230,14 @@ public function encodeEDF( /** * Encode Base256 + * + * @param array $cdw Codewords array + * @param int $cdw_num Codewords number + * @param int $pos Current position + * @param int $data_length Data length + * @param int $field_length Field length + * @param string $data Data string + * @param int $enc Current encoding */ public function encodeBase256( array &$cdw, diff --git a/src/Type/Square/Datamatrix/EncodeTxt.php b/src/Type/Square/Datamatrix/EncodeTxt.php index 3c0bff84..b9f74a8b 100644 --- a/src/Type/Square/Datamatrix/EncodeTxt.php +++ b/src/Type/Square/Datamatrix/EncodeTxt.php @@ -36,6 +36,11 @@ class EncodeTxt extends \Com\Tecnick\Barcode\Type\Square\Datamatrix\Steps { /** * Encode TXTC40 shift + * + * @param int $chr Character code + * @param int $enc Current encoding + * @param array $temp_cw Temporary codewords array + * @param int $ptr Pointer */ public function encodeTXTC40shift( int &$chr, @@ -66,6 +71,13 @@ public function encodeTXTC40shift( /** * Encode TXTC40 * + * @param string $data Data string + * @param int $enc Current encoding + * @param array $temp_cw Temporary codewords array + * @param int $ptr Pointer + * @param int $epos End position + * @param array $charset Charset array + * * @return int Curent character code */ public function encodeTXTC40( @@ -105,6 +117,14 @@ public function encodeTXTC40( * Encode TXTC40 last * The following rules apply when only one or two symbol characters remain in the symbol * before the start of the error correction codewords. + * + * @param int $chr Character code + * @param array $cdw Codewords array + * @param int $cdw_num Codewords number + * @param int $enc Current encoding + * @param array $temp_cw Temporary codewords array + * @param int $ptr Pointer + * @param int $epos End position */ public function encodeTXTC40last( int $chr, @@ -155,6 +175,13 @@ public function encodeTXTC40last( /** * Encode TXT + * + * @param array $cdw Codewords array + * @param int $cdw_num Codewords number + * @param int $pos Current position + * @param int $data_length Data length + * @param string $data Data string + * @param int $enc Current encoding */ public function encodeTXT( array &$cdw, diff --git a/src/Type/Square/Datamatrix/ErrorCorrection.php b/src/Type/Square/Datamatrix/ErrorCorrection.php index 2b0a6526..9e3d8ef2 100644 --- a/src/Type/Square/Datamatrix/ErrorCorrection.php +++ b/src/Type/Square/Datamatrix/ErrorCorrection.php @@ -36,8 +36,8 @@ class ErrorCorrection * * @param int $numa First number to multiply. * @param int $numb Second number to multiply. - * @param array $log Log table. - * @param array $alog Anti-Log table. + * @param array $log Log table. + * @param array $alog Anti-Log table. * @param int $ngf Number of Factors of the Reed-Solomon polynomial. * * @return int product @@ -59,14 +59,14 @@ protected function getGFProduct( /** * Add error correction codewords to data codewords array (ANNEX E). * - * @param array $wdc Array of datacodewords. + * @param array $wdc Array of datacodewords. * @param int $nbk Number of blocks. * @param int $ncw Number of data codewords per block. * @param int $ncc Number of correction codewords per block. * @param int $ngf Number of fields on log/antilog table (power of 2). * @param int $vpp The value of its prime modulus polynomial (301 for ECC200). * - * @return array data codewords + error codewords + * @return array data codewords + error codewords */ public function getErrorCorrection( array $wdc, @@ -133,8 +133,8 @@ public function getErrorCorrection( /** * Generate the log ($log) and antilog ($alog) tables * - * @param array $log Log table - * @param array $alog Anti-Log table + * @param array $log Log table + * @param array $alog Anti-Log table * @param int $ngf Number of fields on log/antilog table (power of 2). * @param int $vpp The value of its prime modulus polynomial (301 for ECC200). */ diff --git a/src/Type/Square/Datamatrix/Modes.php b/src/Type/Square/Datamatrix/Modes.php index aac820e9..be27fc9a 100644 --- a/src/Type/Square/Datamatrix/Modes.php +++ b/src/Type/Square/Datamatrix/Modes.php @@ -209,15 +209,7 @@ protected function getMaxDataCodewords(int $numcw): int */ protected function getSwitchEncodingCodeword(int $mode): int { - $map = [ - Data::ENC_ASCII => 254, - Data::ENC_C40 => 230, - Data::ENC_TXT => 239, - Data::ENC_X12 => 238, - Data::ENC_EDF => 240, - Data::ENC_BASE256 => 231, - ]; - $cdw = $map[$mode]; + $cdw = Data::SWITCHCDW[$mode]; if ($cdw != 254) { return $cdw; } diff --git a/src/Type/Square/Datamatrix/Placement.php b/src/Type/Square/Datamatrix/Placement.php index bf5277cf..5808edfa 100644 --- a/src/Type/Square/Datamatrix/Placement.php +++ b/src/Type/Square/Datamatrix/Placement.php @@ -35,13 +35,15 @@ abstract class Placement * Places "chr+bit" with appropriate wrapping within array[]. * (Annex F - ECC 200 symbol character placement) * - * @param array $marr Array of symbols. + * @param array $marr Array of symbols. * @param int $nrow Number of rows. * @param int $ncol Number of columns. * @param int $row Row number. * @param int $col Column number. * @param int $chr Char byte. * @param int $bit Bit. + * + * @return array */ protected function placeModule( array $marr, @@ -70,12 +72,14 @@ protected function placeModule( * Places the 8 bits of a utah-shaped symbol character. * (Annex F - ECC 200 symbol character placement) * - * @param array $marr Array of symbols. + * @param array $marr Array of symbols. * @param int $nrow Number of rows. * @param int $ncol Number of columns. * @param int $row Row number. * @param int $col Column number. * @param int $chr Char byte. + * + * @return array */ protected function placeUtah( array $marr, @@ -99,12 +103,14 @@ protected function placeUtah( * Places the 8 bits of the first special corner case. * (Annex F - ECC 200 symbol character placement) * - * @param array $marr Array of symbols + * @param array $marr Array of symbols * @param int $nrow Number of rows * @param int $ncol Number of columns * @param int $chr Char byte * @param int $row Current row * @param int $col Current column + * + * @return array */ protected function placeCornerA( array $marr, @@ -134,12 +140,14 @@ protected function placeCornerA( * Places the 8 bits of the second special corner case. * (Annex F - ECC 200 symbol character placement) * - * @param array $marr Array of symbols + * @param array $marr Array of symbols * @param int $nrow Number of rows * @param int $ncol Number of columns * @param int $chr Char byte * @param int $row Current row * @param int $col Current column + * + * @return array */ protected function placeCornerB( array $marr, @@ -169,12 +177,14 @@ protected function placeCornerB( * Places the 8 bits of the third special corner case. * (Annex F - ECC 200 symbol character placement) * - * @param array $marr Array of symbols + * @param array $marr Array of symbols * @param int $nrow Number of rows * @param int $ncol Number of columns * @param int $chr Char byte * @param int $row Current row * @param int $col Current column + * + * @return array */ protected function placeCornerC( array $marr, @@ -204,12 +214,14 @@ protected function placeCornerC( * Places the 8 bits of the fourth special corner case. * (Annex F - ECC 200 symbol character placement) * - * @param array $marr Array of symbols + * @param array $marr Array of symbols * @param int $nrow Number of rows * @param int $ncol Number of columns * @param int $chr Char byte * @param int $row Current row * @param int $col Current column + * + * @return array */ protected function placeCornerD( array $marr, @@ -239,12 +251,14 @@ protected function placeCornerD( * Sweep upward diagonally, inserting successive characters, * (Annex F - ECC 200 symbol character placement) * - * @param array $marr Array of symbols + * @param array $marr Array of symbols * @param int $nrow Number of rows * @param int $ncol Number of columns * @param int $chr Char byte * @param int $row Current row * @param int $col Current column + * + * @return array */ protected function placeSweepUpward( array $marr, @@ -273,12 +287,14 @@ protected function placeSweepUpward( * Sweep downward diagonally, inserting successive characters, * (Annex F - ECC 200 symbol character placement) * - * @param array $marr Array of symbols + * @param array $marr Array of symbols * @param int $nrow Number of rows * @param int $ncol Number of columns * @param int $chr Char byte * @param int $row Current row * @param int $col Current column + * + * @return array */ protected function placeSweepDownward( array $marr, @@ -309,6 +325,8 @@ protected function placeSweepDownward( * * @param int $nrow Number of rows. * @param int $ncol Number of columns. + * + * @return array */ public function getPlacementMap( int $nrow, diff --git a/src/Type/Square/Datamatrix/Steps.php b/src/Type/Square/Datamatrix/Steps.php index b4095ac4..3c7a4e00 100644 --- a/src/Type/Square/Datamatrix/Steps.php +++ b/src/Type/Square/Datamatrix/Steps.php @@ -80,6 +80,10 @@ public function lookAheadTest(string $data, int $pos, int $mode): int /** * Step K + * + * @param array $numch Number of characters + * + * @return int encoding mode */ protected function stepK(array $numch): int { @@ -148,6 +152,9 @@ protected function stepK(array $numch): int /** * Step L + * + * @param int $chr Character code + * @param array $numch Number of characters */ protected function stepL(int $chr, array &$numch): void { @@ -164,6 +171,9 @@ protected function stepL(int $chr, array &$numch): void /** * Step M + * + * @param int $chr Character code + * @param array $numch Number of characters */ protected function stepM(int $chr, array &$numch): void { @@ -178,6 +188,9 @@ protected function stepM(int $chr, array &$numch): void /** * Step N + * + * @param int $chr Character code + * @param array $numch Number of characters */ protected function stepN(int $chr, array &$numch): void { @@ -192,6 +205,9 @@ protected function stepN(int $chr, array &$numch): void /** * Step O + * + * @param int $chr Character code + * @param array $numch Number of characters */ protected function stepO(int $chr, array &$numch): void { @@ -206,6 +222,9 @@ protected function stepO(int $chr, array &$numch): void /** * Step P + * + * @param int $chr Character code + * @param array $numch Number of characters */ protected function stepP(int $chr, array &$numch): void { @@ -220,6 +239,9 @@ protected function stepP(int $chr, array &$numch): void /** * Step Q + * + * @param int $chr Character code + * @param array $numch Number of characters */ protected function stepQ(int $chr, array &$numch): void { @@ -233,6 +255,12 @@ protected function stepQ(int $chr, array &$numch): void /** * Step R-f * + * @param array $numch Number of characters + * @param int $pos Current position + * @param int $data_length Data length + * @param int $charscount Number of processed characters + * @param string $data Data to encode + * * @return int Encoding mode */ protected function stepRf( @@ -278,6 +306,14 @@ protected function stepRf( /** * Step R + * + * @param array $numch Number of characters + * @param int $pos Current position + * @param int $data_length Data length + * @param int $charscount Number of processed characters + * @param string $data Data to encode + * + * @return int Encoding mode */ protected function stepR( array $numch, From b104f4922a543a615e4c503b21ad7b96a152f7cd Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Wed, 22 Nov 2023 09:05:04 +0000 Subject: [PATCH 098/100] datamatrix encodeBitStream --- src/Type/Square/QrCode.php | 6 +- src/Type/Square/QrCode/ByteStream.php | 236 +++++++++++++++----------- 2 files changed, 142 insertions(+), 100 deletions(-) diff --git a/src/Type/Square/QrCode.php b/src/Type/Square/QrCode.php index f694ef72..501e73b5 100644 --- a/src/Type/Square/QrCode.php +++ b/src/Type/Square/QrCode.php @@ -188,9 +188,9 @@ protected function setBars(): void /** * Convert the frame in binary form * - * @param array $frame Array to binarize + * @param array $frame Array to binarize * - * @return array frame in binary form + * @return array frame in binary form */ protected function binarize(array $frame): array { @@ -209,6 +209,8 @@ protected function binarize(array $frame): array * Encode the input string * * @param string $data input string to encode + * + * @return array Encoded data */ protected function encodeString(string $data): array { diff --git a/src/Type/Square/QrCode/ByteStream.php b/src/Type/Square/QrCode/ByteStream.php index 3d25f697..a78edece 100644 --- a/src/Type/Square/QrCode/ByteStream.php +++ b/src/Type/Square/QrCode/ByteStream.php @@ -48,9 +48,14 @@ public function __construct(int $hint, int $version, int $level) /** * Pack all bit streams padding bits into a byte array * - * @param array $items items + * @param array, + * 'bstream': array, + * }> $items Items * - * @return array padded merged byte stream + * @return array padded merged byte stream */ public function getByteStream(array $items): array { @@ -61,12 +66,78 @@ public function getByteStream(array $items): array ); } + /** + * merge the bit stream + * + * @param array, + * 'bstream': array, + * }> $items Items + * + * @return array bitstream + */ + protected function mergeBitStream(array $items): array + { + $items = $this->convertData($items); + $bstream = []; + foreach ($items as $item) { + $bstream = $this->appendBitstream($bstream, $item['bstream']); + } + + return $bstream; + } + + /** + * Append Padding Bit to bitstream + * + * @param array $bstream Bit stream + * + * @return array bitstream + */ + protected function appendPaddingBit(array $bstream): array + { + if (empty($bstream)) { + return []; + } + + $bits = count($bstream); + $spec = new Spec(); + $maxwords = $spec->getDataLength($this->version, $this->level); + $maxbits = $maxwords * 8; + if ($maxbits == $bits) { + return $bstream; + } + + if ($maxbits - $bits < 5) { + return $this->appendNum($bstream, $maxbits - $bits, 0); + } + + $bits += 4; + $words = (int) (($bits + 7) / 8); + $padding = []; + $padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0); + + $padlen = $maxwords - $words; + if ($padlen > 0) { + $padbuf = []; + for ($idx = 0; $idx < $padlen; ++$idx) { + $padbuf[$idx] = ((($idx & 1) !== 0) ? 0x11 : 0xec); + } + + $padding = $this->appendBytes($padding, $padlen, $padbuf); + } + + return $this->appendBitstream($bstream, $padding); + } + /** * Convert bitstream to bytes * - * @param array $bstream Original bitstream + * @param array $bstream Original bitstream * - * @return array of bytes + * @return array of bytes */ protected function bitstreamToByte(array $bstream): array { @@ -103,30 +174,22 @@ protected function bitstreamToByte(array $bstream): array return $data; } - /** - * merge the bit stream - * - * @param array $items Items - * - * @return array bitstream - */ - protected function mergeBitStream(array $items): array - { - $items = $this->convertData($items); - $bstream = []; - foreach ($items as $item) { - $bstream = $this->appendBitstream($bstream, $item['bstream']); - } - - return $bstream; - } - /** * convertData * - * @param array $items Items + * @param array, + * 'bstream': array, + * }> $items Items * - * @return array items + * @return array, + * 'bstream': array, + * }> */ protected function convertData(array $items): array { @@ -157,7 +220,22 @@ protected function convertData(array $items): array /** * Create BitStream * - * @return array of items and total bits + * @param array, + * 'bstream': array, + * }> $items Items + * + * @return array{ + * 0: array, + * 'bstream': array, + * }>, + * 1: int, + * } */ protected function createBitStream(array $items): array { @@ -174,88 +252,50 @@ protected function createBitStream(array $items): array /** * Encode BitStream * - * @return array input item + * @param array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream'?: array, + * } $inputitem Input item + * @param int $version Code version + * + * @return array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } */ public function encodeBitStream(array $inputitem, int $version): array { $inputitem['bstream'] = []; $spec = new Spec(); $words = $spec->maximumWords($inputitem['mode'], $version); - if ($inputitem['size'] > $words) { - $st1 = $this->newInputItem($inputitem['mode'], $words, $inputitem['data']); - $st2 = $this->newInputItem( - $inputitem['mode'], - ($inputitem['size'] - $words), - array_slice($inputitem['data'], $words) - ); - $st1 = $this->encodeBitStream($st1, $version); - $st2 = $this->encodeBitStream($st2, $version); - $inputitem['bstream'] = []; - $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st1['bstream']); - $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']); - } else { - switch ($inputitem['mode']) { - case Data::ENC_MODES['NM']: - $inputitem = $this->encodeModeNum($inputitem, $version); - break; - case Data::ENC_MODES['AN']: - $inputitem = $this->encodeModeAn($inputitem, $version); - break; - case Data::ENC_MODES['8B']: - $inputitem = $this->encodeMode8($inputitem, $version); - break; - case Data::ENC_MODES['KJ']: - $inputitem = $this->encodeModeKanji($inputitem, $version); - break; - case Data::ENC_MODES['ST']: - $inputitem = $this->encodeModeStructure($inputitem); - break; - } - } - - return $inputitem; - } - - /** - * Append Padding Bit to bitstream - * - * @param array $bstream Bit stream - * - * @return array bitstream - */ - protected function appendPaddingBit(array $bstream): array - { - if (empty($bstream)) { - return []; - } - $bits = count($bstream); - $spec = new Spec(); - $maxwords = $spec->getDataLength($this->version, $this->level); - $maxbits = $maxwords * 8; - if ($maxbits == $bits) { - return $bstream; + if ($inputitem['size'] <= $words) { + return match ($inputitem['mode']) { + Data::ENC_MODES['NM'] => $this->encodeModeNum($inputitem, $version), + Data::ENC_MODES['AN'] => $this->encodeModeAn($inputitem, $version), + Data::ENC_MODES['8B'] => $this->encodeMode8($inputitem, $version), + Data::ENC_MODES['KJ'] => $this->encodeModeKanji($inputitem, $version), + Data::ENC_MODES['ST'] => $this->encodeModeStructure($inputitem), + default => throw new BarcodeException('Invalid mode'), + }; } - if ($maxbits - $bits < 5) { - return $this->appendNum($bstream, $maxbits - $bits, 0); - } - - $bits += 4; - $words = (int) (($bits + 7) / 8); - $padding = []; - $padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0); - - $padlen = $maxwords - $words; - if ($padlen > 0) { - $padbuf = []; - for ($idx = 0; $idx < $padlen; ++$idx) { - $padbuf[$idx] = ((($idx & 1) !== 0) ? 0x11 : 0xec); - } - - $padding = $this->appendBytes($padding, $padlen, $padbuf); - } + $st1 = $this->newInputItem($inputitem['mode'], $words, $inputitem['data']); + $st2 = $this->newInputItem( + $inputitem['mode'], + ($inputitem['size'] - $words), + array_slice($inputitem['data'], $words) + ); + $st1 = $this->encodeBitStream($st1, $version); + $st2 = $this->encodeBitStream($st2, $version); + $inputitem['bstream'] = []; + $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st1['bstream']); + $inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']); - return $this->appendBitstream($bstream, $padding); + return $inputitem; } } From a5e4b9c68a824acaba07436bf6905640e19a465c Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Wed, 22 Nov 2023 10:00:10 +0000 Subject: [PATCH 099/100] qrcode init --- src/Type/Square/QrCode/Encode.php | 74 +++++++++++++++++++++++-- src/Type/Square/QrCode/Encoder.php | 12 ++-- src/Type/Square/QrCode/EncodingMode.php | 24 ++++---- src/Type/Square/QrCode/Estimate.php | 16 ++++++ src/Type/Square/QrCode/Init.php | 70 ++++++++++++++++++----- src/Type/Square/QrCode/InputItem.php | 40 ++++++++++--- 6 files changed, 193 insertions(+), 43 deletions(-) diff --git a/src/Type/Square/QrCode/Encode.php b/src/Type/Square/QrCode/Encode.php index f58c48fc..dfa2a101 100644 --- a/src/Type/Square/QrCode/Encode.php +++ b/src/Type/Square/QrCode/Encode.php @@ -32,7 +32,20 @@ abstract class Encode extends \Com\Tecnick\Barcode\Type\Square\QrCode\EncodingMo /** * encode Mode Num * - * @return array input item + * @param array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } $inputitem input item + * @param int $version Code version + * + * @return array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } input item */ protected function encodeModeNum(array $inputitem, int $version): array { @@ -67,7 +80,20 @@ protected function encodeModeNum(array $inputitem, int $version): array /** * encode Mode An * - * @return array input item + * @param array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } $inputitem input item + * @param int $version Code version + * + * @return array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } input item */ protected function encodeModeAn(array $inputitem, int $version): array { @@ -96,7 +122,20 @@ protected function encodeModeAn(array $inputitem, int $version): array /** * encode Mode 8 * - * @return array input item + * @param array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } $inputitem input item + * @param int $version Code version + * + * @return array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } input item */ protected function encodeMode8(array $inputitem, int $version): array { @@ -117,7 +156,20 @@ protected function encodeMode8(array $inputitem, int $version): array /** * encode Mode Kanji * - * @return array input item + * @param array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } $inputitem input item + * @param int $version Code version + * + * @return array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } input item */ protected function encodeModeKanji(array $inputitem, int $version): array { @@ -146,7 +198,19 @@ protected function encodeModeKanji(array $inputitem, int $version): array /** * encode Mode Structure * - * @return array input item + * @param array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } $inputitem input item + * + * @return array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } input item */ protected function encodeModeStructure(array $inputitem): array { diff --git a/src/Type/Square/QrCode/Encoder.php b/src/Type/Square/QrCode/Encoder.php index 7b225871..30acba65 100644 --- a/src/Type/Square/QrCode/Encoder.php +++ b/src/Type/Square/QrCode/Encoder.php @@ -35,9 +35,9 @@ class Encoder extends \Com\Tecnick\Barcode\Type\Square\QrCode\Init * Encode mask * * @param int $maskNo Mask number (masking mode) - * @param array $datacode Data code to encode + * @param array $datacode Data code to encode * - * @return array Encoded Mask + * @return array Encoded Mask */ public function encodeMask(int $maskNo, array $datacode): array { @@ -125,7 +125,7 @@ protected function getCode(): int /** * Set frame value at specified position * - * @param array $pos X,Y position + * @param array{'x': int, 'y': int} $pos X,Y position * @param int $val Value of the character to set */ protected function setFrameAt(array $pos, int $val): void @@ -136,7 +136,7 @@ protected function setFrameAt(array $pos, int $val): void /** * Return the next frame position * - * @return array of x,y coordinates + * @return array{'x': int, 'y': int} of x,y coordinates */ protected function getNextPosition(): array { @@ -169,6 +169,10 @@ protected function getNextPosition(): array /** * Internal cycle for getNextPosition + * + * @param int $xpos X position + * @param int $ypos Y position + * @param int $wdt Width */ protected function getNextPositionB(int &$xpos, int &$ypos, int $wdt): void { diff --git a/src/Type/Square/QrCode/EncodingMode.php b/src/Type/Square/QrCode/EncodingMode.php index 36abf0c7..28751e0f 100644 --- a/src/Type/Square/QrCode/EncodingMode.php +++ b/src/Type/Square/QrCode/EncodingMode.php @@ -107,10 +107,10 @@ public function isAlphanumericAt(string $str, int $pos): bool /** * Append one bitstream to another * - * @param array $bitstream Original bitstream - * @param array $append Bitstream to append + * @param array $bitstream Original bitstream + * @param array $append Bitstream to append * - * @return array bitstream + * @return array bitstream */ protected function appendBitstream(array $bitstream, array $append): array { @@ -128,11 +128,11 @@ protected function appendBitstream(array $bitstream, array $append): array /** * Append one bitstream created from number to another * - * @param array $bitstream Original bitstream + * @param array $bitstream Original bitstream * @param int $bits Number of bits * @param int $num Number * - * @return array bitstream + * @return array bitstream */ protected function appendNum(array $bitstream, int $bits, int $num): array { @@ -146,11 +146,11 @@ protected function appendNum(array $bitstream, int $bits, int $num): array /** * Append one bitstream created from bytes to another * - * @param array $bitstream Original bitstream + * @param array $bitstream Original bitstream * @param int $size Size - * @param array $data Bytes + * @param array $data Bytes * - * @return array bitstream + * @return array bitstream */ protected function appendBytes(array $bitstream, int $size, array $data): array { @@ -167,7 +167,7 @@ protected function appendBytes(array $bitstream, int $size, array $data): array * @param int $bits Number of bits * @param int $num Number * - * @return array bitstream + * @return array bitstream */ protected function newFromNum(int $bits, int $num): array { @@ -186,9 +186,9 @@ protected function newFromNum(int $bits, int $num): array * Return new bitstream from bytes * * @param int $size Size - * @param array $data Bytes + * @param array $data Bytes * - * @return array bitstream + * @return array bitstream */ protected function newFromBytes(int $size, array $data): array { @@ -211,6 +211,8 @@ protected function newFromBytes(int $size, array $data): array * Return an array with zeros * * @param int $setLength Array size + * + * @return array array */ protected function allocate(int $setLength): array { diff --git a/src/Type/Square/QrCode/Estimate.php b/src/Type/Square/QrCode/Estimate.php index b55ab36c..e3f418ad 100644 --- a/src/Type/Square/QrCode/Estimate.php +++ b/src/Type/Square/QrCode/Estimate.php @@ -129,6 +129,14 @@ public function estimateBitsModeKanji(int $size): int /** * Estimate version * + * @param array, + * 'bstream': array, + * }> $items Items + * @param int $level Error correction level + * * @return int version */ public function estimateVersion(array $items, int $level): int @@ -174,6 +182,14 @@ protected function getMinimumVersion(int $size, int $level): int /** * estimateBitStreamSize * + * @param array, + * 'bstream': array, + * }> $items Items + * @param int $version Code version + * * @return int bits */ protected function estimateBitStreamSize(array $items, int $version): int diff --git a/src/Type/Square/QrCode/Init.php b/src/Type/Square/QrCode/Init.php index 03a7009c..925d22a2 100644 --- a/src/Type/Square/QrCode/Init.php +++ b/src/Type/Square/QrCode/Init.php @@ -28,16 +28,41 @@ * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode + * + * @phpstan-type RSItem array{ + * 'alpha_to': array, + * 'fcr': int, + * 'genpoly': array, + * 'gfpoly': int, + * 'index_of': array, + * 'iprim': int, + * 'mm': int, + * 'nn': int, + * 'nroots': int, + * 'pad': int, + * 'prim': int, + * } + * + * @phpstan-type RSblock array{ + * 'data': array, + * 'dataLength': int, + * 'ecc': array, + * 'eccLength': int, + * } */ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask { /** * Data code + * + * @var array */ protected array $datacode = []; /** * Error correction code + * + * @var array */ protected array $ecccode = []; @@ -48,6 +73,8 @@ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask /** * Reed-Solomon blocks + * + * @var array */ protected array $rsblocks = []; //of RSblock @@ -78,6 +105,8 @@ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask /** * Frame + * + * @var array> */ protected array $frame = []; @@ -104,14 +133,14 @@ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask /** * Reed-Solomon items * - * @va array + * @var array */ protected array $rsitems = []; /** * Initialize code * - * @param array $spec Array of ECC specification + * @param array $spec Array of ECC specification */ protected function init(array $spec): void { @@ -141,6 +170,15 @@ protected function init(array $spec): void /** * Internal loop for init + * + * @param int $endfor End for + * @param int $dlv Data length value + * @param int $elv Error correction length value + * @param RSItem $rsv Reed-Solomon values + * @param int $eccPos Error correction code position + * @param int $blockNo Block number + * @param int $dataPos Data position + * @param array $ecc Error correction code */ protected function initLoop( int $endfor, @@ -153,13 +191,15 @@ protected function initLoop( array &$ecc ): void { for ($idx = 0; $idx < $endfor; ++$idx) { + $data = array_slice($this->datacode, $dataPos); $ecc = array_slice($this->ecccode, $eccPos); - $this->rsblocks[$blockNo] = []; - $this->rsblocks[$blockNo]['dataLength'] = $dlv; - $this->rsblocks[$blockNo]['data'] = array_slice($this->datacode, $dataPos); - $this->rsblocks[$blockNo]['eccLength'] = $elv; - $ecc = $this->encodeRsChar($rsv, $this->rsblocks[$blockNo]['data'], $ecc); - $this->rsblocks[$blockNo]['ecc'] = $ecc; + $ecc = $this->encodeRsChar($rsv, $data, $ecc); + $this->rsblocks[$blockNo] = [ + 'data' => $data, + 'dataLength' => $dlv, + 'ecc' => $ecc, + 'eccLength' => $elv, + ]; $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc); $dataPos += $dlv; $eccPos += $elv; @@ -177,7 +217,7 @@ protected function initLoop( * @param int $nroots RS code generator polynomial degree (number of roots) * @param int $pad Padding bytes at front of shortened block * - * @return array Array of RS values: + * @return RSItem Array of RS values: * mm = Bits per symbol; * nn = Symbols per block; * alpha_to = log lookup table array; @@ -235,7 +275,7 @@ protected function initRs( /** * modnn * - * @param array $rsv RS values + * @param RSItem $rsv RS values * @param int $xpos X position * * @return int X position @@ -306,7 +346,7 @@ protected function checkRsCharParamsB(int $symsize, int $nroots, int $pad): void * @param int $nroots RS code generator polynomial degree (number of roots) * @param int $pad Padding bytes at front of shortened block * - * @return array Array of RS values: + * @return RSItem Array of RS values: * mm = Bits per symbol; * nn = Symbols per block; * alpha_to = log lookup table array; @@ -398,11 +438,11 @@ protected function initRsChar( /** * Encode a Reed-Solomon codec and returns the parity array * - * @param array $rsv RS values - * @param array $data Data - * @param array $parity Parity + * @param RSItem $rsv RS values + * @param array $data Data + * @param array $parity Parity * - * @return array Parity array + * @return array Parity array */ protected function encodeRsChar( array $rsv, diff --git a/src/Type/Square/QrCode/InputItem.php b/src/Type/Square/QrCode/InputItem.php index 82fc7e7b..7a202df4 100644 --- a/src/Type/Square/QrCode/InputItem.php +++ b/src/Type/Square/QrCode/InputItem.php @@ -45,12 +45,22 @@ public function lookAnTable(int $chr): int * Append data to an input object. * The data is copied and appended to the input object. * - * @param array $items Input items + * @param array, + * 'bstream': array, + * }> $items Input items * @param int $mode Encoding mode. * @param int $size Size of data (byte). - * @param array $data Array of input data. + * @param array $data Array of input data. * - * @return array items + * @return array, + * 'bstream': array, + * }> items */ public function appendNewInputItem( array $items, @@ -71,10 +81,15 @@ public function appendNewInputItem( * * @param int $mode Encoding mode. * @param int $size Size of data (byte). - * @param array $data Array of input data. - * @param array $bstream Binary stream + * @param array $data Array of input data. + * @param array $bstream Binary stream * - * @return array input item + * @return array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } input item */ protected function newInputItem( int $mode, @@ -84,7 +99,7 @@ protected function newInputItem( ): array { $setData = array_slice($data, 0, $size); if (count($setData) < $size) { - $setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0)); + $setData = array_merge($setData, array_fill(0, ($size - count($setData)), '0')); } if (! $this->check($mode, $size, $setData)) { @@ -104,7 +119,7 @@ protected function newInputItem( * * @param int $mode Encoding mode. * @param int $size Size of data (byte). - * @param array $data Data to validate + * @param array $data Data to validate * * @return bool true in case of valid data, false otherwise */ @@ -130,6 +145,9 @@ protected function check( /** * checkModeNum * + * @param int $size Size of data (byte). + * @param array $data Data to validate + * * @return bool true or false */ protected function checkModeNum(int $size, array $data): bool @@ -146,6 +164,9 @@ protected function checkModeNum(int $size, array $data): bool /** * checkModeAn * + * @param int $size Size of data (byte). + * @param array $data Data to validate + * * @return bool true or false */ protected function checkModeAn(int $size, array $data): bool @@ -162,6 +183,9 @@ protected function checkModeAn(int $size, array $data): bool /** * checkModeKanji * + * @param int $size Size of data (byte). + * @param array $data Data to validate + * * @return bool true or false */ protected function checkModeKanji(int $size, array $data): bool From cb7c53499356fea6f14f4e087db0a8c7eaf99636 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Wed, 22 Nov 2023 10:35:30 +0000 Subject: [PATCH 100/100] complete php8 refactoring --- src/Type/Square/QrCode/ByteStream.php | 60 +++++---------------------- src/Type/Square/QrCode/Estimate.php | 21 ++++------ src/Type/Square/QrCode/Init.php | 2 +- src/Type/Square/QrCode/InputItem.php | 23 +++------- src/Type/Square/QrCode/Mask.php | 19 ++++++--- src/Type/Square/QrCode/MaskNum.php | 8 ++-- src/Type/Square/QrCode/Spec.php | 18 ++++++-- src/Type/Square/QrCode/SpecRs.php | 36 ++++++++++++---- src/Type/Square/QrCode/Split.php | 6 ++- 9 files changed, 91 insertions(+), 102 deletions(-) diff --git a/src/Type/Square/QrCode/ByteStream.php b/src/Type/Square/QrCode/ByteStream.php index a78edece..cef62a2a 100644 --- a/src/Type/Square/QrCode/ByteStream.php +++ b/src/Type/Square/QrCode/ByteStream.php @@ -28,6 +28,8 @@ * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode + * + * @phpstan-import-type Item from \Com\Tecnick\Barcode\Type\Square\QrCode\Estimate */ class ByteStream extends \Com\Tecnick\Barcode\Type\Square\QrCode\Encode { @@ -48,12 +50,7 @@ public function __construct(int $hint, int $version, int $level) /** * Pack all bit streams padding bits into a byte array * - * @param array, - * 'bstream': array, - * }> $items Items + * @param array $items Items * * @return array padded merged byte stream */ @@ -69,12 +66,7 @@ public function getByteStream(array $items): array /** * merge the bit stream * - * @param array, - * 'bstream': array, - * }> $items Items + * @param array $items Items * * @return array bitstream */ @@ -177,19 +169,9 @@ protected function bitstreamToByte(array $bstream): array /** * convertData * - * @param array, - * 'bstream': array, - * }> $items Items + * @param array $items Items * - * @return array, - * 'bstream': array, - * }> + * @return array */ protected function convertData(array $items): array { @@ -220,21 +202,11 @@ protected function convertData(array $items): array /** * Create BitStream * - * @param array, - * 'bstream': array, - * }> $items Items + * @param array $items Items * * @return array{ - * 0: array, - * 'bstream': array, - * }>, - * 1: int, + * 0: array, + * 1: int, * } */ protected function createBitStream(array $items): array @@ -252,20 +224,10 @@ protected function createBitStream(array $items): array /** * Encode BitStream * - * @param array{ - * 'mode': int, - * 'size': int, - * 'data': array, - * 'bstream'?: array, - * } $inputitem Input item + * @param Item $inputitem Input item * @param int $version Code version * - * @return array{ - * 'mode': int, - * 'size': int, - * 'data': array, - * 'bstream': array, - * } + * @return Item */ public function encodeBitStream(array $inputitem, int $version): array { diff --git a/src/Type/Square/QrCode/Estimate.php b/src/Type/Square/QrCode/Estimate.php index e3f418ad..8e0129ad 100644 --- a/src/Type/Square/QrCode/Estimate.php +++ b/src/Type/Square/QrCode/Estimate.php @@ -28,6 +28,13 @@ * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode + * + * @phpstan-type Item array{ + * 'mode': int, + * 'size': int, + * 'data': array, + * 'bstream': array, + * } */ abstract class Estimate { @@ -129,12 +136,7 @@ public function estimateBitsModeKanji(int $size): int /** * Estimate version * - * @param array, - * 'bstream': array, - * }> $items Items + * @param array $items Items * @param int $level Error correction level * * @return int version @@ -182,12 +184,7 @@ protected function getMinimumVersion(int $size, int $level): int /** * estimateBitStreamSize * - * @param array, - * 'bstream': array, - * }> $items Items + * @param array $items Items * @param int $version Code version * * @return int bits diff --git a/src/Type/Square/QrCode/Init.php b/src/Type/Square/QrCode/Init.php index 925d22a2..e4074037 100644 --- a/src/Type/Square/QrCode/Init.php +++ b/src/Type/Square/QrCode/Init.php @@ -106,7 +106,7 @@ abstract class Init extends \Com\Tecnick\Barcode\Type\Square\QrCode\Mask /** * Frame * - * @var array> + * @var array */ protected array $frame = []; diff --git a/src/Type/Square/QrCode/InputItem.php b/src/Type/Square/QrCode/InputItem.php index 7a202df4..17090d67 100644 --- a/src/Type/Square/QrCode/InputItem.php +++ b/src/Type/Square/QrCode/InputItem.php @@ -28,6 +28,8 @@ * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode + * + * @phpstan-import-type Item from \Com\Tecnick\Barcode\Type\Square\QrCode\Estimate */ abstract class InputItem extends \Com\Tecnick\Barcode\Type\Square\QrCode\Estimate { @@ -45,22 +47,12 @@ public function lookAnTable(int $chr): int * Append data to an input object. * The data is copied and appended to the input object. * - * @param array, - * 'bstream': array, - * }> $items Input items + * @param array $items Input items * @param int $mode Encoding mode. * @param int $size Size of data (byte). * @param array $data Array of input data. * - * @return array, - * 'bstream': array, - * }> items + * @return array items */ public function appendNewInputItem( array $items, @@ -84,12 +76,7 @@ public function appendNewInputItem( * @param array $data Array of input data. * @param array $bstream Binary stream * - * @return array{ - * 'mode': int, - * 'size': int, - * 'data': array, - * 'bstream': array, - * } input item + * @return Item input item */ protected function newInputItem( int $mode, diff --git a/src/Type/Square/QrCode/Mask.php b/src/Type/Square/QrCode/Mask.php index 4ea25c07..d0377459 100644 --- a/src/Type/Square/QrCode/Mask.php +++ b/src/Type/Square/QrCode/Mask.php @@ -31,6 +31,8 @@ abstract class Mask extends \Com\Tecnick\Barcode\Type\Square\QrCode\MaskNum { /** * Run length + * + * @var array */ protected array $runLength = []; @@ -73,10 +75,10 @@ public function __construct( * Get the best mask * * @param int $width Width - * @param array $frame Frame + * @param array $frame Frame * @param int $level Error Correction lLevel * - * @return array best mask + * @return array best mask */ protected function mask( int $width, @@ -118,11 +120,11 @@ protected function mask( * Make a mask * * @param int $width Mask width - * @param array $frame Frame + * @param array $frame Frame * @param int $maskNo Mask number * @param int $level Error Correction level * - * @return array mask + * @return array mask */ protected function makeMask( int $width, @@ -139,7 +141,7 @@ protected function makeMask( * Write Format Information on the frame and returns the number of black bits * * @param int $width Mask width - * @param array $frame Frame + * @param array $frame Frame * @param int $maskNo Mask number * @param int $level Error Correction level * @@ -197,7 +199,7 @@ protected function writeFormatInformation( * Evaluate Symbol and returns demerit value. * * @param int $width Width - * @param array $frame Frame + * @param array $frame Frame */ protected function evaluateSymbol(int $width, array $frame): int { @@ -285,6 +287,8 @@ protected function evaluateSymbolB( /** * Calc N1 N3 * + * @param int $length Length + * * @return int demerit */ protected function calcN1N3(int $length): int @@ -306,6 +310,9 @@ protected function calcN1N3(int $length): int /** * Calc N1 N3 delta * + * @param int $length Length + * @param int $idx Index + * * @return int demerit delta */ protected function calcN1N3delta(int $length, int $idx): int diff --git a/src/Type/Square/QrCode/MaskNum.php b/src/Type/Square/QrCode/MaskNum.php index 52aff1a3..8cfde0d8 100644 --- a/src/Type/Square/QrCode/MaskNum.php +++ b/src/Type/Square/QrCode/MaskNum.php @@ -34,8 +34,8 @@ abstract class MaskNum * * @param int $maskNo Mask number * @param int $width Width - * @param array $frame Frame - * @param array $mask Mask + * @param array $frame Frame + * @param array $mask Mask * * @return int mask number */ @@ -66,9 +66,9 @@ protected function makeMaskNo( * * @param int $maskNo Mask number * @param int $width Width - * @param array $frame Frame + * @param array $frame Frame * - * @return array bit mask + * @return array> bit mask */ protected function generateMaskNo( int $maskNo, diff --git a/src/Type/Square/QrCode/Spec.php b/src/Type/Square/QrCode/Spec.php index f11f8319..cc578f06 100644 --- a/src/Type/Square/QrCode/Spec.php +++ b/src/Type/Square/QrCode/Spec.php @@ -26,6 +26,14 @@ * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode + * + * @phpstan-type EccSpec array{ + * 0: int, + * 1: int, + * 2: int, + * 3: int, + * 4: int, + * } */ class Spec extends \Com\Tecnick\Barcode\Type\Square\QrCode\SpecRs { @@ -115,10 +123,14 @@ public function maximumWords(int $mode, int $version): int * * @param int $version Version * @param int $level Error correction level - * @param array $spec Array of ECC specification contains as following: - * {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code} + * @param EccSpec $spec Array of ECC specification * - * @return array spec + * @return EccSpec spec: + * 0 = # of type1 blocks + * 1 = # of data code + * 2 = # of ecc code + * 3 = # of type2 blocks + * 4 = # of data code */ public function getEccSpec(int $version, int $level, array $spec): array { diff --git a/src/Type/Square/QrCode/SpecRs.php b/src/Type/Square/QrCode/SpecRs.php index 57cbb5ea..5d569d89 100644 --- a/src/Type/Square/QrCode/SpecRs.php +++ b/src/Type/Square/QrCode/SpecRs.php @@ -34,6 +34,8 @@ abstract class SpecRs /** * Return block number 0 * + * @param array $spec Spec + * * @return int value */ public function rsBlockNum(array $spec): int @@ -44,6 +46,8 @@ public function rsBlockNum(array $spec): int /** * Return block number 1 * + * @param array $spec Spec + * * @return int value */ public function rsBlockNum1(array $spec): int @@ -54,6 +58,8 @@ public function rsBlockNum1(array $spec): int /** * Return data codes 1 * + * @param array $spec Spec + * * @return int value */ public function rsDataCodes1(array $spec): int @@ -64,6 +70,8 @@ public function rsDataCodes1(array $spec): int /** * Return ecc codes 1 * + * @param array $spec Spec + * * @return int value */ public function rsEccCodes1(array $spec): int @@ -74,6 +82,8 @@ public function rsEccCodes1(array $spec): int /** * Return block number 2 * + * @param array $spec Spec + * * @return int value */ public function rsBlockNum2(array $spec): int @@ -84,6 +94,8 @@ public function rsBlockNum2(array $spec): int /** * Return data codes 2 * + * @param array $spec Spec + * * @return int value */ public function rsDataCodes2(array $spec): int @@ -94,6 +106,8 @@ public function rsDataCodes2(array $spec): int /** * Return ecc codes 2 * + * @param array $spec Spec + * * @return int value */ public function rsEccCodes2(array $spec): int @@ -104,6 +118,8 @@ public function rsEccCodes2(array $spec): int /** * Return data length * + * @param array $spec Spec + * * @return int value */ public function rsDataLength(array $spec): int @@ -114,6 +130,8 @@ public function rsDataLength(array $spec): int /** * Return ecc length * + * @param array $spec Spec + * * @return int value */ public function rsEccLength(array $spec): int @@ -126,7 +144,7 @@ public function rsEccLength(array $spec): int * * @param int $version Version * - * @return array of unsigned char. + * @return array of unsigned char. */ public function createFrame(int $version): array { @@ -198,11 +216,13 @@ public function createFrame(int $version): array /** * Replace a value on the array at the specified position * + * @param array $srctab Source table * @param int $xpos X position * @param int $ypos Y position * @param string $repl Value to replace * @param int $replLen Length of the repl string - * @return array srctab + * + * @return array srctab */ public function qrstrset( array $srctab, @@ -223,11 +243,11 @@ public function qrstrset( /** * Put an alignment marker. * - * @param array $frame Frame + * @param array $frame Frame * @param int $pox X center coordinate of the pattern * @param int $poy Y center coordinate of the pattern * - * @return array frame + * @return array frame */ public function putAlignmentMarker( array $frame, @@ -253,11 +273,11 @@ public function putAlignmentMarker( /** * Put a finder pattern. * - * @param array $frame Frame + * @param array $frame Frame * @param int $pox X center coordinate of the pattern * @param int $poy Y center coordinate of the pattern * - * @return array frame + * @return array frame */ public function putFinderPattern( array $frame, @@ -299,10 +319,10 @@ public function getVersionPattern(int $version): int * Put an alignment pattern. * * @param int $version Version - * @param array $frame Frame + * @param array $frame Frame * @param int $width Width * - * @return array frame + * @return array frame */ public function putAlignmentPattern( int $version, diff --git a/src/Type/Square/QrCode/Split.php b/src/Type/Square/QrCode/Split.php index 3809c34c..df5179cb 100644 --- a/src/Type/Square/QrCode/Split.php +++ b/src/Type/Square/QrCode/Split.php @@ -28,11 +28,15 @@ * @copyright 2010-2023 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode + * + * @phpstan-import-type Item from \Com\Tecnick\Barcode\Type\Square\QrCode\Estimate */ class Split { /** * Input items + * + * @var array */ protected array $items = []; @@ -67,7 +71,7 @@ public function __construct( * * @param string $data Data * - * @return array items + * @return array items */ public function getSplittedString(string $data): array {