作者 曹东东

二维码

要显示太多修改。

为保证性能只显示 26 of 26+ 个文件。

@@ -25,6 +25,7 @@ class Index extends Frontend @@ -25,6 +25,7 @@ class Index extends Frontend
25 protected $template = 'weilai'; 25 protected $template = 'weilai';
26 public function _initialize() 26 public function _initialize()
27 { 27 {
  28 + dump($config = get_addon_config('upyun'));die;
28 parent::_initialize(); // TODO: Change the autogenerated stub 29 parent::_initialize(); // TODO: Change the autogenerated stub
29 $template = TemplateView::getSchoolTemplate( $this->school_id); 30 $template = TemplateView::getSchoolTemplate( $this->school_id);
30 $this->layout = $template->layout ?? 'default'; 31 $this->layout = $template->layout ?? 'default';
@@ -27,9 +27,20 @@ @@ -27,9 +27,20 @@
27 "symfony/var-exporter": "^4.4.13", 27 "symfony/var-exporter": "^4.4.13",
28 "ext-json": "*", 28 "ext-json": "*",
29 "ext-curl": "*", 29 "ext-curl": "*",
30 - "ext-pdo": "*" 30 + "ext-pdo": "*",
  31 + "endroid/qrcode": "^2.1"
31 }, 32 },
32 "config": { 33 "config": {
33 - "preferred-install": "dist" 34 + "preferred-install": "dist",
  35 + "allow-plugins": {
  36 + "topthink/think-installer": true,
  37 + "easywechat-composer/easywechat-composer": true
  38 + }
  39 + },
  40 + "repositories": {
  41 + "packagist": {
  42 + "type": "composer",
  43 + "url": "https://mirrors.huaweicloud.com/repository/php/"
  44 + }
34 } 45 }
35 } 46 }
@@ -4,9 +4,54 @@ @@ -4,9 +4,54 @@
4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 "This file is @generated automatically" 5 "This file is @generated automatically"
6 ], 6 ],
7 - "content-hash": "4a630f335229986f47661bbe170400d4", 7 + "content-hash": "7e5fc6d1e698abe4bb5bc60b23f4277d",
8 "packages": [ 8 "packages": [
9 { 9 {
  10 + "name": "bacon/bacon-qr-code",
  11 + "version": "1.0.3",
  12 + "source": {
  13 + "type": "git",
  14 + "url": "https://github.com/Bacon/BaconQrCode.git",
  15 + "reference": "5a91b62b9d37cee635bbf8d553f4546057250bee"
  16 + },
  17 + "dist": {
  18 + "type": "zip",
  19 + "url": "https://mirrors.huaweicloud.com/repository/php/bacon/bacon-qr-code/1.0.3/bacon-bacon-qr-code-1.0.3.zip",
  20 + "reference": "5a91b62b9d37cee635bbf8d553f4546057250bee",
  21 + "shasum": ""
  22 + },
  23 + "require": {
  24 + "ext-iconv": "*",
  25 + "php": "^5.4|^7.0"
  26 + },
  27 + "require-dev": {
  28 + "phpunit/phpunit": "^4.8"
  29 + },
  30 + "suggest": {
  31 + "ext-gd": "to generate QR code images"
  32 + },
  33 + "type": "library",
  34 + "autoload": {
  35 + "psr-0": {
  36 + "BaconQrCode": "src/"
  37 + }
  38 + },
  39 + "license": [
  40 + "BSD-2-Clause"
  41 + ],
  42 + "authors": [
  43 + {
  44 + "name": "Ben Scholzen 'DASPRiD'",
  45 + "email": "mail@dasprids.de",
  46 + "homepage": "http://www.dasprids.de",
  47 + "role": "Developer"
  48 + }
  49 + ],
  50 + "description": "BaconQrCode is a QR code generator for PHP.",
  51 + "homepage": "https://github.com/Bacon/BaconQrCode",
  52 + "time": "2017-10-17T09:59:25+00:00"
  53 + },
  54 + {
10 "name": "easywechat-composer/easywechat-composer", 55 "name": "easywechat-composer/easywechat-composer",
11 "version": "1.4.0", 56 "version": "1.4.0",
12 "source": { 57 "source": {
@@ -18,13 +63,7 @@ @@ -18,13 +63,7 @@
18 "type": "zip", 63 "type": "zip",
19 "url": "https://api.github.com/repos/mingyoung/easywechat-composer/zipball/93cfce1ec842b9a5b1b0791a52afd18b833f114a", 64 "url": "https://api.github.com/repos/mingyoung/easywechat-composer/zipball/93cfce1ec842b9a5b1b0791a52afd18b833f114a",
20 "reference": "93cfce1ec842b9a5b1b0791a52afd18b833f114a", 65 "reference": "93cfce1ec842b9a5b1b0791a52afd18b833f114a",
21 - "shasum": "",  
22 - "mirrors": [  
23 - {  
24 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
25 - "preferred": true  
26 - }  
27 - ] 66 + "shasum": ""
28 }, 67 },
29 "require": { 68 "require": {
30 "composer-plugin-api": "^1.0 || ^2.0", 69 "composer-plugin-api": "^1.0 || ^2.0",
@@ -57,6 +96,75 @@ @@ -57,6 +96,75 @@
57 "time": "2020-07-23T11:06:47+00:00" 96 "time": "2020-07-23T11:06:47+00:00"
58 }, 97 },
59 { 98 {
  99 + "name": "endroid/qrcode",
  100 + "version": "2.5.1",
  101 + "source": {
  102 + "type": "git",
  103 + "url": "https://github.com/endroid/qr-code.git",
  104 + "reference": "6062677d3404e0ded40647b8f62ec55ff9722eb7"
  105 + },
  106 + "dist": {
  107 + "type": "zip",
  108 + "url": "https://mirrors.huaweicloud.com/repository/php/endroid/qrcode/2.5.1/endroid-qrcode-2.5.1.zip",
  109 + "reference": "6062677d3404e0ded40647b8f62ec55ff9722eb7",
  110 + "shasum": ""
  111 + },
  112 + "require": {
  113 + "bacon/bacon-qr-code": "^1.0.3",
  114 + "ext-gd": "*",
  115 + "khanamiryan/qrcode-detector-decoder": "1",
  116 + "myclabs/php-enum": "^1.5",
  117 + "php": ">=5.6",
  118 + "symfony/options-resolver": "^2.7",
  119 + "symfony/property-access": "^2.7"
  120 + },
  121 + "require-dev": {
  122 + "phpunit/phpunit": "^5.7",
  123 + "symfony/asset": "^2.7",
  124 + "symfony/browser-kit": "^2.7",
  125 + "symfony/finder": "^2.7",
  126 + "symfony/framework-bundle": "^2.7",
  127 + "symfony/http-kernel": "^2.7",
  128 + "symfony/templating": "^2.7",
  129 + "symfony/twig-bundle": "^2.7",
  130 + "symfony/yaml": "^2.7"
  131 + },
  132 + "type": "symfony-bundle",
  133 + "extra": {
  134 + "branch-alias": {
  135 + "dev-master": "2.x-dev"
  136 + }
  137 + },
  138 + "autoload": {
  139 + "psr-4": {
  140 + "Endroid\\QrCode\\": "src/"
  141 + }
  142 + },
  143 + "license": [
  144 + "MIT"
  145 + ],
  146 + "authors": [
  147 + {
  148 + "name": "Jeroen van den Enden",
  149 + "email": "info@endroid.nl",
  150 + "homepage": "http://endroid.nl/"
  151 + }
  152 + ],
  153 + "description": "Endroid QR Code",
  154 + "homepage": "https://github.com/endroid/QrCode",
  155 + "keywords": [
  156 + "bundle",
  157 + "code",
  158 + "endroid",
  159 + "flex",
  160 + "qr",
  161 + "qrcode",
  162 + "symfony"
  163 + ],
  164 + "abandoned": "endroid/qr-code",
  165 + "time": "2018-05-09T20:26:30+00:00"
  166 + },
  167 + {
60 "name": "guzzlehttp/guzzle", 168 "name": "guzzlehttp/guzzle",
61 "version": "6.5.5", 169 "version": "6.5.5",
62 "source": { 170 "source": {
@@ -68,13 +176,7 @@ @@ -68,13 +176,7 @@
68 "type": "zip", 176 "type": "zip",
69 "url": "https://api.github.com/repos/guzzle/guzzle/zipball/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e", 177 "url": "https://api.github.com/repos/guzzle/guzzle/zipball/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
70 "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e", 178 "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
71 - "shasum": "",  
72 - "mirrors": [  
73 - {  
74 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
75 - "preferred": true  
76 - }  
77 - ] 179 + "shasum": ""
78 }, 180 },
79 "require": { 181 "require": {
80 "ext-json": "*", 182 "ext-json": "*",
@@ -141,13 +243,7 @@ @@ -141,13 +243,7 @@
141 "type": "zip", 243 "type": "zip",
142 "url": "https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631", 244 "url": "https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631",
143 "reference": "60d379c243457e073cff02bc323a2a86cb355631", 245 "reference": "60d379c243457e073cff02bc323a2a86cb355631",
144 - "shasum": "",  
145 - "mirrors": [  
146 - {  
147 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
148 - "preferred": true  
149 - }  
150 - ] 246 + "shasum": ""
151 }, 247 },
152 "require": { 248 "require": {
153 "php": ">=5.5" 249 "php": ">=5.5"
@@ -198,13 +294,7 @@ @@ -198,13 +294,7 @@
198 "type": "zip", 294 "type": "zip",
199 "url": "https://api.github.com/repos/guzzle/psr7/zipball/53330f47520498c0ae1f61f7e2c90f55690c06a3", 295 "url": "https://api.github.com/repos/guzzle/psr7/zipball/53330f47520498c0ae1f61f7e2c90f55690c06a3",
200 "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3", 296 "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3",
201 - "shasum": "",  
202 - "mirrors": [  
203 - {  
204 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
205 - "preferred": true  
206 - }  
207 - ] 297 + "shasum": ""
208 }, 298 },
209 "require": { 299 "require": {
210 "php": ">=5.4.0", 300 "php": ">=5.4.0",
@@ -275,13 +365,7 @@ @@ -275,13 +365,7 @@
275 "type": "zip", 365 "type": "zip",
276 "url": "https://api.github.com/repos/karsonzhang/fastadmin-addons/zipball/24b9cad089003488e6b03dc44dc029bcf3b88cf4", 366 "url": "https://api.github.com/repos/karsonzhang/fastadmin-addons/zipball/24b9cad089003488e6b03dc44dc029bcf3b88cf4",
277 "reference": "24b9cad089003488e6b03dc44dc029bcf3b88cf4", 367 "reference": "24b9cad089003488e6b03dc44dc029bcf3b88cf4",
278 - "shasum": "",  
279 - "mirrors": [  
280 - {  
281 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
282 - "preferred": true  
283 - }  
284 - ] 368 + "shasum": ""
285 }, 369 },
286 "require": { 370 "require": {
287 "nelexa/zip": "^3.3", 371 "nelexa/zip": "^3.3",
@@ -321,6 +405,55 @@ @@ -321,6 +405,55 @@
321 "time": "2020-10-13T08:22:20+00:00" 405 "time": "2020-10-13T08:22:20+00:00"
322 }, 406 },
323 { 407 {
  408 + "name": "khanamiryan/qrcode-detector-decoder",
  409 + "version": "1",
  410 + "source": {
  411 + "type": "git",
  412 + "url": "https://github.com/khanamiryan/php-qrcode-detector-decoder.git",
  413 + "reference": "96d5f80680b04803c4f1b69d6e01735e876b80c7"
  414 + },
  415 + "dist": {
  416 + "type": "zip",
  417 + "url": "https://mirrors.huaweicloud.com/repository/php/khanamiryan/qrcode-detector-decoder/1/khanamiryan-qrcode-detector-decoder-1.zip",
  418 + "reference": "96d5f80680b04803c4f1b69d6e01735e876b80c7",
  419 + "shasum": ""
  420 + },
  421 + "require": {
  422 + "php": "^5.6|^7.0"
  423 + },
  424 + "require-dev": {
  425 + "phpunit/phpunit": "^5.7"
  426 + },
  427 + "type": "library",
  428 + "autoload": {
  429 + "files": [
  430 + "lib/common/customFunctions.php"
  431 + ],
  432 + "classmap": [
  433 + "lib/"
  434 + ]
  435 + },
  436 + "license": [
  437 + "MIT"
  438 + ],
  439 + "authors": [
  440 + {
  441 + "name": "Ashot Khanamiryan",
  442 + "email": "a.khanamiryan@gmail.com",
  443 + "homepage": "https://github.com/khanamiryan",
  444 + "role": "Developer"
  445 + }
  446 + ],
  447 + "description": "QR code decoder / reader",
  448 + "homepage": "https://github.com/khanamiryan/php-qrcode-detector-decoder",
  449 + "keywords": [
  450 + "barcode",
  451 + "qr",
  452 + "zxing"
  453 + ],
  454 + "time": "2017-01-13T09:11:46+00:00"
  455 + },
  456 + {
324 "name": "maennchen/zipstream-php", 457 "name": "maennchen/zipstream-php",
325 "version": "2.1.0", 458 "version": "2.1.0",
326 "source": { 459 "source": {
@@ -332,13 +465,7 @@ @@ -332,13 +465,7 @@
332 "type": "zip", 465 "type": "zip",
333 "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/c4c5803cc1f93df3d2448478ef79394a5981cc58", 466 "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/c4c5803cc1f93df3d2448478ef79394a5981cc58",
334 "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58", 467 "reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58",
335 - "shasum": "",  
336 - "mirrors": [  
337 - {  
338 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
339 - "preferred": true  
340 - }  
341 - ] 468 + "shasum": ""
342 }, 469 },
343 "require": { 470 "require": {
344 "myclabs/php-enum": "^1.5", 471 "myclabs/php-enum": "^1.5",
@@ -405,13 +532,7 @@ @@ -405,13 +532,7 @@
405 "type": "zip", 532 "type": "zip",
406 "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/9999f1432fae467bc93c53f357105b4c31bb994c", 533 "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/9999f1432fae467bc93c53f357105b4c31bb994c",
407 "reference": "9999f1432fae467bc93c53f357105b4c31bb994c", 534 "reference": "9999f1432fae467bc93c53f357105b4c31bb994c",
408 - "shasum": "",  
409 - "mirrors": [  
410 - {  
411 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
412 - "preferred": true  
413 - }  
414 - ] 535 + "shasum": ""
415 }, 536 },
416 "require": { 537 "require": {
417 "php": "^7.2 || ^8.0" 538 "php": "^7.2 || ^8.0"
@@ -506,13 +627,7 @@ @@ -506,13 +627,7 @@
506 "type": "zip", 627 "type": "zip",
507 "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/9567d9c4c519fbe40de01dbd1e4469dbbb66f46a", 628 "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/9567d9c4c519fbe40de01dbd1e4469dbbb66f46a",
508 "reference": "9567d9c4c519fbe40de01dbd1e4469dbbb66f46a", 629 "reference": "9567d9c4c519fbe40de01dbd1e4469dbbb66f46a",
509 - "shasum": "",  
510 - "mirrors": [  
511 - {  
512 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
513 - "preferred": true  
514 - }  
515 - ] 630 + "shasum": ""
516 }, 631 },
517 "require": { 632 "require": {
518 "php": "^7.2 || ^8.0" 633 "php": "^7.2 || ^8.0"
@@ -582,13 +697,7 @@ @@ -582,13 +697,7 @@
582 "type": "zip", 697 "type": "zip",
583 "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f9eee5cec93dfb313a38b6b288741e84e53f02d5", 698 "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f9eee5cec93dfb313a38b6b288741e84e53f02d5",
584 "reference": "f9eee5cec93dfb313a38b6b288741e84e53f02d5", 699 "reference": "f9eee5cec93dfb313a38b6b288741e84e53f02d5",
585 - "shasum": "",  
586 - "mirrors": [  
587 - {  
588 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
589 - "preferred": true  
590 - }  
591 - ] 700 + "shasum": ""
592 }, 701 },
593 "require": { 702 "require": {
594 "php": ">=7.2", 703 "php": ">=7.2",
@@ -679,13 +788,7 @@ @@ -679,13 +788,7 @@
679 "type": "zip", 788 "type": "zip",
680 "url": "https://api.github.com/repos/myclabs/php-enum/zipball/5f36467c7a87e20fbdc51e524fd8f9d1de80187c", 789 "url": "https://api.github.com/repos/myclabs/php-enum/zipball/5f36467c7a87e20fbdc51e524fd8f9d1de80187c",
681 "reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c", 790 "reference": "5f36467c7a87e20fbdc51e524fd8f9d1de80187c",
682 - "shasum": "",  
683 - "mirrors": [  
684 - {  
685 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
686 - "preferred": true  
687 - }  
688 - ] 791 + "shasum": ""
689 }, 792 },
690 "require": { 793 "require": {
691 "ext-json": "*", 794 "ext-json": "*",
@@ -731,13 +834,7 @@ @@ -731,13 +834,7 @@
731 "type": "zip", 834 "type": "zip",
732 "url": "https://api.github.com/repos/Ne-Lexa/php-zip/zipball/501b52f6fc393a599b44ff348a42740e1eaac7c6", 835 "url": "https://api.github.com/repos/Ne-Lexa/php-zip/zipball/501b52f6fc393a599b44ff348a42740e1eaac7c6",
733 "reference": "501b52f6fc393a599b44ff348a42740e1eaac7c6", 836 "reference": "501b52f6fc393a599b44ff348a42740e1eaac7c6",
734 - "shasum": "",  
735 - "mirrors": [  
736 - {  
737 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
738 - "preferred": true  
739 - }  
740 - ] 837 + "shasum": ""
741 }, 838 },
742 "require": { 839 "require": {
743 "ext-zlib": "*", 840 "ext-zlib": "*",
@@ -803,13 +900,7 @@ @@ -803,13 +900,7 @@
803 "type": "zip", 900 "type": "zip",
804 "url": "https://api.github.com/repos/overtrue/pinyin/zipball/3b781d267197b74752daa32814d3a2cf5d140779", 901 "url": "https://api.github.com/repos/overtrue/pinyin/zipball/3b781d267197b74752daa32814d3a2cf5d140779",
805 "reference": "3b781d267197b74752daa32814d3a2cf5d140779", 902 "reference": "3b781d267197b74752daa32814d3a2cf5d140779",
806 - "shasum": "",  
807 - "mirrors": [  
808 - {  
809 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
810 - "preferred": true  
811 - }  
812 - ] 903 + "shasum": ""
813 }, 904 },
814 "require": { 905 "require": {
815 "php": ">=5.3" 906 "php": ">=5.3"
@@ -854,13 +945,7 @@ @@ -854,13 +945,7 @@
854 "type": "zip", 945 "type": "zip",
855 "url": "https://api.github.com/repos/overtrue/socialite/zipball/ae4c8d1e9fe39418b9a598d42f01d7c1fe30f200", 946 "url": "https://api.github.com/repos/overtrue/socialite/zipball/ae4c8d1e9fe39418b9a598d42f01d7c1fe30f200",
856 "reference": "ae4c8d1e9fe39418b9a598d42f01d7c1fe30f200", 947 "reference": "ae4c8d1e9fe39418b9a598d42f01d7c1fe30f200",
857 - "shasum": "",  
858 - "mirrors": [  
859 - {  
860 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
861 - "preferred": true  
862 - }  
863 - ] 948 + "shasum": ""
864 }, 949 },
865 "require": { 950 "require": {
866 "ext-json": "*", 951 "ext-json": "*",
@@ -913,20 +998,14 @@ @@ -913,20 +998,14 @@
913 "version": "4.2.11", 998 "version": "4.2.11",
914 "source": { 999 "source": {
915 "type": "git", 1000 "type": "git",
916 - "url": "https://github.com/overtrue/wechat.git", 1001 + "url": "https://github.com/w7corp/easywechat.git",
917 "reference": "853e0772e6aa53a71edf1b5d251c7ff1e6b2a2bf" 1002 "reference": "853e0772e6aa53a71edf1b5d251c7ff1e6b2a2bf"
918 }, 1003 },
919 "dist": { 1004 "dist": {
920 "type": "zip", 1005 "type": "zip",
921 "url": "https://api.github.com/repos/overtrue/wechat/zipball/853e0772e6aa53a71edf1b5d251c7ff1e6b2a2bf", 1006 "url": "https://api.github.com/repos/overtrue/wechat/zipball/853e0772e6aa53a71edf1b5d251c7ff1e6b2a2bf",
922 "reference": "853e0772e6aa53a71edf1b5d251c7ff1e6b2a2bf", 1007 "reference": "853e0772e6aa53a71edf1b5d251c7ff1e6b2a2bf",
923 - "shasum": "",  
924 - "mirrors": [  
925 - {  
926 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
927 - "preferred": true  
928 - }  
929 - ] 1008 + "shasum": ""
930 }, 1009 },
931 "require": { 1010 "require": {
932 "easywechat-composer/easywechat-composer": "^1.1", 1011 "easywechat-composer/easywechat-composer": "^1.1",
@@ -978,6 +1057,7 @@ @@ -978,6 +1057,7 @@
978 "weixin", 1057 "weixin",
979 "weixin-sdk" 1058 "weixin-sdk"
980 ], 1059 ],
  1060 + "abandoned": "w7corp/easywechat",
981 "time": "2019-11-27T16:38:00+00:00" 1061 "time": "2019-11-27T16:38:00+00:00"
982 }, 1062 },
983 { 1063 {
@@ -992,13 +1072,7 @@ @@ -992,13 +1072,7 @@
992 "type": "zip", 1072 "type": "zip",
993 "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", 1073 "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
994 "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", 1074 "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
995 - "shasum": "",  
996 - "mirrors": [  
997 - {  
998 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
999 - "preferred": true  
1000 - }  
1001 - ] 1075 + "shasum": ""
1002 }, 1076 },
1003 "require": { 1077 "require": {
1004 "php": "^7" 1078 "php": "^7"
@@ -1043,13 +1117,7 @@ @@ -1043,13 +1117,7 @@
1043 "type": "zip", 1117 "type": "zip",
1044 "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/917ab212fa00dc6eacbb26e8bc387ebe40993bc1", 1118 "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/917ab212fa00dc6eacbb26e8bc387ebe40993bc1",
1045 "reference": "917ab212fa00dc6eacbb26e8bc387ebe40993bc1", 1119 "reference": "917ab212fa00dc6eacbb26e8bc387ebe40993bc1",
1046 - "shasum": "",  
1047 - "mirrors": [  
1048 - {  
1049 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1050 - "preferred": true  
1051 - }  
1052 - ] 1120 + "shasum": ""
1053 }, 1121 },
1054 "require": { 1122 "require": {
1055 "ext-ctype": "*", 1123 "ext-ctype": "*",
@@ -1118,13 +1186,7 @@ @@ -1118,13 +1186,7 @@
1118 "type": "zip", 1186 "type": "zip",
1119 "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/a8e8068b31b8119e1daa5b1eb5715a3a8ea8305f", 1187 "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/a8e8068b31b8119e1daa5b1eb5715a3a8ea8305f",
1120 "reference": "a8e8068b31b8119e1daa5b1eb5715a3a8ea8305f", 1188 "reference": "a8e8068b31b8119e1daa5b1eb5715a3a8ea8305f",
1121 - "shasum": "",  
1122 - "mirrors": [  
1123 - {  
1124 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1125 - "preferred": true  
1126 - }  
1127 - ] 1189 + "shasum": ""
1128 }, 1190 },
1129 "require": { 1191 "require": {
1130 "ext-ctype": "*", 1192 "ext-ctype": "*",
@@ -1220,13 +1282,7 @@ @@ -1220,13 +1282,7 @@
1220 "type": "zip", 1282 "type": "zip",
1221 "url": "https://api.github.com/repos/silexphp/Pimple/zipball/e55d12f9d6a0e7f9c85992b73df1267f46279930", 1283 "url": "https://api.github.com/repos/silexphp/Pimple/zipball/e55d12f9d6a0e7f9c85992b73df1267f46279930",
1222 "reference": "e55d12f9d6a0e7f9c85992b73df1267f46279930", 1284 "reference": "e55d12f9d6a0e7f9c85992b73df1267f46279930",
1223 - "shasum": "",  
1224 - "mirrors": [  
1225 - {  
1226 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1227 - "preferred": true  
1228 - }  
1229 - ] 1285 + "shasum": ""
1230 }, 1286 },
1231 "require": { 1287 "require": {
1232 "php": "^7.2.5", 1288 "php": "^7.2.5",
@@ -1276,13 +1332,7 @@ @@ -1276,13 +1332,7 @@
1276 "type": "zip", 1332 "type": "zip",
1277 "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", 1333 "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
1278 "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", 1334 "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
1279 - "shasum": "",  
1280 - "mirrors": [  
1281 - {  
1282 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1283 - "preferred": true  
1284 - }  
1285 - ] 1335 + "shasum": ""
1286 }, 1336 },
1287 "require": { 1337 "require": {
1288 "php": ">=5.3.0" 1338 "php": ">=5.3.0"
@@ -1328,13 +1378,7 @@ @@ -1328,13 +1378,7 @@
1328 "type": "zip", 1378 "type": "zip",
1329 "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 1379 "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
1330 "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 1380 "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
1331 - "shasum": "",  
1332 - "mirrors": [  
1333 - {  
1334 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1335 - "preferred": true  
1336 - }  
1337 - ] 1381 + "shasum": ""
1338 }, 1382 },
1339 "require": { 1383 "require": {
1340 "php": ">=5.3.0" 1384 "php": ">=5.3.0"
@@ -1383,13 +1427,7 @@ @@ -1383,13 +1427,7 @@
1383 "type": "zip", 1427 "type": "zip",
1384 "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", 1428 "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
1385 "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", 1429 "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
1386 - "shasum": "",  
1387 - "mirrors": [  
1388 - {  
1389 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1390 - "preferred": true  
1391 - }  
1392 - ] 1430 + "shasum": ""
1393 }, 1431 },
1394 "require": { 1432 "require": {
1395 "php": "^7.0 || ^8.0", 1433 "php": "^7.0 || ^8.0",
@@ -1438,13 +1476,7 @@ @@ -1438,13 +1476,7 @@
1438 "type": "zip", 1476 "type": "zip",
1439 "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", 1477 "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
1440 "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", 1478 "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
1441 - "shasum": "",  
1442 - "mirrors": [  
1443 - {  
1444 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1445 - "preferred": true  
1446 - }  
1447 - ] 1479 + "shasum": ""
1448 }, 1480 },
1449 "require": { 1481 "require": {
1450 "php": ">=7.0.0", 1482 "php": ">=7.0.0",
@@ -1496,13 +1528,7 @@ @@ -1496,13 +1528,7 @@
1496 "type": "zip", 1528 "type": "zip",
1497 "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", 1529 "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
1498 "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", 1530 "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
1499 - "shasum": "",  
1500 - "mirrors": [  
1501 - {  
1502 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1503 - "preferred": true  
1504 - }  
1505 - ] 1531 + "shasum": ""
1506 }, 1532 },
1507 "require": { 1533 "require": {
1508 "php": ">=5.3.0" 1534 "php": ">=5.3.0"
@@ -1552,13 +1578,7 @@ @@ -1552,13 +1578,7 @@
1552 "type": "zip", 1578 "type": "zip",
1553 "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", 1579 "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
1554 "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", 1580 "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
1555 - "shasum": "",  
1556 - "mirrors": [  
1557 - {  
1558 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1559 - "preferred": true  
1560 - }  
1561 - ] 1581 + "shasum": ""
1562 }, 1582 },
1563 "require": { 1583 "require": {
1564 "php": ">=5.3.0" 1584 "php": ">=5.3.0"
@@ -1605,13 +1625,7 @@ @@ -1605,13 +1625,7 @@
1605 "type": "zip", 1625 "type": "zip",
1606 "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", 1626 "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
1607 "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", 1627 "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
1608 - "shasum": "",  
1609 - "mirrors": [  
1610 - {  
1611 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1612 - "preferred": true  
1613 - }  
1614 - ] 1628 + "shasum": ""
1615 }, 1629 },
1616 "require": { 1630 "require": {
1617 "php": ">=5.3.0" 1631 "php": ">=5.3.0"
@@ -1659,13 +1673,7 @@ @@ -1659,13 +1673,7 @@
1659 "type": "zip", 1673 "type": "zip",
1660 "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", 1674 "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
1661 "reference": "120b605dfeb996808c31b6477290a714d356e822", 1675 "reference": "120b605dfeb996808c31b6477290a714d356e822",
1662 - "shasum": "",  
1663 - "mirrors": [  
1664 - {  
1665 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1666 - "preferred": true  
1667 - }  
1668 - ] 1676 + "shasum": ""
1669 }, 1677 },
1670 "require": { 1678 "require": {
1671 "php": ">=5.6" 1679 "php": ">=5.6"
@@ -1705,13 +1713,7 @@ @@ -1705,13 +1713,7 @@
1705 "type": "zip", 1713 "type": "zip",
1706 "url": "https://api.github.com/repos/symfony/cache/zipball/969a76c2dbce7e4306684f5376718147d1ec4ae7", 1714 "url": "https://api.github.com/repos/symfony/cache/zipball/969a76c2dbce7e4306684f5376718147d1ec4ae7",
1707 "reference": "969a76c2dbce7e4306684f5376718147d1ec4ae7", 1715 "reference": "969a76c2dbce7e4306684f5376718147d1ec4ae7",
1708 - "shasum": "",  
1709 - "mirrors": [  
1710 - {  
1711 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1712 - "preferred": true  
1713 - }  
1714 - ] 1716 + "shasum": ""
1715 }, 1717 },
1716 "require": { 1718 "require": {
1717 "php": ">=7.1.3", 1719 "php": ">=7.1.3",
@@ -1804,13 +1806,7 @@ @@ -1804,13 +1806,7 @@
1804 "type": "zip", 1806 "type": "zip",
1805 "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/8034ca0b61d4dd967f3698aaa1da2507b631d0cb", 1807 "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/8034ca0b61d4dd967f3698aaa1da2507b631d0cb",
1806 "reference": "8034ca0b61d4dd967f3698aaa1da2507b631d0cb", 1808 "reference": "8034ca0b61d4dd967f3698aaa1da2507b631d0cb",
1807 - "shasum": "",  
1808 - "mirrors": [  
1809 - {  
1810 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1811 - "preferred": true  
1812 - }  
1813 - ] 1809 + "shasum": ""
1814 }, 1810 },
1815 "require": { 1811 "require": {
1816 "php": ">=7.2.5", 1812 "php": ">=7.2.5",
@@ -1886,13 +1882,7 @@ @@ -1886,13 +1882,7 @@
1886 "type": "zip", 1882 "type": "zip",
1887 "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/e17bb5e0663dc725f7cdcafc932132735b4725cd", 1883 "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/e17bb5e0663dc725f7cdcafc932132735b4725cd",
1888 "reference": "e17bb5e0663dc725f7cdcafc932132735b4725cd", 1884 "reference": "e17bb5e0663dc725f7cdcafc932132735b4725cd",
1889 - "shasum": "",  
1890 - "mirrors": [  
1891 - {  
1892 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1893 - "preferred": true  
1894 - }  
1895 - ] 1885 + "shasum": ""
1896 }, 1886 },
1897 "require": { 1887 "require": {
1898 "php": ">=7.1.3", 1888 "php": ">=7.1.3",
@@ -1977,13 +1967,7 @@ @@ -1977,13 +1967,7 @@
1977 "type": "zip", 1967 "type": "zip",
1978 "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/84e23fdcd2517bf37aecbd16967e83f0caee25a7", 1968 "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/84e23fdcd2517bf37aecbd16967e83f0caee25a7",
1979 "reference": "84e23fdcd2517bf37aecbd16967e83f0caee25a7", 1969 "reference": "84e23fdcd2517bf37aecbd16967e83f0caee25a7",
1980 - "shasum": "",  
1981 - "mirrors": [  
1982 - {  
1983 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
1984 - "preferred": true  
1985 - }  
1986 - ] 1970 + "shasum": ""
1987 }, 1971 },
1988 "require": { 1972 "require": {
1989 "php": ">=7.1.3" 1973 "php": ">=7.1.3"
@@ -2059,13 +2043,7 @@ @@ -2059,13 +2043,7 @@
2059 "type": "zip", 2043 "type": "zip",
2060 "url": "https://api.github.com/repos/symfony/finder/zipball/2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8", 2044 "url": "https://api.github.com/repos/symfony/finder/zipball/2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8",
2061 "reference": "2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8", 2045 "reference": "2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8",
2062 - "shasum": "",  
2063 - "mirrors": [  
2064 - {  
2065 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2066 - "preferred": true  
2067 - }  
2068 - ] 2046 + "shasum": ""
2069 }, 2047 },
2070 "require": { 2048 "require": {
2071 "php": ">=7.2.5" 2049 "php": ">=7.2.5"
@@ -2128,13 +2106,7 @@ @@ -2128,13 +2106,7 @@
2128 "type": "zip", 2106 "type": "zip",
2129 "url": "https://api.github.com/repos/symfony/http-foundation/zipball/10683b407c3b6087c64619ebc97a87e36ea62c92", 2107 "url": "https://api.github.com/repos/symfony/http-foundation/zipball/10683b407c3b6087c64619ebc97a87e36ea62c92",
2130 "reference": "10683b407c3b6087c64619ebc97a87e36ea62c92", 2108 "reference": "10683b407c3b6087c64619ebc97a87e36ea62c92",
2131 - "shasum": "",  
2132 - "mirrors": [  
2133 - {  
2134 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2135 - "preferred": true  
2136 - }  
2137 - ] 2109 + "shasum": ""
2138 }, 2110 },
2139 "require": { 2111 "require": {
2140 "php": ">=7.1.3", 2112 "php": ">=7.1.3",
@@ -2203,13 +2175,7 @@ @@ -2203,13 +2175,7 @@
2203 "type": "zip", 2175 "type": "zip",
2204 "url": "https://api.github.com/repos/symfony/mime/zipball/4404d6545125863561721514ad9388db2661eec5", 2176 "url": "https://api.github.com/repos/symfony/mime/zipball/4404d6545125863561721514ad9388db2661eec5",
2205 "reference": "4404d6545125863561721514ad9388db2661eec5", 2177 "reference": "4404d6545125863561721514ad9388db2661eec5",
2206 - "shasum": "",  
2207 - "mirrors": [  
2208 - {  
2209 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2210 - "preferred": true  
2211 - }  
2212 - ] 2178 + "shasum": ""
2213 }, 2179 },
2214 "require": { 2180 "require": {
2215 "php": ">=7.2.5", 2181 "php": ">=7.2.5",
@@ -2275,6 +2241,137 @@ @@ -2275,6 +2241,137 @@
2275 "time": "2020-09-02T16:23:27+00:00" 2241 "time": "2020-09-02T16:23:27+00:00"
2276 }, 2242 },
2277 { 2243 {
  2244 + "name": "symfony/options-resolver",
  2245 + "version": "v2.8.52",
  2246 + "source": {
  2247 + "type": "git",
  2248 + "url": "https://github.com/symfony/options-resolver.git",
  2249 + "reference": "7aaab725bb58f0e18aa12c61bdadd4793ab4c32b"
  2250 + },
  2251 + "dist": {
  2252 + "type": "zip",
  2253 + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/options-resolver/v2.8.52/symfony-options-resolver-v2.8.52.zip",
  2254 + "reference": "7aaab725bb58f0e18aa12c61bdadd4793ab4c32b",
  2255 + "shasum": ""
  2256 + },
  2257 + "require": {
  2258 + "php": ">=5.3.9"
  2259 + },
  2260 + "type": "library",
  2261 + "extra": {
  2262 + "branch-alias": {
  2263 + "dev-master": "2.8-dev"
  2264 + }
  2265 + },
  2266 + "autoload": {
  2267 + "psr-4": {
  2268 + "Symfony\\Component\\OptionsResolver\\": ""
  2269 + },
  2270 + "exclude-from-classmap": [
  2271 + "/Tests/"
  2272 + ]
  2273 + },
  2274 + "license": [
  2275 + "MIT"
  2276 + ],
  2277 + "authors": [
  2278 + {
  2279 + "name": "Fabien Potencier",
  2280 + "email": "fabien@symfony.com"
  2281 + },
  2282 + {
  2283 + "name": "Symfony Community",
  2284 + "homepage": "https://symfony.com/contributors"
  2285 + }
  2286 + ],
  2287 + "description": "Symfony OptionsResolver Component",
  2288 + "homepage": "https://symfony.com",
  2289 + "keywords": [
  2290 + "config",
  2291 + "configuration",
  2292 + "options"
  2293 + ],
  2294 + "time": "2018-11-11T11:18:13+00:00"
  2295 + },
  2296 + {
  2297 + "name": "symfony/polyfill-ctype",
  2298 + "version": "v1.25.0",
  2299 + "source": {
  2300 + "type": "git",
  2301 + "url": "https://github.com/symfony/polyfill-ctype.git",
  2302 + "reference": "30885182c981ab175d4d034db0f6f469898070ab"
  2303 + },
  2304 + "dist": {
  2305 + "type": "zip",
  2306 + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-ctype/v1.25.0/symfony-polyfill-ctype-v1.25.0.zip",
  2307 + "reference": "30885182c981ab175d4d034db0f6f469898070ab",
  2308 + "shasum": ""
  2309 + },
  2310 + "require": {
  2311 + "php": ">=7.1"
  2312 + },
  2313 + "provide": {
  2314 + "ext-ctype": "*"
  2315 + },
  2316 + "suggest": {
  2317 + "ext-ctype": "For best performance"
  2318 + },
  2319 + "type": "library",
  2320 + "extra": {
  2321 + "branch-alias": {
  2322 + "dev-main": "1.23-dev"
  2323 + },
  2324 + "thanks": {
  2325 + "name": "symfony/polyfill",
  2326 + "url": "https://github.com/symfony/polyfill"
  2327 + }
  2328 + },
  2329 + "autoload": {
  2330 + "files": [
  2331 + "bootstrap.php"
  2332 + ],
  2333 + "psr-4": {
  2334 + "Symfony\\Polyfill\\Ctype\\": ""
  2335 + }
  2336 + },
  2337 + "license": [
  2338 + "MIT"
  2339 + ],
  2340 + "authors": [
  2341 + {
  2342 + "name": "Gert de Pagter",
  2343 + "email": "BackEndTea@gmail.com"
  2344 + },
  2345 + {
  2346 + "name": "Symfony Community",
  2347 + "homepage": "https://symfony.com/contributors"
  2348 + }
  2349 + ],
  2350 + "description": "Symfony polyfill for ctype functions",
  2351 + "homepage": "https://symfony.com",
  2352 + "keywords": [
  2353 + "compatibility",
  2354 + "ctype",
  2355 + "polyfill",
  2356 + "portable"
  2357 + ],
  2358 + "funding": [
  2359 + {
  2360 + "url": "https://symfony.com/sponsor",
  2361 + "type": "custom"
  2362 + },
  2363 + {
  2364 + "url": "https://github.com/fabpot",
  2365 + "type": "github"
  2366 + },
  2367 + {
  2368 + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  2369 + "type": "tidelift"
  2370 + }
  2371 + ],
  2372 + "time": "2021-10-20T20:35:02+00:00"
  2373 + },
  2374 + {
2278 "name": "symfony/polyfill-intl-idn", 2375 "name": "symfony/polyfill-intl-idn",
2279 "version": "v1.18.1", 2376 "version": "v1.18.1",
2280 "source": { 2377 "source": {
@@ -2286,13 +2383,7 @@ @@ -2286,13 +2383,7 @@
2286 "type": "zip", 2383 "type": "zip",
2287 "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/5dcab1bc7146cf8c1beaa4502a3d9be344334251", 2384 "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/5dcab1bc7146cf8c1beaa4502a3d9be344334251",
2288 "reference": "5dcab1bc7146cf8c1beaa4502a3d9be344334251", 2385 "reference": "5dcab1bc7146cf8c1beaa4502a3d9be344334251",
2289 - "shasum": "",  
2290 - "mirrors": [  
2291 - {  
2292 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2293 - "preferred": true  
2294 - }  
2295 - ] 2386 + "shasum": ""
2296 }, 2387 },
2297 "require": { 2388 "require": {
2298 "php": ">=5.3.3", 2389 "php": ">=5.3.3",
@@ -2377,13 +2468,7 @@ @@ -2377,13 +2468,7 @@
2377 "type": "zip", 2468 "type": "zip",
2378 "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e", 2469 "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e",
2379 "reference": "37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e", 2470 "reference": "37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e",
2380 - "shasum": "",  
2381 - "mirrors": [  
2382 - {  
2383 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2384 - "preferred": true  
2385 - }  
2386 - ] 2471 + "shasum": ""
2387 }, 2472 },
2388 "require": { 2473 "require": {
2389 "php": ">=5.3.3" 2474 "php": ">=5.3.3"
@@ -2464,13 +2549,7 @@ @@ -2464,13 +2549,7 @@
2464 "type": "zip", 2549 "type": "zip",
2465 "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", 2550 "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a",
2466 "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", 2551 "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a",
2467 - "shasum": "",  
2468 - "mirrors": [  
2469 - {  
2470 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2471 - "preferred": true  
2472 - }  
2473 - ] 2552 + "shasum": ""
2474 }, 2553 },
2475 "require": { 2554 "require": {
2476 "php": ">=5.3.3" 2555 "php": ">=5.3.3"
@@ -2547,13 +2626,7 @@ @@ -2547,13 +2626,7 @@
2547 "type": "zip", 2626 "type": "zip",
2548 "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0dd93f2c578bdc9c72697eaa5f1dd25644e618d3", 2627 "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0dd93f2c578bdc9c72697eaa5f1dd25644e618d3",
2549 "reference": "0dd93f2c578bdc9c72697eaa5f1dd25644e618d3", 2628 "reference": "0dd93f2c578bdc9c72697eaa5f1dd25644e618d3",
2550 - "shasum": "",  
2551 - "mirrors": [  
2552 - {  
2553 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2554 - "preferred": true  
2555 - }  
2556 - ] 2629 + "shasum": ""
2557 }, 2630 },
2558 "require": { 2631 "require": {
2559 "paragonie/random_compat": "~1.0|~2.0|~9.99", 2632 "paragonie/random_compat": "~1.0|~2.0|~9.99",
@@ -2630,13 +2703,7 @@ @@ -2630,13 +2703,7 @@
2630 "type": "zip", 2703 "type": "zip",
2631 "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/639447d008615574653fb3bc60d1986d7172eaae", 2704 "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/639447d008615574653fb3bc60d1986d7172eaae",
2632 "reference": "639447d008615574653fb3bc60d1986d7172eaae", 2705 "reference": "639447d008615574653fb3bc60d1986d7172eaae",
2633 - "shasum": "",  
2634 - "mirrors": [  
2635 - {  
2636 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2637 - "preferred": true  
2638 - }  
2639 - ] 2706 + "shasum": ""
2640 }, 2707 },
2641 "require": { 2708 "require": {
2642 "php": ">=5.3.3" 2709 "php": ">=5.3.3"
@@ -2709,13 +2776,7 @@ @@ -2709,13 +2776,7 @@
2709 "type": "zip", 2776 "type": "zip",
2710 "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981", 2777 "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981",
2711 "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981", 2778 "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981",
2712 - "shasum": "",  
2713 - "mirrors": [  
2714 - {  
2715 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2716 - "preferred": true  
2717 - }  
2718 - ] 2779 + "shasum": ""
2719 }, 2780 },
2720 "require": { 2781 "require": {
2721 "php": ">=7.0.8" 2782 "php": ">=7.0.8"
@@ -2784,6 +2845,66 @@ @@ -2784,6 +2845,66 @@
2784 "time": "2020-07-14T12:35:20+00:00" 2845 "time": "2020-07-14T12:35:20+00:00"
2785 }, 2846 },
2786 { 2847 {
  2848 + "name": "symfony/property-access",
  2849 + "version": "v2.8.52",
  2850 + "source": {
  2851 + "type": "git",
  2852 + "url": "https://github.com/symfony/property-access.git",
  2853 + "reference": "c8f10191183be9bb0d5a1b8364d3891f1bde07b6"
  2854 + },
  2855 + "dist": {
  2856 + "type": "zip",
  2857 + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/property-access/v2.8.52/symfony-property-access-v2.8.52.zip",
  2858 + "reference": "c8f10191183be9bb0d5a1b8364d3891f1bde07b6",
  2859 + "shasum": ""
  2860 + },
  2861 + "require": {
  2862 + "php": ">=5.3.9",
  2863 + "symfony/polyfill-ctype": "~1.8"
  2864 + },
  2865 + "type": "library",
  2866 + "extra": {
  2867 + "branch-alias": {
  2868 + "dev-master": "2.8-dev"
  2869 + }
  2870 + },
  2871 + "autoload": {
  2872 + "psr-4": {
  2873 + "Symfony\\Component\\PropertyAccess\\": ""
  2874 + },
  2875 + "exclude-from-classmap": [
  2876 + "/Tests/"
  2877 + ]
  2878 + },
  2879 + "license": [
  2880 + "MIT"
  2881 + ],
  2882 + "authors": [
  2883 + {
  2884 + "name": "Fabien Potencier",
  2885 + "email": "fabien@symfony.com"
  2886 + },
  2887 + {
  2888 + "name": "Symfony Community",
  2889 + "homepage": "https://symfony.com/contributors"
  2890 + }
  2891 + ],
  2892 + "description": "Symfony PropertyAccess Component",
  2893 + "homepage": "https://symfony.com",
  2894 + "keywords": [
  2895 + "access",
  2896 + "array",
  2897 + "extraction",
  2898 + "index",
  2899 + "injection",
  2900 + "object",
  2901 + "property",
  2902 + "property path",
  2903 + "reflection"
  2904 + ],
  2905 + "time": "2018-11-11T11:18:13+00:00"
  2906 + },
  2907 + {
2787 "name": "symfony/psr-http-message-bridge", 2908 "name": "symfony/psr-http-message-bridge",
2788 "version": "v1.3.0", 2909 "version": "v1.3.0",
2789 "source": { 2910 "source": {
@@ -2795,13 +2916,7 @@ @@ -2795,13 +2916,7 @@
2795 "type": "zip", 2916 "type": "zip",
2796 "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/9d3e80d54d9ae747ad573cad796e8e247df7b796", 2917 "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/9d3e80d54d9ae747ad573cad796e8e247df7b796",
2797 "reference": "9d3e80d54d9ae747ad573cad796e8e247df7b796", 2918 "reference": "9d3e80d54d9ae747ad573cad796e8e247df7b796",
2798 - "shasum": "",  
2799 - "mirrors": [  
2800 - {  
2801 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2802 - "preferred": true  
2803 - }  
2804 - ] 2919 + "shasum": ""
2805 }, 2920 },
2806 "require": { 2921 "require": {
2807 "php": "^7.1", 2922 "php": "^7.1",
@@ -2866,13 +2981,7 @@ @@ -2866,13 +2981,7 @@
2866 "type": "zip", 2981 "type": "zip",
2867 "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1", 2982 "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1",
2868 "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1", 2983 "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1",
2869 - "shasum": "",  
2870 - "mirrors": [  
2871 - {  
2872 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2873 - "preferred": true  
2874 - }  
2875 - ] 2984 + "shasum": ""
2876 }, 2985 },
2877 "require": { 2986 "require": {
2878 "php": ">=7.2.5", 2987 "php": ">=7.2.5",
@@ -2948,13 +3057,7 @@ @@ -2948,13 +3057,7 @@
2948 "type": "zip", 3057 "type": "zip",
2949 "url": "https://api.github.com/repos/symfony/var-exporter/zipball/bb6c505d1492bf55534184c0a38826bda529e5e2", 3058 "url": "https://api.github.com/repos/symfony/var-exporter/zipball/bb6c505d1492bf55534184c0a38826bda529e5e2",
2950 "reference": "bb6c505d1492bf55534184c0a38826bda529e5e2", 3059 "reference": "bb6c505d1492bf55534184c0a38826bda529e5e2",
2951 - "shasum": "",  
2952 - "mirrors": [  
2953 - {  
2954 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
2955 - "preferred": true  
2956 - }  
2957 - ] 3060 + "shasum": ""
2958 }, 3061 },
2959 "require": { 3062 "require": {
2960 "php": ">=7.1.3" 3063 "php": ">=7.1.3"
@@ -3028,13 +3131,7 @@ @@ -3028,13 +3131,7 @@
3028 "type": "zip", 3131 "type": "zip",
3029 "url": "https://api.github.com/repos/top-think/framework/zipball/c255c22b2f5fa30f320ecf6c1d29f7740eb3e8be", 3132 "url": "https://api.github.com/repos/top-think/framework/zipball/c255c22b2f5fa30f320ecf6c1d29f7740eb3e8be",
3030 "reference": "c255c22b2f5fa30f320ecf6c1d29f7740eb3e8be", 3133 "reference": "c255c22b2f5fa30f320ecf6c1d29f7740eb3e8be",
3031 - "shasum": "",  
3032 - "mirrors": [  
3033 - {  
3034 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
3035 - "preferred": true  
3036 - }  
3037 - ] 3134 + "shasum": ""
3038 }, 3135 },
3039 "require": { 3136 "require": {
3040 "php": ">=5.4.0", 3137 "php": ">=5.4.0",
@@ -3085,13 +3182,7 @@ @@ -3085,13 +3182,7 @@
3085 "type": "zip", 3182 "type": "zip",
3086 "url": "https://api.github.com/repos/top-think/think-captcha/zipball/1d64363c814c92f6086c4fa5e3223fe7e23db09d", 3183 "url": "https://api.github.com/repos/top-think/think-captcha/zipball/1d64363c814c92f6086c4fa5e3223fe7e23db09d",
3087 "reference": "1d64363c814c92f6086c4fa5e3223fe7e23db09d", 3184 "reference": "1d64363c814c92f6086c4fa5e3223fe7e23db09d",
3088 - "shasum": "",  
3089 - "mirrors": [  
3090 - {  
3091 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
3092 - "preferred": true  
3093 - }  
3094 - ] 3185 + "shasum": ""
3095 }, 3186 },
3096 "require": { 3187 "require": {
3097 "topthink/framework": "~5.0.0", 3188 "topthink/framework": "~5.0.0",
@@ -3131,13 +3222,7 @@ @@ -3131,13 +3222,7 @@
3131 "type": "zip", 3222 "type": "zip",
3132 "url": "https://api.github.com/repos/top-think/think-installer/zipball/1be326e68f63de4e95977ed50f46ae75f017556d", 3223 "url": "https://api.github.com/repos/top-think/think-installer/zipball/1be326e68f63de4e95977ed50f46ae75f017556d",
3133 "reference": "1be326e68f63de4e95977ed50f46ae75f017556d", 3224 "reference": "1be326e68f63de4e95977ed50f46ae75f017556d",
3134 - "shasum": "",  
3135 - "mirrors": [  
3136 - {  
3137 - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",  
3138 - "preferred": true  
3139 - }  
3140 - ] 3225 + "shasum": ""
3141 }, 3226 },
3142 "require": { 3227 "require": {
3143 "composer-plugin-api": "^1.0" 3228 "composer-plugin-api": "^1.0"
  1 +composer.lock
  2 +vendor
  3 +nbproject
  4 +.idea
  5 +.buildpath
  6 +.project
  7 +.DS_Store
  8 +.*.sw*
  9 +.*.un~
  1 +language: php
  2 +php:
  3 + - 5.4
  4 + - 5.5
  5 + - 5.6
  6 + - 7.0
  7 + - 7.1
  8 + - hhvm
  9 +
  10 +install:
  11 + - travis_retry composer install --no-interaction
  12 + - composer info -i
  13 +
  14 +script: vendor/bin/phpunit --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests
  1 +Copyright (c) 2013, Ben 'DASPRiD' Scholzen
  2 +All rights reserved.
  3 +
  4 +Redistribution and use in source and binary forms, with or without
  5 +modification, are permitted provided that the following conditions are met:
  6 +
  7 +1. Redistributions of source code must retain the above copyright notice, this
  8 + list of conditions and the following disclaimer.
  9 +2. Redistributions in binary form must reproduce the above copyright notice,
  10 + this list of conditions and the following disclaimer in the documentation
  11 + and/or other materials provided with the distribution.
  12 +
  13 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  14 +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15 +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16 +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  17 +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18 +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19 +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20 +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22 +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode;
  11 +
  12 +use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
  13 +
  14 +/**
  15 + * Module for generating QR codes.
  16 + */
  17 +class Module implements AutoloaderProviderInterface
  18 +{
  19 + /**
  20 + * Get autoloader config.
  21 + *
  22 + * @return array
  23 + */
  24 + public function getAutoloaderConfig()
  25 + {
  26 + return array(
  27 + 'Zend\Loader\ClassMapAutoloader' => array(
  28 + __DIR__ . '/autoload_classmap.php',
  29 + ),
  30 + 'Zend\Loader\StandardAutoloader' => array(
  31 + 'namespaces' => array(
  32 + __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
  33 + ),
  34 + ),
  35 + );
  36 + }
  37 +}
  1 +QR Code generator
  2 +=================
  3 +
  4 +Master: [![Build Status](https://api.travis-ci.org/Bacon/BaconQrCode.png?branch=master)](http://travis-ci.org/Bacon/BaconQrCode)
  5 +
  6 +Introduction
  7 +------------
  8 +BaconQrCode is a port of QR code portion of the ZXing library. It currently
  9 +only features the encoder part, but could later receive the decoder part as
  10 +well.
  11 +
  12 +As the Reed Solomon codec implementation of the ZXing library performs quite
  13 +slow in PHP, it was exchanged with the implementation by Phil Karn.
  14 +
  15 +
  16 +Example usage
  17 +-------------
  18 +```php
  19 +$renderer = new \BaconQrCode\Renderer\Image\Png();
  20 +$renderer->setHeight(256);
  21 +$renderer->setWidth(256);
  22 +$writer = new \BaconQrCode\Writer($renderer);
  23 +$writer->writeFile('Hello World!', 'qrcode.png');
  24 +```
  1 +<?php
  2 +// Generated by ZF2's ./bin/classmap_generator.php
  3 +return array(
  4 + 'BaconQrCode\Common\AbstractEnum' => __DIR__ . '/src/BaconQrCode/Common/AbstractEnum.php',
  5 + 'BaconQrCode\Common\BitArray' => __DIR__ . '/src/BaconQrCode/Common/BitArray.php',
  6 + 'BaconQrCode\Common\BitMatrix' => __DIR__ . '/src/BaconQrCode/Common/BitMatrix.php',
  7 + 'BaconQrCode\Common\BitUtils' => __DIR__ . '/src/BaconQrCode/Common/BitUtils.php',
  8 + 'BaconQrCode\Common\CharacterSetEci' => __DIR__ . '/src/BaconQrCode/Common/CharacterSetEci.php',
  9 + 'BaconQrCode\Common\EcBlock' => __DIR__ . '/src/BaconQrCode/Common/EcBlock.php',
  10 + 'BaconQrCode\Common\EcBlocks' => __DIR__ . '/src/BaconQrCode/Common/EcBlocks.php',
  11 + 'BaconQrCode\Common\ErrorCorrectionLevel' => __DIR__ . '/src/BaconQrCode/Common/ErrorCorrectionLevel.php',
  12 + 'BaconQrCode\Common\FormatInformation' => __DIR__ . '/src/BaconQrCode/Common/FormatInformation.php',
  13 + 'BaconQrCode\Common\Mode' => __DIR__ . '/src/BaconQrCode/Common/Mode.php',
  14 + 'BaconQrCode\Common\ReedSolomonCodec' => __DIR__ . '/src/BaconQrCode/Common/ReedSolomonCodec.php',
  15 + 'BaconQrCode\Common\Version' => __DIR__ . '/src/BaconQrCode/Common/Version.php',
  16 + 'BaconQrCode\Encoder\BlockPair' => __DIR__ . '/src/BaconQrCode/Encoder/BlockPair.php',
  17 + 'BaconQrCode\Encoder\ByteMatrix' => __DIR__ . '/src/BaconQrCode/Encoder/ByteMatrix.php',
  18 + 'BaconQrCode\Encoder\Encoder' => __DIR__ . '/src/BaconQrCode/Encoder/Encoder.php',
  19 + 'BaconQrCode\Encoder\MaskUtil' => __DIR__ . '/src/BaconQrCode/Encoder/MaskUtil.php',
  20 + 'BaconQrCode\Encoder\MatrixUtil' => __DIR__ . '/src/BaconQrCode/Encoder/MatrixUtil.php',
  21 + 'BaconQrCode\Encoder\QrCode' => __DIR__ . '/src/BaconQrCode/Encoder/QrCode.php',
  22 + 'BaconQrCode\Exception\ExceptionInterface' => __DIR__ . '/src/BaconQrCode/Exception/ExceptionInterface.php',
  23 + 'BaconQrCode\Exception\InvalidArgumentException' => __DIR__ . '/src/BaconQrCode/Exception/InvalidArgumentException.php',
  24 + 'BaconQrCode\Exception\OutOfBoundsException' => __DIR__ . '/src/BaconQrCode/Exception/OutOfBoundsException.php',
  25 + 'BaconQrCode\Exception\RuntimeException' => __DIR__ . '/src/BaconQrCode/Exception/RuntimeException.php',
  26 + 'BaconQrCode\Exception\UnexpectedValueException' => __DIR__ . '/src/BaconQrCode/Exception/UnexpectedValueException.php',
  27 + 'BaconQrCode\Exception\WriterException' => __DIR__ . '/src/BaconQrCode/Exception/WriterException.php',
  28 + 'BaconQrCode\Renderer\Color\Cmyk' => __DIR__ . '/src/BaconQrCode/Renderer/Color/Cmyk.php',
  29 + 'BaconQrCode\Renderer\Color\ColorInterface' => __DIR__ . '/src/BaconQrCode/Renderer/Color/ColorInterface.php',
  30 + 'BaconQrCode\Renderer\Color\Gray' => __DIR__ . '/src/BaconQrCode/Renderer/Color/Gray.php',
  31 + 'BaconQrCode\Renderer\Color\Rgb' => __DIR__ . '/src/BaconQrCode/Renderer/Color/Rgb.php',
  32 + 'BaconQrCode\Renderer\Image\AbstractRenderer' => __DIR__ . '/src/BaconQrCode/Renderer/Image/AbstractRenderer.php',
  33 + 'BaconQrCode\Renderer\Image\Decorator\DecoratorInterface' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Decorator/DecoratorInterface.php',
  34 + 'BaconQrCode\Renderer\Image\Decorator\FinderPattern' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Decorator/FinderPattern.php',
  35 + 'BaconQrCode\Renderer\Image\Eps' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Eps.php',
  36 + 'BaconQrCode\Renderer\Image\Png' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Png.php',
  37 + 'BaconQrCode\Renderer\Image\RendererInterface' => __DIR__ . '/src/BaconQrCode/Renderer/Image/RendererInterface.php',
  38 + 'BaconQrCode\Renderer\Image\Svg' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Svg.php',
  39 + 'BaconQrCode\Renderer\RendererInterface' => __DIR__ . '/src/BaconQrCode/Renderer/RendererInterface.php',
  40 + 'BaconQrCode\Renderer\Text\Plain' => __DIR__ . '/src/BaconQrCode/Renderer/Text/Plain.php',
  41 + 'BaconQrCode\Renderer\Text\Html' => __DIR__ . '/src/BaconQrCode/Renderer/Text/Html.php',
  42 + 'BaconQrCode\Writer' => __DIR__ . '/src/BaconQrCode/Writer.php',
  43 +);
  1 +<?php
  2 +return function ($class) {
  3 + static $map;
  4 + if (!$map) {
  5 + $map = include __DIR__ . '/autoload_classmap.php';
  6 + }
  7 +
  8 + if (!isset($map[$class])) {
  9 + return false;
  10 + }
  11 + return include $map[$class];
  12 +};
  1 +<?php
  2 +spl_autoload_register(include __DIR__ . '/autoload_function.php');
  1 +{
  2 + "name": "bacon/bacon-qr-code",
  3 + "description": "BaconQrCode is a QR code generator for PHP.",
  4 + "license" : "BSD-2-Clause",
  5 + "homepage": "https://github.com/Bacon/BaconQrCode",
  6 + "require": {
  7 + "php": "^5.4|^7.0",
  8 + "ext-iconv": "*"
  9 + },
  10 + "suggest": {
  11 + "ext-gd": "to generate QR code images"
  12 + },
  13 + "authors": [
  14 + {
  15 + "name": "Ben Scholzen 'DASPRiD'",
  16 + "email": "mail@dasprids.de",
  17 + "homepage": "http://www.dasprids.de",
  18 + "role": "Developer"
  19 + }
  20 + ],
  21 + "autoload": {
  22 + "psr-0": {
  23 + "BaconQrCode": "src/"
  24 + }
  25 + },
  26 + "require-dev": {
  27 + "phpunit/phpunit": "^4.8"
  28 + }
  29 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +use BaconQrCode\Exception;
  13 +use ReflectionClass;
  14 +
  15 +/**
  16 + * A general enum implementation until we got SplEnum.
  17 + */
  18 +abstract class AbstractEnum
  19 +{
  20 + /**
  21 + * Default value.
  22 + */
  23 + const __default = null;
  24 +
  25 + /**
  26 + * Current value.
  27 + *
  28 + * @var mixed
  29 + */
  30 + protected $value;
  31 +
  32 + /**
  33 + * Cache of constants.
  34 + *
  35 + * @var array
  36 + */
  37 + protected $constants;
  38 +
  39 + /**
  40 + * Whether to handle values strict or not.
  41 + *
  42 + * @var boolean
  43 + */
  44 + protected $strict;
  45 +
  46 + /**
  47 + * Creates a new enum.
  48 + *
  49 + * @param mixed $initialValue
  50 + * @param boolean $strict
  51 + */
  52 + public function __construct($initialValue = null, $strict = false)
  53 + {
  54 + $this->strict = $strict;
  55 + $this->change($initialValue);
  56 + }
  57 +
  58 + /**
  59 + * Changes the value of the enum.
  60 + *
  61 + * @param mixed $value
  62 + * @return void
  63 + */
  64 + public function change($value)
  65 + {
  66 + if (!in_array($value, $this->getConstList(), $this->strict)) {
  67 + throw new Exception\UnexpectedValueException('Value not a const in enum ' . get_class($this));
  68 + }
  69 +
  70 + $this->value = $value;
  71 + }
  72 +
  73 + /**
  74 + * Gets current value.
  75 + *
  76 + * @return mixed
  77 + */
  78 + public function get()
  79 + {
  80 + return $this->value;
  81 + }
  82 +
  83 + /**
  84 + * Gets all constants (possible values) as an array.
  85 + *
  86 + * @param boolean $includeDefault
  87 + * @return array
  88 + */
  89 + public function getConstList($includeDefault = true)
  90 + {
  91 + if ($this->constants === null) {
  92 + $reflection = new ReflectionClass($this);
  93 + $this->constants = $reflection->getConstants();
  94 + }
  95 +
  96 + if ($includeDefault) {
  97 + return $this->constants;
  98 + }
  99 +
  100 + $constants = $this->constants;
  101 + unset($constants['__default']);
  102 +
  103 + return $constants;
  104 + }
  105 +
  106 + /**
  107 + * Gets the name of the enum.
  108 + *
  109 + * @return string
  110 + */
  111 + public function __toString()
  112 + {
  113 + return array_search($this->value, $this->getConstList());
  114 + }
  115 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +use SplFixedArray;
  13 +
  14 +/**
  15 + * A simple, fast array of bits.
  16 + */
  17 +class BitArray
  18 +{
  19 + /**
  20 + * Bits represented as an array of integers.
  21 + *
  22 + * @var SplFixedArray
  23 + */
  24 + protected $bits;
  25 +
  26 + /**
  27 + * Size of the bit array in bits.
  28 + *
  29 + * @var integer
  30 + */
  31 + protected $size;
  32 +
  33 + /**
  34 + * Creates a new bit array with a given size.
  35 + *
  36 + * @param integer $size
  37 + */
  38 + public function __construct($size = 0)
  39 + {
  40 + $this->size = $size;
  41 + $this->bits = new SplFixedArray(($this->size + 31) >> 3);
  42 + }
  43 +
  44 + /**
  45 + * Gets the size in bits.
  46 + *
  47 + * @return integer
  48 + */
  49 + public function getSize()
  50 + {
  51 + return $this->size;
  52 + }
  53 +
  54 + /**
  55 + * Gets the size in bytes.
  56 + *
  57 + * @return integer
  58 + */
  59 + public function getSizeInBytes()
  60 + {
  61 + return ($this->size + 7) >> 3;
  62 + }
  63 +
  64 + /**
  65 + * Ensures that the array has a minimum capacity.
  66 + *
  67 + * @param integer $size
  68 + * @return void
  69 + */
  70 + public function ensureCapacity($size)
  71 + {
  72 + if ($size > count($this->bits) << 5) {
  73 + $this->bits->setSize(($size + 31) >> 5);
  74 + }
  75 + }
  76 +
  77 + /**
  78 + * Gets a specific bit.
  79 + *
  80 + * @param integer $i
  81 + * @return boolean
  82 + */
  83 + public function get($i)
  84 + {
  85 + return ($this->bits[$i >> 5] & (1 << ($i & 0x1f))) !== 0;
  86 + }
  87 +
  88 + /**
  89 + * Sets a specific bit.
  90 + *
  91 + * @param integer $i
  92 + * @return void
  93 + */
  94 + public function set($i)
  95 + {
  96 + $this->bits[$i >> 5] = $this->bits[$i >> 5] | 1 << ($i & 0x1f);
  97 + }
  98 +
  99 + /**
  100 + * Flips a specific bit.
  101 + *
  102 + * @param integer $i
  103 + * @return void
  104 + */
  105 + public function flip($i)
  106 + {
  107 + $this->bits[$i >> 5] ^= 1 << ($i & 0x1f);
  108 + }
  109 +
  110 + /**
  111 + * Gets the next set bit position from a given position.
  112 + *
  113 + * @param integer $from
  114 + * @return integer
  115 + */
  116 + public function getNextSet($from)
  117 + {
  118 + if ($from >= $this->size) {
  119 + return $this->size;
  120 + }
  121 +
  122 + $bitsOffset = $from >> 5;
  123 + $currentBits = $this->bits[$bitsOffset];
  124 + $bitsLength = count($this->bits);
  125 +
  126 + $currentBits &= ~((1 << ($from & 0x1f)) - 1);
  127 +
  128 + while ($currentBits === 0) {
  129 + if (++$bitsOffset === $bitsLength) {
  130 + return $this->size;
  131 + }
  132 +
  133 + $currentBits = $this->bits[$bitsOffset];
  134 + }
  135 +
  136 + $result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits);
  137 +
  138 + return $result > $this->size ? $this->size : $result;
  139 + }
  140 +
  141 + /**
  142 + * Gets the next unset bit position from a given position.
  143 + *
  144 + * @param integer $from
  145 + * @return integer
  146 + */
  147 + public function getNextUnset($from)
  148 + {
  149 + if ($from >= $this->size) {
  150 + return $this->size;
  151 + }
  152 +
  153 + $bitsOffset = $from >> 5;
  154 + $currentBits = ~$this->bits[$bitsOffset];
  155 + $bitsLength = count($this->bits);
  156 +
  157 + $currentBits &= ~((1 << ($from & 0x1f)) - 1);
  158 +
  159 + while ($currentBits === 0) {
  160 + if (++$bitsOffset === $bitsLength) {
  161 + return $this->size;
  162 + }
  163 +
  164 + $currentBits = ~$this->bits[$bitsOffset];
  165 + }
  166 +
  167 + $result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits);
  168 +
  169 + return $result > $this->size ? $this->size : $result;
  170 + }
  171 +
  172 + /**
  173 + * Sets a bulk of bits.
  174 + *
  175 + * @param integer $i
  176 + * @param integer $newBits
  177 + * @return void
  178 + */
  179 + public function setBulk($i, $newBits)
  180 + {
  181 + $this->bits[$i >> 5] = $newBits;
  182 + }
  183 +
  184 + /**
  185 + * Sets a range of bits.
  186 + *
  187 + * @param integer $start
  188 + * @param integer $end
  189 + * @return void
  190 + * @throws Exception\InvalidArgumentException
  191 + */
  192 + public function setRange($start, $end)
  193 + {
  194 + if ($end < $start) {
  195 + throw new Exception\InvalidArgumentException('End must be greater or equal to start');
  196 + }
  197 +
  198 + if ($end === $start) {
  199 + return;
  200 + }
  201 +
  202 + $end--;
  203 +
  204 + $firstInt = $start >> 5;
  205 + $lastInt = $end >> 5;
  206 +
  207 + for ($i = $firstInt; $i <= $lastInt; $i++) {
  208 + $firstBit = $i > $firstInt ? 0 : $start & 0x1f;
  209 + $lastBit = $i < $lastInt ? 31 : $end & 0x1f;
  210 +
  211 + if ($firstBit === 0 && $lastBit === 31) {
  212 + $mask = 0x7fffffff;
  213 + } else {
  214 + $mask = 0;
  215 +
  216 + for ($j = $firstBit; $j < $lastBit; $j++) {
  217 + $mask |= 1 << $j;
  218 + }
  219 + }
  220 +
  221 + $this->bits[$i] = $this->bits[$i] | $mask;
  222 + }
  223 + }
  224 +
  225 + /**
  226 + * Clears the bit array, unsetting every bit.
  227 + *
  228 + * @return void
  229 + */
  230 + public function clear()
  231 + {
  232 + $bitsLength = count($this->bits);
  233 +
  234 + for ($i = 0; $i < $bitsLength; $i++) {
  235 + $this->bits[$i] = 0;
  236 + }
  237 + }
  238 +
  239 + /**
  240 + * Checks if a range of bits is set or not set.
  241 + *
  242 + * @param integer $start
  243 + * @param integer $end
  244 + * @param integer $value
  245 + * @return boolean
  246 + * @throws Exception\InvalidArgumentException
  247 + */
  248 + public function isRange($start, $end, $value)
  249 + {
  250 + if ($end < $start) {
  251 + throw new Exception\InvalidArgumentException('End must be greater or equal to start');
  252 + }
  253 +
  254 + if ($end === $start) {
  255 + return;
  256 + }
  257 +
  258 + $end--;
  259 +
  260 + $firstInt = $start >> 5;
  261 + $lastInt = $end >> 5;
  262 +
  263 + for ($i = $firstInt; $i <= $lastInt; $i++) {
  264 + $firstBit = $i > $firstInt ? 0 : $start & 0x1f;
  265 + $lastBit = $i < $lastInt ? 31 : $end & 0x1f;
  266 +
  267 + if ($firstBit === 0 && $lastBit === 31) {
  268 + $mask = 0x7fffffff;
  269 + } else {
  270 + $mask = 0;
  271 +
  272 + for ($j = $firstBit; $j <= $lastBit; $j++) {
  273 + $mask |= 1 << $j;
  274 + }
  275 + }
  276 +
  277 + if (($this->bits[$i] & $mask) !== ($value ? $mask : 0)) {
  278 + return false;
  279 + }
  280 + }
  281 +
  282 + return true;
  283 + }
  284 +
  285 + /**
  286 + * Appends a bit to the array.
  287 + *
  288 + * @param boolean $bit
  289 + * @return void
  290 + */
  291 + public function appendBit($bit)
  292 + {
  293 + $this->ensureCapacity($this->size + 1);
  294 +
  295 + if ($bit) {
  296 + $this->bits[$this->size >> 5] = $this->bits[$this->size >> 5] | (1 << ($this->size & 0x1f));
  297 + }
  298 +
  299 + $this->size++;
  300 + }
  301 +
  302 + /**
  303 + * Appends a number of bits (up to 32) to the array.
  304 + *
  305 + * @param integer $value
  306 + * @param integer $numBits
  307 + * @return void
  308 + * @throws Exception\InvalidArgumentException
  309 + */
  310 + public function appendBits($value, $numBits)
  311 + {
  312 + if ($numBits < 0 || $numBits > 32) {
  313 + throw new Exception\InvalidArgumentException('Num bits must be between 0 and 32');
  314 + }
  315 +
  316 + $this->ensureCapacity($this->size + $numBits);
  317 +
  318 + for ($numBitsLeft = $numBits; $numBitsLeft > 0; $numBitsLeft--) {
  319 + $this->appendBit((($value >> ($numBitsLeft - 1)) & 0x01) === 1);
  320 + }
  321 + }
  322 +
  323 + /**
  324 + * Appends another bit array to this array.
  325 + *
  326 + * @param BitArray $other
  327 + * @return void
  328 + */
  329 + public function appendBitArray(self $other)
  330 + {
  331 + $otherSize = $other->getSize();
  332 + $this->ensureCapacity($this->size + $other->getSize());
  333 +
  334 + for ($i = 0; $i < $otherSize; $i++) {
  335 + $this->appendBit($other->get($i));
  336 + }
  337 + }
  338 +
  339 + /**
  340 + * Makes an exclusive-or comparision on the current bit array.
  341 + *
  342 + * @param BitArray $other
  343 + * @return void
  344 + * @throws Exception\InvalidArgumentException
  345 + */
  346 + public function xorBits(self $other)
  347 + {
  348 + $bitsLength = count($this->bits);
  349 + $otherBits = $other->getBitArray();
  350 +
  351 + if ($bitsLength !== count($otherBits)) {
  352 + throw new Exception\InvalidArgumentException('Sizes don\'t match');
  353 + }
  354 +
  355 + for ($i = 0; $i < $bitsLength; $i++) {
  356 + $this->bits[$i] = $this->bits[$i] ^ $otherBits[$i];
  357 + }
  358 + }
  359 +
  360 + /**
  361 + * Converts the bit array to a byte array.
  362 + *
  363 + * @param integer $bitOffset
  364 + * @param integer $numBytes
  365 + * @return SplFixedArray
  366 + */
  367 + public function toBytes($bitOffset, $numBytes)
  368 + {
  369 + $bytes = new SplFixedArray($numBytes);
  370 +
  371 + for ($i = 0; $i < $numBytes; $i++) {
  372 + $byte = 0;
  373 +
  374 + for ($j = 0; $j < 8; $j++) {
  375 + if ($this->get($bitOffset)) {
  376 + $byte |= 1 << (7 - $j);
  377 + }
  378 +
  379 + $bitOffset++;
  380 + }
  381 +
  382 + $bytes[$i] = $byte;
  383 + }
  384 +
  385 + return $bytes;
  386 + }
  387 +
  388 + /**
  389 + * Gets the internal bit array.
  390 + *
  391 + * @return SplFixedArray
  392 + */
  393 + public function getBitArray()
  394 + {
  395 + return $this->bits;
  396 + }
  397 +
  398 + /**
  399 + * Reverses the array.
  400 + *
  401 + * @return void
  402 + */
  403 + public function reverse()
  404 + {
  405 + $newBits = new SplFixedArray(count($this->bits));
  406 +
  407 + for ($i = 0; $i < $this->size; $i++) {
  408 + if ($this->get($this->size - $i - 1)) {
  409 + $newBits[$i >> 5] = $newBits[$i >> 5] | (1 << ($i & 0x1f));
  410 + }
  411 + }
  412 +
  413 + $this->bits = newBits;
  414 + }
  415 +
  416 + /**
  417 + * Returns a string representation of the bit array.
  418 + *
  419 + * @return string
  420 + */
  421 + public function __toString()
  422 + {
  423 + $result = '';
  424 +
  425 + for ($i = 0; $i < $this->size; $i++) {
  426 + if (($i & 0x07) === 0) {
  427 + $result .= ' ';
  428 + }
  429 +
  430 + $result .= $this->get($i) ? 'X' : '.';
  431 + }
  432 +
  433 + return $result;
  434 + }
  435 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +use SplFixedArray;
  13 +
  14 +/**
  15 + * Bit matrix.
  16 + *
  17 + * Represents a 2D matrix of bits. In function arguments below, and throughout
  18 + * the common module, x is the column position, and y is the row position. The
  19 + * ordering is always x, y. The origin is at the top-left.
  20 + */
  21 +class BitMatrix
  22 +{
  23 + /**
  24 + * Width of the bit matrix.
  25 + *
  26 + * @var integer
  27 + */
  28 + protected $width;
  29 +
  30 + /**
  31 + * Height of the bit matrix.
  32 + *
  33 + * @var integer
  34 + */
  35 + protected $height;
  36 +
  37 + /**
  38 + * Size in bits of each individual row.
  39 + *
  40 + * @var integer
  41 + */
  42 + protected $rowSize;
  43 +
  44 + /**
  45 + * Bits representation.
  46 + *
  47 + * @var SplFixedArray
  48 + */
  49 + protected $bits;
  50 +
  51 + /**
  52 + * Creates a new bit matrix with given dimensions.
  53 + *
  54 + * @param integer $width
  55 + * @param integer|null $height
  56 + * @throws Exception\InvalidArgumentException
  57 + */
  58 + public function __construct($width, $height = null)
  59 + {
  60 + if ($height === null) {
  61 + $height = $width;
  62 + }
  63 +
  64 + if ($width < 1 || $height < 1) {
  65 + throw new Exception\InvalidArgumentException('Both dimensions must be greater than zero');
  66 + }
  67 +
  68 + $this->width = $width;
  69 + $this->height = $height;
  70 + $this->rowSize = ($width + 31) >> 5;
  71 + $this->bits = new SplFixedArray($this->rowSize * $height);
  72 + }
  73 +
  74 + /**
  75 + * Gets the requested bit, where true means black.
  76 + *
  77 + * @param integer $x
  78 + * @param integer $y
  79 + * @return boolean
  80 + */
  81 + public function get($x, $y)
  82 + {
  83 + $offset = $y * $this->rowSize + ($x >> 5);
  84 + return (BitUtils::unsignedRightShift($this->bits[$offset], ($x & 0x1f)) & 1) !== 0;
  85 + }
  86 +
  87 + /**
  88 + * Sets the given bit to true.
  89 + *
  90 + * @param integer $x
  91 + * @param integer $y
  92 + * @return void
  93 + */
  94 + public function set($x, $y)
  95 + {
  96 + $offset = $y * $this->rowSize + ($x >> 5);
  97 + $this->bits[$offset] = $this->bits[$offset] | (1 << ($x & 0x1f));
  98 + }
  99 +
  100 + /**
  101 + * Flips the given bit.
  102 + *
  103 + * @param integer $x
  104 + * @param integer $y
  105 + * @return void
  106 + */
  107 + public function flip($x, $y)
  108 + {
  109 + $offset = $y * $this->rowSize + ($x >> 5);
  110 + $this->bits[$offset] = $this->bits[$offset] ^ (1 << ($x & 0x1f));
  111 + }
  112 +
  113 + /**
  114 + * Clears all bits (set to false).
  115 + *
  116 + * @return void
  117 + */
  118 + public function clear()
  119 + {
  120 + $max = count($this->bits);
  121 +
  122 + for ($i = 0; $i < $max; $i++) {
  123 + $this->bits[$i] = 0;
  124 + }
  125 + }
  126 +
  127 + /**
  128 + * Sets a square region of the bit matrix to true.
  129 + *
  130 + * @param integer $left
  131 + * @param integer $top
  132 + * @param integer $width
  133 + * @param integer $height
  134 + * @return void
  135 + */
  136 + public function setRegion($left, $top, $width, $height)
  137 + {
  138 + if ($top < 0 || $left < 0) {
  139 + throw new Exception\InvalidArgumentException('Left and top must be non-negative');
  140 + }
  141 +
  142 + if ($height < 1 || $width < 1) {
  143 + throw new Exception\InvalidArgumentException('Width and height must be at least 1');
  144 + }
  145 +
  146 + $right = $left + $width;
  147 + $bottom = $top + $height;
  148 +
  149 + if ($bottom > $this->height || $right > $this->width) {
  150 + throw new Exception\InvalidArgumentException('The region must fit inside the matrix');
  151 + }
  152 +
  153 + for ($y = $top; $y < $bottom; $y++) {
  154 + $offset = $y * $this->rowSize;
  155 +
  156 + for ($x = $left; $x < $right; $x++) {
  157 + $index = $offset + ($x >> 5);
  158 + $this->bits[$index] = $this->bits[$index] | (1 << ($x & 0x1f));
  159 + }
  160 + }
  161 + }
  162 +
  163 + /**
  164 + * A fast method to retrieve one row of data from the matrix as a BitArray.
  165 + *
  166 + * @param integer $y
  167 + * @param BitArray $row
  168 + * @return BitArray
  169 + */
  170 + public function getRow($y, BitArray $row = null)
  171 + {
  172 + if ($row === null || $row->getSize() < $this->width) {
  173 + $row = new BitArray($this->width);
  174 + }
  175 +
  176 + $offset = $y * $this->rowSize;
  177 +
  178 + for ($x = 0; $x < $this->rowSize; $x++) {
  179 + $row->setBulk($x << 5, $this->bits[$offset + $x]);
  180 + }
  181 +
  182 + return $row;
  183 + }
  184 +
  185 + /**
  186 + * Sets a row of data from a BitArray.
  187 + *
  188 + * @param integer $y
  189 + * @param BitArray $row
  190 + * @return void
  191 + */
  192 + public function setRow($y, BitArray $row)
  193 + {
  194 + $bits = $row->getBitArray();
  195 +
  196 + for ($i = 0; $i < $this->rowSize; $i++) {
  197 + $this->bits[$y * $this->rowSize + $i] = $bits[$i];
  198 + }
  199 + }
  200 +
  201 + /**
  202 + * This is useful in detecting the enclosing rectangle of a 'pure' barcode.
  203 + *
  204 + * @return SplFixedArray
  205 + */
  206 + public function getEnclosingRectangle()
  207 + {
  208 + $left = $this->width;
  209 + $top = $this->height;
  210 + $right = -1;
  211 + $bottom = -1;
  212 +
  213 + for ($y = 0; $y < $this->height; $y++) {
  214 + for ($x32 = 0; $x32 < $this->rowSize; $x32++) {
  215 + $bits = $this->bits[$y * $this->rowSize + $x32];
  216 +
  217 + if ($bits !== 0) {
  218 + if ($y < $top) {
  219 + $top = $y;
  220 + }
  221 +
  222 + if ($y > $bottom) {
  223 + $bottom = $y;
  224 + }
  225 +
  226 + if ($x32 * 32 < $left) {
  227 + $bit = 0;
  228 +
  229 + while (($bits << (31 - $bit)) === 0) {
  230 + $bit++;
  231 + }
  232 +
  233 + if (($x32 * 32 + $bit) < $left) {
  234 + $left = $x32 * 32 + $bit;
  235 + }
  236 + }
  237 + }
  238 +
  239 + if ($x32 * 32 + 31 > $right) {
  240 + $bit = 31;
  241 +
  242 + while (BitUtils::unsignedRightShift($bits, $bit) === 0) {
  243 + $bit--;
  244 + }
  245 +
  246 + if (($x32 * 32 + $bit) > $right) {
  247 + $right = $x32 * 32 + $bit;
  248 + }
  249 + }
  250 + }
  251 + }
  252 +
  253 + $width = $right - $left;
  254 + $height = $bottom - $top;
  255 +
  256 + if ($width < 0 || $height < 0) {
  257 + return null;
  258 + }
  259 +
  260 + return SplFixedArray::fromArray(array($left, $top, $width, $height), false);
  261 + }
  262 +
  263 + /**
  264 + * Gets the most top left set bit.
  265 + *
  266 + * This is useful in detecting a corner of a 'pure' barcode.
  267 + *
  268 + * @return SplFixedArray
  269 + */
  270 + public function getTopLeftOnBit()
  271 + {
  272 + $bitsOffset = 0;
  273 +
  274 + while ($bitsOffset < count($this->bits) && $this->bits[$bitsOffset] === 0) {
  275 + $bitsOffset++;
  276 + }
  277 +
  278 + if ($bitsOffset === count($this->bits)) {
  279 + return null;
  280 + }
  281 +
  282 + $x = intval($bitsOffset / $this->rowSize);
  283 + $y = ($bitsOffset % $this->rowSize) << 5;
  284 +
  285 + $bits = $this->bits[$bitsOffset];
  286 + $bit = 0;
  287 +
  288 + while (($bits << (31 - $bit)) === 0) {
  289 + $bit++;
  290 + }
  291 +
  292 + $x += $bit;
  293 +
  294 + return SplFixedArray::fromArray(array($x, $y), false);
  295 + }
  296 +
  297 + /**
  298 + * Gets the most bottom right set bit.
  299 + *
  300 + * This is useful in detecting a corner of a 'pure' barcode.
  301 + *
  302 + * @return SplFixedArray
  303 + */
  304 + public function getBottomRightOnBit()
  305 + {
  306 + $bitsOffset = count($this->bits) - 1;
  307 +
  308 + while ($bitsOffset >= 0 && $this->bits[$bitsOffset] === 0) {
  309 + $bitsOffset--;
  310 + }
  311 +
  312 + if ($bitsOffset < 0) {
  313 + return null;
  314 + }
  315 +
  316 + $x = intval($bitsOffset / $this->rowSize);
  317 + $y = ($bitsOffset % $this->rowSize) << 5;
  318 +
  319 + $bits = $this->bits[$bitsOffset];
  320 + $bit = 0;
  321 +
  322 + while (BitUtils::unsignedRightShift($bits, $bit) === 0) {
  323 + $bit--;
  324 + }
  325 +
  326 + $x += $bit;
  327 +
  328 + return SplFixedArray::fromArray(array($x, $y), false);
  329 + }
  330 +
  331 + /**
  332 + * Gets the width of the matrix,
  333 + *
  334 + * @return integer
  335 + */
  336 + public function getWidth()
  337 + {
  338 + return $this->width;
  339 + }
  340 +
  341 + /**
  342 + * Gets the height of the matrix.
  343 + *
  344 + * @return integer
  345 + */
  346 + public function getHeight()
  347 + {
  348 + return $this->height;
  349 + }
  350 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +/**
  13 + * General bit utilities.
  14 + *
  15 + * All utility methods are based on 32-bit integers and also work on 64-bit
  16 + * systems.
  17 + */
  18 +class BitUtils
  19 +{
  20 + /**
  21 + * Performs an unsigned right shift.
  22 + *
  23 + * This is the same as the unsigned right shift operator ">>>" in other
  24 + * languages.
  25 + *
  26 + * @param integer $a
  27 + * @param integer $b
  28 + * @return integer
  29 + */
  30 + public static function unsignedRightShift($a, $b)
  31 + {
  32 + return (
  33 + $a >= 0
  34 + ? $a >> $b
  35 + : (($a & 0x7fffffff) >> $b) | (0x40000000 >> ($b - 1))
  36 + );
  37 + }
  38 +
  39 + /**
  40 + * Gets the number of trailing zeros.
  41 + *
  42 + * @param integer $i
  43 + * @return integer
  44 + */
  45 + public static function numberOfTrailingZeros($i)
  46 + {
  47 + $lastPos = strrpos(str_pad(decbin($i), 32, '0', STR_PAD_LEFT), '1');
  48 +
  49 + return $lastPos === false ? 32 : 31 - $lastPos;
  50 + }
  51 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +/**
  13 + * Encapsulates a Character Set ECI, according to "Extended Channel
  14 + * Interpretations" 5.3.1.1 of ISO 18004.
  15 + */
  16 +class CharacterSetEci extends AbstractEnum
  17 +{
  18 + /**#@+
  19 + * Character set constants.
  20 + */
  21 + const CP437 = 0;
  22 + const ISO8859_1 = 1;
  23 + const ISO8859_2 = 4;
  24 + const ISO8859_3 = 5;
  25 + const ISO8859_4 = 6;
  26 + const ISO8859_5 = 7;
  27 + const ISO8859_6 = 8;
  28 + const ISO8859_7 = 9;
  29 + const ISO8859_8 = 10;
  30 + const ISO8859_9 = 11;
  31 + const ISO8859_10 = 12;
  32 + const ISO8859_11 = 13;
  33 + const ISO8859_12 = 14;
  34 + const ISO8859_13 = 15;
  35 + const ISO8859_14 = 16;
  36 + const ISO8859_15 = 17;
  37 + const ISO8859_16 = 18;
  38 + const SJIS = 20;
  39 + const CP1250 = 21;
  40 + const CP1251 = 22;
  41 + const CP1252 = 23;
  42 + const CP1256 = 24;
  43 + const UNICODE_BIG_UNMARKED = 25;
  44 + const UTF8 = 26;
  45 + const ASCII = 27;
  46 + const BIG5 = 28;
  47 + const GB18030 = 29;
  48 + const EUC_KR = 30;
  49 + /**#@-*/
  50 +
  51 + /**
  52 + * Map between character names and their ECI values.
  53 + *
  54 + * @var array
  55 + */
  56 + protected static $nameToEci = array(
  57 + 'ISO-8859-1' => self::ISO8859_1,
  58 + 'ISO-8859-2' => self::ISO8859_2,
  59 + 'ISO-8859-3' => self::ISO8859_3,
  60 + 'ISO-8859-4' => self::ISO8859_4,
  61 + 'ISO-8859-5' => self::ISO8859_5,
  62 + 'ISO-8859-6' => self::ISO8859_6,
  63 + 'ISO-8859-7' => self::ISO8859_7,
  64 + 'ISO-8859-8' => self::ISO8859_8,
  65 + 'ISO-8859-9' => self::ISO8859_9,
  66 + 'ISO-8859-10' => self::ISO8859_10,
  67 + 'ISO-8859-11' => self::ISO8859_11,
  68 + 'ISO-8859-12' => self::ISO8859_12,
  69 + 'ISO-8859-13' => self::ISO8859_13,
  70 + 'ISO-8859-14' => self::ISO8859_14,
  71 + 'ISO-8859-15' => self::ISO8859_15,
  72 + 'ISO-8859-16' => self::ISO8859_16,
  73 + 'SHIFT-JIS' => self::SJIS,
  74 + 'WINDOWS-1250' => self::CP1250,
  75 + 'WINDOWS-1251' => self::CP1251,
  76 + 'WINDOWS-1252' => self::CP1252,
  77 + 'WINDOWS-1256' => self::CP1256,
  78 + 'UTF-16BE' => self::UNICODE_BIG_UNMARKED,
  79 + 'UTF-8' => self::UTF8,
  80 + 'ASCII' => self::ASCII,
  81 + 'GBK' => self::GB18030,
  82 + 'EUC-KR' => self::EUC_KR,
  83 + );
  84 +
  85 + /**
  86 + * Additional possible values for character sets.
  87 + *
  88 + * @var array
  89 + */
  90 + protected $additionalValues = array(
  91 + self::CP437 => 2,
  92 + self::ASCII => 170,
  93 + );
  94 +
  95 + /**
  96 + * Gets character set ECI by value.
  97 + *
  98 + * @param string $name
  99 + * @return CharacterSetEci|null
  100 + */
  101 + public static function getCharacterSetECIByValue($value)
  102 + {
  103 + if ($value < 0 || $value >= 900) {
  104 + throw new Exception\InvalidArgumentException('Value must be between 0 and 900');
  105 + }
  106 +
  107 + if (false !== ($key = array_search($value, self::$additionalValues))) {
  108 + $value = $key;
  109 + }
  110 +
  111 + try {
  112 + return new self($value);
  113 + } catch (Exception\UnexpectedValueException $e) {
  114 + return null;
  115 + }
  116 + }
  117 +
  118 + /**
  119 + * Gets character set ECI by name.
  120 + *
  121 + * @param string $name
  122 + * @return CharacterSetEci|null
  123 + */
  124 + public static function getCharacterSetECIByName($name)
  125 + {
  126 + $name = strtoupper($name);
  127 +
  128 + if (isset(self::$nameToEci[$name])) {
  129 + return new self(self::$nameToEci[$name]);
  130 + }
  131 +
  132 + return null;
  133 + }
  134 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +/**
  13 + * Encapsualtes the parameters for one error-correction block in one symbol
  14 + * version. This includes the number of data codewords, and the number of times
  15 + * a block with these parameters is used consecutively in the QR code version's
  16 + * format.
  17 + */
  18 +class EcBlock
  19 +{
  20 + /**
  21 + * How many times the block is used.
  22 + *
  23 + * @var integer
  24 + */
  25 + protected $count;
  26 +
  27 + /**
  28 + * Number of data codewords.
  29 + *
  30 + * @var integer
  31 + */
  32 + protected $dataCodewords;
  33 +
  34 + /**
  35 + * Creates a new EC block.
  36 + *
  37 + * @param integer $count
  38 + * @param integer $dataCodewords
  39 + */
  40 + public function __construct($count, $dataCodewords)
  41 + {
  42 + $this->count = $count;
  43 + $this->dataCodewords = $dataCodewords;
  44 + }
  45 +
  46 + /**
  47 + * Returns how many times the block is used.
  48 + *
  49 + * @return integer
  50 + */
  51 + public function getCount()
  52 + {
  53 + return $this->count;
  54 + }
  55 +
  56 + /**
  57 + * Returns the number of data codewords.
  58 + *
  59 + * @return integer
  60 + */
  61 + public function getDataCodewords()
  62 + {
  63 + return $this->dataCodewords;
  64 + }
  65 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +use SplFixedArray;
  13 +
  14 +/**
  15 + * Encapsulates a set of error-correction blocks in one symbol version. Most
  16 + * versions will use blocks of differing sizes within one version, so, this
  17 + * encapsulates the parameters for each set of blocks. It also holds the number
  18 + * of error-correction codewords per block since it will be the same across all
  19 + * blocks within one version.
  20 + */
  21 +class EcBlocks
  22 +{
  23 + /**
  24 + * Number of EC codewords per block.
  25 + *
  26 + * @var integer
  27 + */
  28 + protected $ecCodewordsPerBlock;
  29 +
  30 + /**
  31 + * List of EC blocks.
  32 + *
  33 + * @var SplFixedArray
  34 + */
  35 + protected $ecBlocks;
  36 +
  37 + /**
  38 + * Creates a new EC blocks instance.
  39 + *
  40 + * @param integer $ecCodewordsPerBlock
  41 + * @param EcBlock $ecb1
  42 + * @param EcBlock|null $ecb2
  43 + */
  44 + public function __construct($ecCodewordsPerBlock, EcBlock $ecb1, EcBlock $ecb2 = null)
  45 + {
  46 + $this->ecCodewordsPerBlock = $ecCodewordsPerBlock;
  47 +
  48 + $this->ecBlocks = new SplFixedArray($ecb2 === null ? 1 : 2);
  49 + $this->ecBlocks[0] = $ecb1;
  50 +
  51 + if ($ecb2 !== null) {
  52 + $this->ecBlocks[1] = $ecb2;
  53 + }
  54 + }
  55 +
  56 + /**
  57 + * Gets the number of EC codewords per block.
  58 + *
  59 + * @return integer
  60 + */
  61 + public function getEcCodewordsPerBlock()
  62 + {
  63 + return $this->ecCodewordsPerBlock;
  64 + }
  65 +
  66 + /**
  67 + * Gets the total number of EC block appearances.
  68 + *
  69 + * @return integer
  70 + */
  71 + public function getNumBlocks()
  72 + {
  73 + $total = 0;
  74 +
  75 + foreach ($this->ecBlocks as $ecBlock) {
  76 + $total += $ecBlock->getCount();
  77 + }
  78 +
  79 + return $total;
  80 + }
  81 +
  82 + /**
  83 + * Gets the total count of EC codewords.
  84 + *
  85 + * @return integer
  86 + */
  87 + public function getTotalEcCodewords()
  88 + {
  89 + return $this->ecCodewordsPerBlock * $this->getNumBlocks();
  90 + }
  91 +
  92 + /**
  93 + * Gets the EC blocks included in this collection.
  94 + *
  95 + * @return SplFixedArray
  96 + */
  97 + public function getEcBlocks()
  98 + {
  99 + return $this->ecBlocks;
  100 + }
  101 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +/**
  13 + * Enum representing the four error correction levels.
  14 + */
  15 +class ErrorCorrectionLevel extends AbstractEnum
  16 +{
  17 + /**
  18 + * Level L, ~7% correction.
  19 + */
  20 + const L = 0x1;
  21 +
  22 + /**
  23 + * Level M, ~15% correction.
  24 + */
  25 + const M = 0x0;
  26 +
  27 + /**
  28 + * Level Q, ~25% correction.
  29 + */
  30 + const Q = 0x3;
  31 +
  32 + /**
  33 + * Level H, ~30% correction.
  34 + */
  35 + const H = 0x2;
  36 +
  37 + /**
  38 + * Gets the ordinal of this enumeration constant.
  39 + *
  40 + * @return integer
  41 + */
  42 + public function getOrdinal()
  43 + {
  44 + switch ($this->value) {
  45 + case self::L:
  46 + return 0;
  47 + break;
  48 +
  49 + case self::M:
  50 + return 1;
  51 + break;
  52 +
  53 + case self::Q:
  54 + return 2;
  55 + break;
  56 +
  57 + case self::H:
  58 + return 3;
  59 + break;
  60 + }
  61 + }
  62 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +/**
  13 + * Encapsulates a QR Code's format information, including the data mask used and
  14 + * error correction level.
  15 + */
  16 +class FormatInformation
  17 +{
  18 + /**
  19 + * Mask for format information.
  20 + */
  21 + const FORMAT_INFO_MASK_QR = 0x5412;
  22 +
  23 + /**
  24 + * Lookup table for decoding format information.
  25 + *
  26 + * See ISO 18004:2006, Annex C, Table C.1
  27 + *
  28 + * @var array
  29 + */
  30 + protected static $formatInfoDecodeLookup = array(
  31 + array(0x5412, 0x00),
  32 + array(0x5125, 0x01),
  33 + array(0x5e7c, 0x02),
  34 + array(0x5b4b, 0x03),
  35 + array(0x45f9, 0x04),
  36 + array(0x40ce, 0x05),
  37 + array(0x4f97, 0x06),
  38 + array(0x4aa0, 0x07),
  39 + array(0x77c4, 0x08),
  40 + array(0x72f3, 0x09),
  41 + array(0x7daa, 0x0a),
  42 + array(0x789d, 0x0b),
  43 + array(0x662f, 0x0c),
  44 + array(0x6318, 0x0d),
  45 + array(0x6c41, 0x0e),
  46 + array(0x6976, 0x0f),
  47 + array(0x1689, 0x10),
  48 + array(0x13be, 0x11),
  49 + array(0x1ce7, 0x12),
  50 + array(0x19d0, 0x13),
  51 + array(0x0762, 0x14),
  52 + array(0x0255, 0x15),
  53 + array(0x0d0c, 0x16),
  54 + array(0x083b, 0x17),
  55 + array(0x355f, 0x18),
  56 + array(0x3068, 0x19),
  57 + array(0x3f31, 0x1a),
  58 + array(0x3a06, 0x1b),
  59 + array(0x24b4, 0x1c),
  60 + array(0x2183, 0x1d),
  61 + array(0x2eda, 0x1e),
  62 + array(0x2bed, 0x1f),
  63 + );
  64 +
  65 + /**
  66 + * Offset i holds the number of 1 bits in the binary representation of i.
  67 + *
  68 + * @var array
  69 + */
  70 + protected static $bitsSetInHalfByte = array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
  71 +
  72 + /**
  73 + * Error correction level.
  74 + *
  75 + * @var ErrorCorrectionLevel
  76 + */
  77 + protected $ecLevel;
  78 +
  79 + /**
  80 + * Data mask.
  81 + *
  82 + * @var integer
  83 + */
  84 + protected $dataMask;
  85 +
  86 + /**
  87 + * Creates a new format information instance.
  88 + *
  89 + * @param integer $formatInfo
  90 + */
  91 + protected function __construct($formatInfo)
  92 + {
  93 + $this->ecLevel = new ErrorCorrectionLevel(($formatInfo >> 3) & 0x3);
  94 + $this->dataMask = $formatInfo & 0x7;
  95 + }
  96 +
  97 + /**
  98 + * Checks how many bits are different between two integers.
  99 + *
  100 + * @param integer $a
  101 + * @param integer $b
  102 + * @return integer
  103 + */
  104 + public static function numBitsDiffering($a, $b)
  105 + {
  106 + $a ^= $b;
  107 +
  108 + return (
  109 + self::$bitsSetInHalfByte[$a & 0xf]
  110 + + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 4) & 0xf)]
  111 + + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 8) & 0xf)]
  112 + + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 12) & 0xf)]
  113 + + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 16) & 0xf)]
  114 + + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 20) & 0xf)]
  115 + + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 24) & 0xf)]
  116 + + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 28) & 0xf)]
  117 + );
  118 + }
  119 +
  120 + /**
  121 + * Decodes format information.
  122 + *
  123 + * @param integer $maskedFormatInfo1
  124 + * @param integer $maskedFormatInfo2
  125 + * @return FormatInformation|null
  126 + */
  127 + public static function decodeFormatInformation($maskedFormatInfo1, $maskedFormatInfo2)
  128 + {
  129 + $formatInfo = self::doDecodeFormatInformation($maskedFormatInfo1, $maskedFormatInfo2);
  130 +
  131 + if ($formatInfo !== null) {
  132 + return $formatInfo;
  133 + }
  134 +
  135 + // Should return null, but, some QR codes apparently do not mask this
  136 + // info. Try again by actually masking the pattern first.
  137 + return self::doDecodeFormatInformation(
  138 + $maskedFormatInfo1 ^ self::FORMAT_INFO_MASK_QR,
  139 + $maskedFormatInfo2 ^ self::FORMAT_INFO_MASK_QR
  140 + );
  141 + }
  142 +
  143 + /**
  144 + * Internal method for decoding format information.
  145 + *
  146 + * @param integer $maskedFormatInfo1
  147 + * @param integer $maskedFormatInfo2
  148 + * @return FormatInformation|null
  149 + */
  150 + protected static function doDecodeFormatInformation($maskedFormatInfo1, $maskedFormatInfo2)
  151 + {
  152 + $bestDifference = PHP_INT_MAX;
  153 + $bestFormatInfo = 0;
  154 +
  155 + foreach (self::$formatInfoDecodeLookup as $decodeInfo) {
  156 + $targetInfo = $decodeInfo[0];
  157 +
  158 + if ($targetInfo === $maskedFormatInfo1 || $targetInfo === $maskedFormatInfo2) {
  159 + // Found an exact match
  160 + return new self($decodeInfo[1]);
  161 + }
  162 +
  163 + $bitsDifference = self::numBitsDiffering($maskedFormatInfo1, $targetInfo);
  164 +
  165 + if ($bitsDifference < $bestDifference) {
  166 + $bestFormatInfo = $decodeInfo[1];
  167 + $bestDifference = $bitsDifference;
  168 + }
  169 +
  170 + if ($maskedFormatInfo1 !== $maskedFormatInfo2) {
  171 + // Also try the other option
  172 + $bitsDifference = self::numBitsDiffering($maskedFormatInfo2, $targetInfo);
  173 +
  174 + if ($bitsDifference < $bestDifference) {
  175 + $bestFormatInfo = $decodeInfo[1];
  176 + $bestDifference = $bitsDifference;
  177 + }
  178 + }
  179 + }
  180 +
  181 + // Hamming distance of the 32 masked codes is 7, by construction, so
  182 + // <= 3 bits differing means we found a match.
  183 + if ($bestDifference <= 3) {
  184 + return new self($bestFormatInfo);
  185 + }
  186 +
  187 + return null;
  188 + }
  189 +
  190 + /**
  191 + * Gets the error correction level.
  192 + *
  193 + * @return ErrorCorrectionLevel
  194 + */
  195 + public function getErrorCorrectionLevel()
  196 + {
  197 + return $this->ecLevel;
  198 + }
  199 +
  200 + /**
  201 + * Gets the data mask.
  202 + *
  203 + * @return integer
  204 + */
  205 + public function getDataMask()
  206 + {
  207 + return $this->dataMask;
  208 + }
  209 +
  210 + /**
  211 + * Hashes the code of the EC level.
  212 + *
  213 + * @return integer
  214 + */
  215 + public function hashCode()
  216 + {
  217 + return ($this->ecLevel->get() << 3) | $this->dataMask;
  218 + }
  219 +
  220 + /**
  221 + * Verifies if this instance equals another one.
  222 + *
  223 + * @param mixed $other
  224 + * @return boolean
  225 + */
  226 + public function equals($other) {
  227 + if (!$other instanceof self) {
  228 + return false;
  229 + }
  230 +
  231 + return (
  232 + $this->ecLevel->get() === $other->getErrorCorrectionLevel()->get()
  233 + && $this->dataMask === $other->getDataMask()
  234 + );
  235 + }
  236 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +/**
  13 + * Enum representing various modes in which data can be encoded to bits.
  14 + */
  15 +class Mode extends AbstractEnum
  16 +{
  17 + /**#@+
  18 + * Mode constants.
  19 + */
  20 + const TERMINATOR = 0x0;
  21 + const NUMERIC = 0x1;
  22 + const ALPHANUMERIC = 0x2;
  23 + const STRUCTURED_APPEND = 0x3;
  24 + const BYTE = 0x4;
  25 + const ECI = 0x7;
  26 + const KANJI = 0x8;
  27 + const FNC1_FIRST_POSITION = 0x5;
  28 + const FNC1_SECOND_POSITION = 0x9;
  29 + const HANZI = 0xd;
  30 + /**#@-*/
  31 +
  32 + /**
  33 + * Character count bits for each version.
  34 + *
  35 + * @var array
  36 + */
  37 + protected static $characterCountBitsForVersions = array(
  38 + self::TERMINATOR => array(0, 0, 0),
  39 + self::NUMERIC => array(10, 12, 14),
  40 + self::ALPHANUMERIC => array(9, 11, 13),
  41 + self::STRUCTURED_APPEND => array(0, 0, 0),
  42 + self::BYTE => array(8, 16, 16),
  43 + self::ECI => array(0, 0, 0),
  44 + self::KANJI => array(8, 10, 12),
  45 + self::FNC1_FIRST_POSITION => array(0, 0, 0),
  46 + self::FNC1_SECOND_POSITION => array(0, 0, 0),
  47 + self::HANZI => array(8, 10, 12),
  48 + );
  49 +
  50 + /**
  51 + * Gets the number of bits used in a specific QR code version.
  52 + *
  53 + * @param Version $version
  54 + * @return integer
  55 + */
  56 + public function getCharacterCountBits(Version $version)
  57 + {
  58 + $number = $version->getVersionNumber();
  59 +
  60 + if ($number <= 9) {
  61 + $offset = 0;
  62 + } elseif ($number <= 26) {
  63 + $offset = 1;
  64 + } else {
  65 + $offset = 2;
  66 + }
  67 +
  68 + return self::$characterCountBitsForVersions[$this->value][$offset];
  69 + }
  70 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +use BaconQrCode\Exception;
  13 +use SplFixedArray;
  14 +
  15 +/**
  16 + * Reed-Solomon codec for 8-bit characters.
  17 + *
  18 + * Based on libfec by Phil Karn, KA9Q.
  19 + */
  20 +class ReedSolomonCodec
  21 +{
  22 + /**
  23 + * Symbol size in bits.
  24 + *
  25 + * @var integer
  26 + */
  27 + protected $symbolSize;
  28 +
  29 + /**
  30 + * Block size in symbols.
  31 + *
  32 + * @var integer
  33 + */
  34 + protected $blockSize;
  35 +
  36 + /**
  37 + * First root of RS code generator polynomial, index form.
  38 + *
  39 + * @var integer
  40 + */
  41 + protected $firstRoot;
  42 +
  43 + /**
  44 + * Primitive element to generate polynomial roots, index form.
  45 + *
  46 + * @var integer
  47 + */
  48 + protected $primitive;
  49 +
  50 + /**
  51 + * Prim-th root of 1, index form.
  52 + *
  53 + * @var integer
  54 + */
  55 + protected $iPrimitive;
  56 +
  57 + /**
  58 + * RS code generator polynomial degree (number of roots).
  59 + *
  60 + * @var integer
  61 + */
  62 + protected $numRoots;
  63 +
  64 + /**
  65 + * Padding bytes at front of shortened block.
  66 + *
  67 + * @var integer
  68 + */
  69 + protected $padding;
  70 +
  71 + /**
  72 + * Log lookup table.
  73 + *
  74 + * @var SplFixedArray
  75 + */
  76 + protected $alphaTo;
  77 +
  78 + /**
  79 + * Anti-Log lookup table.
  80 + *
  81 + * @var SplFixedArray
  82 + */
  83 + protected $indexOf;
  84 +
  85 + /**
  86 + * Generator polynomial.
  87 + *
  88 + * @var SplFixedArray
  89 + */
  90 + protected $generatorPoly;
  91 +
  92 + /**
  93 + * Creates a new reed solomon instance.
  94 + *
  95 + * @param integer $symbolSize
  96 + * @param integer $gfPoly
  97 + * @param integer $firstRoot
  98 + * @param integer $primitive
  99 + * @param integer $numRoots
  100 + * @param integer $padding
  101 + * @throws Exception\InvalidArgumentException
  102 + * @throws Exception\RuntimeException
  103 + */
  104 + public function __construct($symbolSize, $gfPoly, $firstRoot, $primitive, $numRoots, $padding)
  105 + {
  106 + if ($symbolSize < 0 || $symbolSize > 8) {
  107 + throw new Exception\InvalidArgumentException('Symbol size must be between 0 and 8');
  108 + }
  109 +
  110 + if ($firstRoot < 0 || $firstRoot >= (1 << $symbolSize)) {
  111 + throw new Exception\InvalidArgumentException('First root must be between 0 and ' . (1 << $symbolSize));
  112 + }
  113 +
  114 + if ($numRoots < 0 || $numRoots >= (1 << $symbolSize)) {
  115 + throw new Exception\InvalidArgumentException('Num roots must be between 0 and ' . (1 << $symbolSize));
  116 + }
  117 +
  118 + if ($padding < 0 || $padding >= ((1 << $symbolSize) - 1 - $numRoots)) {
  119 + throw new Exception\InvalidArgumentException('Padding must be between 0 and ' . ((1 << $symbolSize) - 1 - $numRoots));
  120 + }
  121 +
  122 + $this->symbolSize = $symbolSize;
  123 + $this->blockSize = (1 << $symbolSize) - 1;
  124 + $this->padding = $padding;
  125 + $this->alphaTo = SplFixedArray::fromArray(array_fill(0, $this->blockSize + 1, 0), false);
  126 + $this->indexOf = SplFixedArray::fromArray(array_fill(0, $this->blockSize + 1, 0), false);
  127 +
  128 + // Generate galous field lookup table
  129 + $this->indexOf[0] = $this->blockSize;
  130 + $this->alphaTo[$this->blockSize] = 0;
  131 +
  132 + $sr = 1;
  133 +
  134 + for ($i = 0; $i < $this->blockSize; $i++) {
  135 + $this->indexOf[$sr] = $i;
  136 + $this->alphaTo[$i] = $sr;
  137 +
  138 + $sr <<= 1;
  139 +
  140 + if ($sr & (1 << $symbolSize)) {
  141 + $sr ^= $gfPoly;
  142 + }
  143 +
  144 + $sr &= $this->blockSize;
  145 + }
  146 +
  147 + if ($sr !== 1) {
  148 + throw new Exception\RuntimeException('Field generator polynomial is not primitive');
  149 + }
  150 +
  151 + // Form RS code generator polynomial from its roots
  152 + $this->generatorPoly = SplFixedArray::fromArray(array_fill(0, $numRoots + 1, 0), false);
  153 + $this->firstRoot = $firstRoot;
  154 + $this->primitive = $primitive;
  155 + $this->numRoots = $numRoots;
  156 +
  157 + // Find prim-th root of 1, used in decoding
  158 + for ($iPrimitive = 1; ($iPrimitive % $primitive) !== 0; $iPrimitive += $this->blockSize);
  159 + $this->iPrimitive = intval($iPrimitive / $primitive);
  160 +
  161 + $this->generatorPoly[0] = 1;
  162 +
  163 + for ($i = 0, $root = $firstRoot * $primitive; $i < $numRoots; $i++, $root += $primitive) {
  164 + $this->generatorPoly[$i + 1] = 1;
  165 +
  166 + for ($j = $i; $j > 0; $j--) {
  167 + if ($this->generatorPoly[$j] !== 0) {
  168 + $this->generatorPoly[$j] = $this->generatorPoly[$j - 1] ^ $this->alphaTo[$this->modNn($this->indexOf[$this->generatorPoly[$j]] + $root)];
  169 + } else {
  170 + $this->generatorPoly[$j] = $this->generatorPoly[$j - 1];
  171 + }
  172 + }
  173 +
  174 + $this->generatorPoly[$j] = $this->alphaTo[$this->modNn($this->indexOf[$this->generatorPoly[0]] + $root)];
  175 + }
  176 +
  177 + // Convert generator poly to index form for quicker encoding
  178 + for ($i = 0; $i <= $numRoots; $i++) {
  179 + $this->generatorPoly[$i] = $this->indexOf[$this->generatorPoly[$i]];
  180 + }
  181 + }
  182 +
  183 + /**
  184 + * Encodes data and writes result back into parity array.
  185 + *
  186 + * @param SplFixedArray $data
  187 + * @param SplFixedArray $parity
  188 + * @return void
  189 + */
  190 + public function encode(SplFixedArray $data, SplFixedArray $parity)
  191 + {
  192 + for ($i = 0; $i < $this->numRoots; $i++) {
  193 + $parity[$i] = 0;
  194 + }
  195 +
  196 + $iterations = $this->blockSize - $this->numRoots - $this->padding;
  197 +
  198 + for ($i = 0; $i < $iterations; $i++) {
  199 + $feedback = $this->indexOf[$data[$i] ^ $parity[0]];
  200 +
  201 + if ($feedback !== $this->blockSize) {
  202 + // Feedback term is non-zero
  203 + $feedback = $this->modNn($this->blockSize - $this->generatorPoly[$this->numRoots] + $feedback);
  204 +
  205 + for ($j = 1; $j < $this->numRoots; $j++) {
  206 + $parity[$j] = $parity[$j] ^ $this->alphaTo[$this->modNn($feedback + $this->generatorPoly[$this->numRoots - $j])];
  207 + }
  208 + }
  209 +
  210 + for ($j = 0; $j < $this->numRoots - 1; $j++) {
  211 + $parity[$j] = $parity[$j + 1];
  212 + }
  213 +
  214 + if ($feedback !== $this->blockSize) {
  215 + $parity[$this->numRoots - 1] = $this->alphaTo[$this->modNn($feedback + $this->generatorPoly[0])];
  216 + } else {
  217 + $parity[$this->numRoots - 1] = 0;
  218 + }
  219 + }
  220 + }
  221 +
  222 + /**
  223 + * Decodes received data.
  224 + *
  225 + * @param SplFixedArray $data
  226 + * @param SplFixedArray|null $erasures
  227 + * @return null|integer
  228 + */
  229 + public function decode(SplFixedArray $data, SplFixedArray $erasures = null)
  230 + {
  231 + // This speeds up the initialization a bit.
  232 + $numRootsPlusOne = SplFixedArray::fromArray(array_fill(0, $this->numRoots + 1, 0), false);
  233 + $numRoots = SplFixedArray::fromArray(array_fill(0, $this->numRoots, 0), false);
  234 +
  235 + $lambda = clone $numRootsPlusOne;
  236 + $b = clone $numRootsPlusOne;
  237 + $t = clone $numRootsPlusOne;
  238 + $omega = clone $numRootsPlusOne;
  239 + $root = clone $numRoots;
  240 + $loc = clone $numRoots;
  241 +
  242 + $numErasures = ($erasures !== null ? count($erasures) : 0);
  243 +
  244 + // Form the Syndromes; i.e., evaluate data(x) at roots of g(x)
  245 + $syndromes = SplFixedArray::fromArray(array_fill(0, $this->numRoots, $data[0]), false);
  246 +
  247 + for ($i = 1; $i < $this->blockSize - $this->padding; $i++) {
  248 + for ($j = 0; $j < $this->numRoots; $j++) {
  249 + if ($syndromes[$j] === 0) {
  250 + $syndromes[$j] = $data[$i];
  251 + } else {
  252 + $syndromes[$j] = $data[$i] ^ $this->alphaTo[
  253 + $this->modNn($this->indexOf[$syndromes[$j]] + ($this->firstRoot + $j) * $this->primitive)
  254 + ];
  255 + }
  256 + }
  257 + }
  258 +
  259 + // Convert syndromes to index form, checking for nonzero conditions
  260 + $syndromeError = 0;
  261 +
  262 + for ($i = 0; $i < $this->numRoots; $i++) {
  263 + $syndromeError |= $syndromes[$i];
  264 + $syndromes[$i] = $this->indexOf[$syndromes[$i]];
  265 + }
  266 +
  267 + if (!$syndromeError) {
  268 + // If syndrome is zero, data[] is a codeword and there are no errors
  269 + // to correct, so return data[] unmodified.
  270 + return 0;
  271 + }
  272 +
  273 + $lambda[0] = 1;
  274 +
  275 + if ($numErasures > 0) {
  276 + // Init lambda to be the erasure locator polynomial
  277 + $lambda[1] = $this->alphaTo[$this->modNn($this->primitive * ($this->blockSize - 1 - $erasures[0]))];
  278 +
  279 + for ($i = 1; $i < $numErasures; $i++) {
  280 + $u = $this->modNn($this->primitive * ($this->blockSize - 1 - $erasures[$i]));
  281 +
  282 + for ($j = $i + 1; $j > 0; $j--) {
  283 + $tmp = $this->indexOf[$lambda[$j - 1]];
  284 +
  285 + if ($tmp !== $this->blockSize) {
  286 + $lambda[$j] = $lambda[$j] ^ $this->alphaTo[$this->modNn($u + $tmp)];
  287 + }
  288 + }
  289 + }
  290 + }
  291 +
  292 + for ($i = 0; $i <= $this->numRoots; $i++) {
  293 + $b[$i] = $this->indexOf[$lambda[$i]];
  294 + }
  295 +
  296 + // Begin Berlekamp-Massey algorithm to determine error+erasure locator
  297 + // polynomial
  298 + $r = $numErasures;
  299 + $el = $numErasures;
  300 +
  301 + while (++$r <= $this->numRoots) {
  302 + // Compute discrepancy at the r-th step in poly form
  303 + $discrepancyR = 0;
  304 +
  305 + for ($i = 0; $i < $r; $i++) {
  306 + if ($lambda[$i] !== 0 && $syndromes[$r - $i - 1] !== $this->blockSize) {
  307 + $discrepancyR ^= $this->alphaTo[$this->modNn($this->indexOf[$lambda[$i]] + $syndromes[$r - $i - 1])];
  308 + }
  309 + }
  310 +
  311 + $discrepancyR = $this->indexOf[$discrepancyR];
  312 +
  313 + if ($discrepancyR === $this->blockSize) {
  314 + $tmp = $b->toArray();
  315 + array_unshift($tmp, $this->blockSize);
  316 + array_pop($tmp);
  317 + $b = SplFixedArray::fromArray($tmp, false);
  318 + } else {
  319 + $t[0] = $lambda[0];
  320 +
  321 + for ($i = 0; $i < $this->numRoots; $i++) {
  322 + if ($b[$i] !== $this->blockSize) {
  323 + $t[$i + 1] = $lambda[$i + 1] ^ $this->alphaTo[$this->modNn($discrepancyR + $b[$i])];
  324 + } else {
  325 + $t[$i + 1] = $lambda[$i + 1];
  326 + }
  327 + }
  328 +
  329 + if (2 * $el <= $r + $numErasures - 1) {
  330 + $el = $r + $numErasures - $el;
  331 +
  332 + for ($i = 0; $i <= $this->numRoots; $i++) {
  333 + $b[$i] = (
  334 + $lambda[$i] === 0
  335 + ? $this->blockSize
  336 + : $this->modNn($this->indexOf[$lambda[$i]] - $discrepancyR + $this->blockSize)
  337 + );
  338 + }
  339 + } else {
  340 + $tmp = $b->toArray();
  341 + array_unshift($tmp, $this->blockSize);
  342 + array_pop($tmp);
  343 + $b = SplFixedArray::fromArray($tmp, false);
  344 + }
  345 +
  346 + $lambda = clone $t;
  347 + }
  348 + }
  349 +
  350 + // Convert lambda to index form and compute deg(lambda(x))
  351 + $degLambda = 0;
  352 +
  353 + for ($i = 0; $i <= $this->numRoots; $i++) {
  354 + $lambda[$i] = $this->indexOf[$lambda[$i]];
  355 +
  356 + if ($lambda[$i] !== $this->blockSize) {
  357 + $degLambda = $i;
  358 + }
  359 + }
  360 +
  361 + // Find roots of the error+erasure locator polynomial by Chien search.
  362 + $reg = clone $lambda;
  363 + $reg[0] = 0;
  364 + $count = 0;
  365 +
  366 + for ($i = 1, $k = $this->iPrimitive - 1; $i <= $this->blockSize; $i++, $k = $this->modNn($k + $this->iPrimitive)) {
  367 + $q = 1;
  368 +
  369 + for ($j = $degLambda; $j > 0; $j--) {
  370 + if ($reg[$j] !== $this->blockSize) {
  371 + $reg[$j] = $this->modNn($reg[$j] + $j);
  372 + $q ^= $this->alphaTo[$reg[$j]];
  373 + }
  374 + }
  375 +
  376 + if ($q !== 0) {
  377 + // Not a root
  378 + continue;
  379 + }
  380 +
  381 + // Store root (index-form) and error location number
  382 + $root[$count] = $i;
  383 + $loc[$count] = $k;
  384 +
  385 + if (++$count === $degLambda) {
  386 + break;
  387 + }
  388 + }
  389 +
  390 + if ($degLambda !== $count) {
  391 + // deg(lambda) unequal to number of roots: uncorreactable error
  392 + // detected
  393 + return null;
  394 + }
  395 +
  396 + // Compute err+eras evaluate poly omega(x) = s(x)*lambda(x) (modulo
  397 + // x**numRoots). In index form. Also find deg(omega).
  398 + $degOmega = $degLambda - 1;
  399 +
  400 + for ($i = 0; $i <= $degOmega; $i++) {
  401 + $tmp = 0;
  402 +
  403 + for ($j = $i; $j >= 0; $j--) {
  404 + if ($syndromes[$i - $j] !== $this->blockSize && $lambda[$j] !== $this->blockSize) {
  405 + $tmp ^= $this->alphaTo[$this->modNn($syndromes[$i - $j] + $lambda[$j])];
  406 + }
  407 + }
  408 +
  409 + $omega[$i] = $this->indexOf[$tmp];
  410 + }
  411 +
  412 + // Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
  413 + // inv(X(l))**(firstRoot-1) and den = lambda_pr(inv(X(l))) all in poly
  414 + // form.
  415 + for ($j = $count - 1; $j >= 0; $j--) {
  416 + $num1 = 0;
  417 +
  418 + for ($i = $degOmega; $i >= 0; $i--) {
  419 + if ($omega[$i] !== $this->blockSize) {
  420 + $num1 ^= $this->alphaTo[$this->modNn($omega[$i] + $i * $root[$j])];
  421 + }
  422 + }
  423 +
  424 + $num2 = $this->alphaTo[$this->modNn($root[$j] * ($this->firstRoot - 1) + $this->blockSize)];
  425 + $den = 0;
  426 +
  427 + // lambda[i+1] for i even is the formal derivativelambda_pr of
  428 + // lambda[i]
  429 + for ($i = min($degLambda, $this->numRoots - 1) & ~1; $i >= 0; $i -= 2) {
  430 + if ($lambda[$i + 1] !== $this->blockSize) {
  431 + $den ^= $this->alphaTo[$this->modNn($lambda[$i + 1] + $i * $root[$j])];
  432 + }
  433 + }
  434 +
  435 + // Apply error to data
  436 + if ($num1 !== 0 && $loc[$j] >= $this->padding) {
  437 + $data[$loc[$j] - $this->padding] = $data[$loc[$j] - $this->padding] ^ (
  438 + $this->alphaTo[
  439 + $this->modNn(
  440 + $this->indexOf[$num1] + $this->indexOf[$num2] + $this->blockSize - $this->indexOf[$den]
  441 + )
  442 + ]
  443 + );
  444 + }
  445 + }
  446 +
  447 + if ($erasures !== null) {
  448 + if (count($erasures) < $count) {
  449 + $erasures->setSize($count);
  450 + }
  451 +
  452 + for ($i = 0; $i < $count; $i++) {
  453 + $erasures[$i] = $loc[$i];
  454 + }
  455 + }
  456 +
  457 + return $count;
  458 + }
  459 +
  460 + /**
  461 + * Computes $x % GF_SIZE, where GF_SIZE is 2**GF_BITS - 1, without a slow
  462 + * divide.
  463 + *
  464 + * @param itneger $x
  465 + * @return integer
  466 + */
  467 + protected function modNn($x)
  468 + {
  469 + while ($x >= $this->blockSize) {
  470 + $x -= $this->blockSize;
  471 + $x = ($x >> $this->symbolSize) + ($x & $this->blockSize);
  472 + }
  473 +
  474 + return $x;
  475 + }
  476 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Common;
  11 +
  12 +use SplFixedArray;
  13 +
  14 +/**
  15 + * Version representation.
  16 + */
  17 +class Version
  18 +{
  19 + /**
  20 + * Version decode information.
  21 + *
  22 + * @var array
  23 + */
  24 + protected static $versionDecodeInfo = array(
  25 + 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d,
  26 + 0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9,
  27 + 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75,
  28 + 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64,
  29 + 0x27541, 0x28c69
  30 + );
  31 +
  32 + /**
  33 + * Cached version instances.
  34 + *
  35 + * @var array
  36 + */
  37 + protected static $versions = array();
  38 +
  39 + /**
  40 + * Version number of this version.
  41 + *
  42 + * @var integer
  43 + */
  44 + protected $versionNumber;
  45 +
  46 + /**
  47 + * Alignment pattern centers.
  48 + *
  49 + * @var SplFixedArray
  50 + */
  51 + protected $alignmentPatternCenters;
  52 +
  53 + /**
  54 + * Error correction blocks.
  55 + *
  56 + * @var SplFixedArray
  57 + */
  58 + protected $errorCorrectionBlocks;
  59 +
  60 + /**
  61 + * Total number of codewords.
  62 + *
  63 + * @var integer
  64 + */
  65 + protected $totalCodewords;
  66 +
  67 + /**
  68 + * Creates a new version.
  69 + *
  70 + * @param integer $versionNumber
  71 + * @param SplFixedArray $alignmentPatternCenters
  72 + * @param SplFixedArray $ecBlocks
  73 + */
  74 + protected function __construct(
  75 + $versionNumber,
  76 + SplFixedArray $alignmentPatternCenters,
  77 + SplFixedArray $ecBlocks
  78 + ) {
  79 + $this->versionNumber = $versionNumber;
  80 + $this->alignmentPatternCenters = $alignmentPatternCenters;
  81 + $this->errorCorrectionBlocks = $ecBlocks;
  82 +
  83 + $totalCodewords = 0;
  84 + $ecCodewords = $ecBlocks[0]->getEcCodewordsPerBlock();
  85 +
  86 + foreach ($ecBlocks[0]->getEcBlocks() as $ecBlock) {
  87 + $totalCodewords += $ecBlock->getCount() * ($ecBlock->getDataCodewords() + $ecCodewords);
  88 + }
  89 +
  90 + $this->totalCodewords = $totalCodewords;
  91 + }
  92 +
  93 + /**
  94 + * Gets the version number.
  95 + *
  96 + * @return integer
  97 + */
  98 + public function getVersionNumber()
  99 + {
  100 + return $this->versionNumber;
  101 + }
  102 +
  103 + /**
  104 + * Gets the alignment pattern centers.
  105 + *
  106 + * @return SplFixedArray
  107 + */
  108 + public function getAlignmentPatternCenters()
  109 + {
  110 + return $this->alignmentPatternCenters;
  111 + }
  112 +
  113 + /**
  114 + * Gets the total number of codewords.
  115 + *
  116 + * @return integer
  117 + */
  118 + public function getTotalCodewords()
  119 + {
  120 + return $this->totalCodewords;
  121 + }
  122 +
  123 + /**
  124 + * Gets the dimension for the current version.
  125 + *
  126 + * @return integer
  127 + */
  128 + public function getDimensionForVersion()
  129 + {
  130 + return 17 + 4 * $this->versionNumber;
  131 + }
  132 +
  133 + /**
  134 + * Gets the number of EC blocks for a specific EC level.
  135 + *
  136 + * @param ErrorCorrectionLevel $ecLevel
  137 + * @return integer
  138 + */
  139 + public function getEcBlocksForLevel(ErrorCorrectionLevel $ecLevel)
  140 + {
  141 + return $this->errorCorrectionBlocks[$ecLevel->getOrdinal()];
  142 + }
  143 +
  144 + /**
  145 + * Gets a provisional version number for a specific dimension.
  146 + *
  147 + * @param integer $dimension
  148 + * @return Version
  149 + * @throws Exception\InvalidArgumentException
  150 + */
  151 + public static function getProvisionalVersionForDimension($dimension)
  152 + {
  153 + if ($dimension % 4 !== 1) {
  154 + throw new Exception\InvalidArgumentException('Dimension is not 1 mod 4');
  155 + }
  156 +
  157 + return self::getVersionForNumber(($dimension - 17) >> 2);
  158 + }
  159 +
  160 + /**
  161 + * Gets a version instance for a specific version number.
  162 + *
  163 + * @param integer $versionNumber
  164 + * @return Version
  165 + * @throws Exception\InvalidArgumentException
  166 + */
  167 + public static function getVersionForNumber($versionNumber)
  168 + {
  169 + if ($versionNumber < 1 || $versionNumber > 40) {
  170 + throw new Exception\InvalidArgumentException('Version number must be between 1 and 40');
  171 + }
  172 +
  173 + if (!isset(self::$versions[$versionNumber])) {
  174 + self::buildVersion($versionNumber);
  175 + }
  176 +
  177 + return self::$versions[$versionNumber - 1];
  178 + }
  179 +
  180 + /**
  181 + * Decodes version information from an integer and returns the version.
  182 + *
  183 + * @param integer $versionBits
  184 + * @return Version|null
  185 + */
  186 + public static function decodeVersionInformation($versionBits)
  187 + {
  188 + $bestDifference = PHP_INT_MAX;
  189 + $bestVersion = 0;
  190 +
  191 + foreach (self::$versionDecodeInfo as $i => $targetVersion) {
  192 + if ($targetVersion === $versionBits) {
  193 + return self::getVersionForNumber($i + 7);
  194 + }
  195 +
  196 + $bitsDifference = FormatInformation::numBitsDiffering($versionBits, $targetVersion);
  197 +
  198 + if ($bitsDifference < $bestDifference) {
  199 + $bestVersion = $i + 7;
  200 + $bestDifference = $bitsDifference;
  201 + }
  202 + }
  203 +
  204 + if ($bestDifference <= 3) {
  205 + return self::getVersionForNumber($bestVersion);
  206 + }
  207 +
  208 + return null;
  209 + }
  210 +
  211 + /**
  212 + * Builds the function pattern for the current version.
  213 + *
  214 + * @return BitMatrix
  215 + */
  216 + public function buildFunctionPattern()
  217 + {
  218 + $dimension = $this->getDimensionForVersion();
  219 + $bitMatrix = new BitMatrix($dimension);
  220 +
  221 + // Top left finder pattern + separator + format
  222 + $bitMatrix->setRegion(0, 0, 9, 9);
  223 + // Top right finder pattern + separator + format
  224 + $bitMatrix->setRegion($dimension - 8, 0, 8, 9);
  225 + // Bottom left finder pattern + separator + format
  226 + $bitMatrix->setRegion(0, $dimension - 8, 9, 8);
  227 +
  228 + // Alignment patterns
  229 + $max = count($this->alignmentPatternCenters);
  230 +
  231 + for ($x = 0; $x < $max; $x++) {
  232 + $i = $this->alignmentPatternCenters[$x] - 2;
  233 +
  234 + for ($y = 0; $y < $max; $y++) {
  235 + if (($x === 0 && ($y === 0 || $y === $max - 1)) || ($x === $max - 1 && $y === 0)) {
  236 + // No alignment patterns near the three finder paterns
  237 + continue;
  238 + }
  239 +
  240 + $bitMatrix->setRegion($this->alignmentPatternCenters[$y] - 2, $i, 5, 5);
  241 + }
  242 + }
  243 +
  244 + // Vertical timing pattern
  245 + $bitMatrix->setRegion(6, 9, 1, $dimension - 17);
  246 + // Horizontal timing pattern
  247 + $bitMatrix->setRegion(9, 6, $dimension - 17, 1);
  248 +
  249 + if ($this->versionNumber > 6) {
  250 + // Version info, top right
  251 + $bitMatrix->setRegion($dimension - 11, 0, 3, 6);
  252 + // Version info, bottom left
  253 + $bitMatrix->setRegion(0, $dimension - 11, 6, 3);
  254 + }
  255 +
  256 + return $bitMatrix;
  257 + }
  258 +
  259 + /**
  260 + * Returns a string representation for the version.
  261 + *
  262 + * @return string
  263 + */
  264 + public function __toString()
  265 + {
  266 + return (string) $this->versionNumber;
  267 + }
  268 +
  269 + /**
  270 + * Build and cache a specific version.
  271 + *
  272 + * See ISO 18004:2006 6.5.1 Table 9.
  273 + *
  274 + * @param integer $versionNumber
  275 + * @return void
  276 + */
  277 + protected static function buildVersion($versionNumber)
  278 + {
  279 + switch ($versionNumber) {
  280 + case 1:
  281 + $patterns = array();
  282 + $ecBlocks = array(
  283 + new EcBlocks(7, new EcBlock(1, 19)),
  284 + new EcBlocks(10, new EcBlock(1, 16)),
  285 + new EcBlocks(13, new EcBlock(1, 13)),
  286 + new EcBlocks(17, new EcBlock(1, 9)),
  287 + );
  288 + break;
  289 +
  290 + case 2:
  291 + $patterns = array(6, 18);
  292 + $ecBlocks = array(
  293 + new EcBlocks(10, new EcBlock(1, 34)),
  294 + new EcBlocks(16, new EcBlock(1, 28)),
  295 + new EcBlocks(22, new EcBlock(1, 22)),
  296 + new EcBlocks(28, new EcBlock(1, 16)),
  297 + );
  298 + break;
  299 +
  300 + case 3:
  301 + $patterns = array(6, 22);
  302 + $ecBlocks = array(
  303 + new EcBlocks(15, new EcBlock(1, 55)),
  304 + new EcBlocks(26, new EcBlock(1, 44)),
  305 + new EcBlocks(18, new EcBlock(2, 17)),
  306 + new EcBlocks(22, new EcBlock(2, 13)),
  307 + );
  308 + break;
  309 +
  310 + case 4:
  311 + $patterns = array(6, 26);
  312 + $ecBlocks = array(
  313 + new EcBlocks(20, new EcBlock(1, 80)),
  314 + new EcBlocks(18, new EcBlock(2, 32)),
  315 + new EcBlocks(26, new EcBlock(3, 24)),
  316 + new EcBlocks(16, new EcBlock(4, 9)),
  317 + );
  318 + break;
  319 +
  320 + case 5:
  321 + $patterns = array(6, 30);
  322 + $ecBlocks = array(
  323 + new EcBlocks(26, new EcBlock(1, 108)),
  324 + new EcBlocks(24, new EcBlock(2, 43)),
  325 + new EcBlocks(18, new EcBlock(2, 15), new EcBlock(2, 16)),
  326 + new EcBlocks(22, new EcBlock(2, 11), new EcBlock(2, 12)),
  327 + );
  328 + break;
  329 +
  330 + case 6:
  331 + $patterns = array(6, 34);
  332 + $ecBlocks = array(
  333 + new EcBlocks(18, new EcBlock(2, 68)),
  334 + new EcBlocks(16, new EcBlock(4, 27)),
  335 + new EcBlocks(24, new EcBlock(4, 19)),
  336 + new EcBlocks(28, new EcBlock(4, 15)),
  337 + );
  338 + break;
  339 +
  340 + case 7:
  341 + $patterns = array(6, 22, 38);
  342 + $ecBlocks = array(
  343 + new EcBlocks(20, new EcBlock(2, 78)),
  344 + new EcBlocks(18, new EcBlock(4, 31)),
  345 + new EcBlocks(18, new EcBlock(2, 14), new EcBlock(4, 15)),
  346 + new EcBlocks(26, new EcBlock(4, 13), new EcBlock(1, 14)),
  347 + );
  348 + break;
  349 +
  350 + case 8:
  351 + $patterns = array(6, 24, 42);
  352 + $ecBlocks = array(
  353 + new EcBlocks(24, new EcBlock(2, 97)),
  354 + new EcBlocks(22, new EcBlock(2, 38), new EcBlock(2, 39)),
  355 + new EcBlocks(22, new EcBlock(4, 18), new EcBlock(2, 19)),
  356 + new EcBlocks(26, new EcBlock(4, 14), new EcBlock(2, 15)),
  357 + );
  358 + break;
  359 +
  360 + case 9:
  361 + $patterns = array(6, 26, 46);
  362 + $ecBlocks = array(
  363 + new EcBlocks(30, new EcBlock(2, 116)),
  364 + new EcBlocks(22, new EcBlock(3, 36), new EcBlock(2, 37)),
  365 + new EcBlocks(20, new EcBlock(4, 16), new EcBlock(4, 17)),
  366 + new EcBlocks(24, new EcBlock(4, 12), new EcBlock(4, 13)),
  367 + );
  368 + break;
  369 +
  370 + case 10:
  371 + $patterns = array(6, 28, 50);
  372 + $ecBlocks = array(
  373 + new EcBlocks(18, new EcBlock(2, 68), new EcBlock(2, 69)),
  374 + new EcBlocks(26, new EcBlock(4, 43), new EcBlock(1, 44)),
  375 + new EcBlocks(24, new EcBlock(6, 19), new EcBlock(2, 20)),
  376 + new EcBlocks(28, new EcBlock(6, 15), new EcBlock(2, 16)),
  377 + );
  378 + break;
  379 +
  380 + case 11:
  381 + $patterns = array(6, 30, 54);
  382 + $ecBlocks = array(
  383 + new EcBlocks(20, new EcBlock(4, 81)),
  384 + new EcBlocks(30, new EcBlock(1, 50), new EcBlock(4, 51)),
  385 + new EcBlocks(28, new EcBlock(4, 22), new EcBlock(4, 23)),
  386 + new EcBlocks(24, new EcBlock(3, 12), new EcBlock(8, 13)),
  387 + );
  388 + break;
  389 +
  390 + case 12:
  391 + $patterns = array(6, 32, 58);
  392 + $ecBlocks = array(
  393 + new EcBlocks(24, new EcBlock(2, 92), new EcBlock(2, 93)),
  394 + new EcBlocks(22, new EcBlock(6, 36), new EcBlock(2, 37)),
  395 + new EcBlocks(26, new EcBlock(4, 20), new EcBlock(6, 21)),
  396 + new EcBlocks(28, new EcBlock(7, 14), new EcBlock(4, 15)),
  397 + );
  398 + break;
  399 +
  400 + case 13:
  401 + $patterns = array(6, 34, 62);
  402 + $ecBlocks = array(
  403 + new EcBlocks(26, new EcBlock(4, 107)),
  404 + new EcBlocks(22, new EcBlock(8, 37), new EcBlock(1, 38)),
  405 + new EcBlocks(24, new EcBlock(8, 20), new EcBlock(4, 21)),
  406 + new EcBlocks(22, new EcBlock(12, 11), new EcBlock(4, 12)),
  407 + );
  408 + break;
  409 +
  410 + case 14:
  411 + $patterns = array(6, 26, 46, 66);
  412 + $ecBlocks = array(
  413 + new EcBlocks(30, new EcBlock(3, 115), new EcBlock(1, 116)),
  414 + new EcBlocks(24, new EcBlock(4, 40), new EcBlock(5, 41)),
  415 + new EcBlocks(20, new EcBlock(11, 16), new EcBlock(5, 17)),
  416 + new EcBlocks(24, new EcBlock(11, 12), new EcBlock(5, 13)),
  417 + );
  418 + break;
  419 +
  420 + case 15:
  421 + $patterns = array(6, 26, 48, 70);
  422 + $ecBlocks = array(
  423 + new EcBlocks(22, new EcBlock(5, 87), new EcBlock(1, 88)),
  424 + new EcBlocks(24, new EcBlock(5, 41), new EcBlock(5, 42)),
  425 + new EcBlocks(30, new EcBlock(5, 24), new EcBlock(7, 25)),
  426 + new EcBlocks(24, new EcBlock(11, 12), new EcBlock(7, 13)),
  427 + );
  428 + break;
  429 +
  430 + case 16:
  431 + $patterns = array(6, 26, 50, 74);
  432 + $ecBlocks = array(
  433 + new EcBlocks(24, new EcBlock(5, 98), new EcBlock(1, 99)),
  434 + new EcBlocks(28, new EcBlock(7, 45), new EcBlock(3, 46)),
  435 + new EcBlocks(24, new EcBlock(15, 19), new EcBlock(2, 20)),
  436 + new EcBlocks(30, new EcBlock(3, 15), new EcBlock(13, 16)),
  437 + );
  438 + break;
  439 +
  440 + case 17:
  441 + $patterns = array(6, 30, 54, 78);
  442 + $ecBlocks = array(
  443 + new EcBlocks(28, new EcBlock(1, 107), new EcBlock(5, 108)),
  444 + new EcBlocks(28, new EcBlock(10, 46), new EcBlock(1, 47)),
  445 + new EcBlocks(28, new EcBlock(1, 22), new EcBlock(15, 23)),
  446 + new EcBlocks(28, new EcBlock(2, 14), new EcBlock(17, 15)),
  447 + );
  448 + break;
  449 +
  450 + case 18:
  451 + $patterns = array(6, 30, 56, 82);
  452 + $ecBlocks = array(
  453 + new EcBlocks(30, new EcBlock(5, 120), new EcBlock(1, 121)),
  454 + new EcBlocks(26, new EcBlock(9, 43), new EcBlock(4, 44)),
  455 + new EcBlocks(28, new EcBlock(17, 22), new EcBlock(1, 23)),
  456 + new EcBlocks(28, new EcBlock(2, 14), new EcBlock(19, 15)),
  457 + );
  458 + break;
  459 +
  460 + case 19:
  461 + $patterns = array(6, 30, 58, 86);
  462 + $ecBlocks = array(
  463 + new EcBlocks(28, new EcBlock(3, 113), new EcBlock(4, 114)),
  464 + new EcBlocks(26, new EcBlock(3, 44), new EcBlock(11, 45)),
  465 + new EcBlocks(26, new EcBlock(17, 21), new EcBlock(4, 22)),
  466 + new EcBlocks(26, new EcBlock(9, 13), new EcBlock(16, 14)),
  467 + );
  468 + break;
  469 +
  470 + case 20:
  471 + $patterns = array(6, 34, 62, 90);
  472 + $ecBlocks = array(
  473 + new EcBlocks(28, new EcBlock(3, 107), new EcBlock(5, 108)),
  474 + new EcBlocks(26, new EcBlock(3, 41), new EcBlock(13, 42)),
  475 + new EcBlocks(30, new EcBlock(15, 24), new EcBlock(5, 25)),
  476 + new EcBlocks(28, new EcBlock(15, 15), new EcBlock(10, 16)),
  477 + );
  478 + break;
  479 +
  480 + case 21:
  481 + $patterns = array(6, 28, 50, 72, 94);
  482 + $ecBlocks = array(
  483 + new EcBlocks(28, new EcBlock(4, 116), new EcBlock(4, 117)),
  484 + new EcBlocks(26, new EcBlock(17, 42)),
  485 + new EcBlocks(28, new EcBlock(17, 22), new EcBlock(6, 23)),
  486 + new EcBlocks(30, new EcBlock(19, 16), new EcBlock(6, 17)),
  487 + );
  488 + break;
  489 +
  490 + case 22:
  491 + $patterns = array(6, 26, 50, 74, 98);
  492 + $ecBlocks = array(
  493 + new EcBlocks(28, new EcBlock(2, 111), new EcBlock(7, 112)),
  494 + new EcBlocks(28, new EcBlock(17, 46)),
  495 + new EcBlocks(30, new EcBlock(7, 24), new EcBlock(16, 25)),
  496 + new EcBlocks(24, new EcBlock(34, 13)),
  497 + );
  498 + break;
  499 +
  500 + case 23:
  501 + $patterns = array(6, 30, 54, 78, 102);
  502 + $ecBlocks = array(
  503 + new EcBlocks(30, new EcBlock(4, 121), new EcBlock(5, 122)),
  504 + new EcBlocks(28, new EcBlock(4, 47), new EcBlock(14, 48)),
  505 + new EcBlocks(30, new EcBlock(11, 24), new EcBlock(14, 25)),
  506 + new EcBlocks(30, new EcBlock(16, 15), new EcBlock(14, 16)),
  507 + );
  508 + break;
  509 +
  510 + case 24:
  511 + $patterns = array(6, 28, 54, 80, 106);
  512 + $ecBlocks = array(
  513 + new EcBlocks(30, new EcBlock(6, 117), new EcBlock(4, 118)),
  514 + new EcBlocks(28, new EcBlock(6, 45), new EcBlock(14, 46)),
  515 + new EcBlocks(30, new EcBlock(11, 24), new EcBlock(16, 25)),
  516 + new EcBlocks(30, new EcBlock(30, 16), new EcBlock(2, 17)),
  517 + );
  518 + break;
  519 +
  520 + case 25:
  521 + $patterns = array(6, 32, 58, 84, 110);
  522 + $ecBlocks = array(
  523 + new EcBlocks(26, new EcBlock(8, 106), new EcBlock(4, 107)),
  524 + new EcBlocks(28, new EcBlock(8, 47), new EcBlock(13, 48)),
  525 + new EcBlocks(30, new EcBlock(7, 24), new EcBlock(22, 25)),
  526 + new EcBlocks(30, new EcBlock(22, 15), new EcBlock(13, 16)),
  527 + );
  528 + break;
  529 +
  530 + case 26:
  531 + $patterns = array(6, 30, 58, 86, 114);
  532 + $ecBlocks = array(
  533 + new EcBlocks(28, new EcBlock(10, 114), new EcBlock(2, 115)),
  534 + new EcBlocks(28, new EcBlock(19, 46), new EcBlock(4, 47)),
  535 + new EcBlocks(28, new EcBlock(28, 22), new EcBlock(6, 23)),
  536 + new EcBlocks(30, new EcBlock(33, 16), new EcBlock(4, 17)),
  537 + );
  538 + break;
  539 +
  540 + case 27:
  541 + $patterns = array(6, 34, 62, 90, 118);
  542 + $ecBlocks = array(
  543 + new EcBlocks(30, new EcBlock(8, 122), new EcBlock(4, 123)),
  544 + new EcBlocks(28, new EcBlock(22, 45), new EcBlock(3, 46)),
  545 + new EcBlocks(30, new EcBlock(8, 23), new EcBlock(26, 24)),
  546 + new EcBlocks(30, new EcBlock(12, 15), new EcBlock(28, 16)),
  547 + );
  548 + break;
  549 +
  550 + case 28:
  551 + $patterns = array(6, 26, 50, 74, 98, 122);
  552 + $ecBlocks = array(
  553 + new EcBlocks(30, new EcBlock(3, 117), new EcBlock(10, 118)),
  554 + new EcBlocks(28, new EcBlock(3, 45), new EcBlock(23, 46)),
  555 + new EcBlocks(30, new EcBlock(4, 24), new EcBlock(31, 25)),
  556 + new EcBlocks(30, new EcBlock(11, 15), new EcBlock(31, 16)),
  557 + );
  558 + break;
  559 +
  560 + case 29:
  561 + $patterns = array(6, 30, 54, 78, 102, 126);
  562 + $ecBlocks = array(
  563 + new EcBlocks(30, new EcBlock(7, 116), new EcBlock(7, 117)),
  564 + new EcBlocks(28, new EcBlock(21, 45), new EcBlock(7, 46)),
  565 + new EcBlocks(30, new EcBlock(1, 23), new EcBlock(37, 24)),
  566 + new EcBlocks(30, new EcBlock(19, 15), new EcBlock(26, 16)),
  567 + );
  568 + break;
  569 +
  570 + case 30:
  571 + $patterns = array(6, 26, 52, 78, 104, 130);
  572 + $ecBlocks = array(
  573 + new EcBlocks(30, new EcBlock(5, 115), new EcBlock(10, 116)),
  574 + new EcBlocks(28, new EcBlock(19, 47), new EcBlock(10, 48)),
  575 + new EcBlocks(30, new EcBlock(15, 24), new EcBlock(25, 25)),
  576 + new EcBlocks(30, new EcBlock(23, 15), new EcBlock(25, 16)),
  577 + );
  578 + break;
  579 +
  580 + case 31:
  581 + $patterns = array(6, 30, 56, 82, 108, 134);
  582 + $ecBlocks = array(
  583 + new EcBlocks(30, new EcBlock(13, 115), new EcBlock(3, 116)),
  584 + new EcBlocks(28, new EcBlock(2, 46), new EcBlock(29, 47)),
  585 + new EcBlocks(30, new EcBlock(42, 24), new EcBlock(1, 25)),
  586 + new EcBlocks(30, new EcBlock(23, 15), new EcBlock(28, 16)),
  587 + );
  588 + break;
  589 +
  590 + case 32:
  591 + $patterns = array(6, 34, 60, 86, 112, 138);
  592 + $ecBlocks = array(
  593 + new EcBlocks(30, new EcBlock(17, 115)),
  594 + new EcBlocks(28, new EcBlock(10, 46), new EcBlock(23, 47)),
  595 + new EcBlocks(30, new EcBlock(10, 24), new EcBlock(35, 25)),
  596 + new EcBlocks(30, new EcBlock(19, 15), new EcBlock(35, 16)),
  597 + );
  598 + break;
  599 +
  600 + case 33:
  601 + $patterns = array(6, 30, 58, 86, 114, 142);
  602 + $ecBlocks = array(
  603 + new EcBlocks(30, new EcBlock(17, 115), new EcBlock(1, 116)),
  604 + new EcBlocks(28, new EcBlock(14, 46), new EcBlock(21, 47)),
  605 + new EcBlocks(30, new EcBlock(29, 24), new EcBlock(19, 25)),
  606 + new EcBlocks(30, new EcBlock(11, 15), new EcBlock(46, 16)),
  607 + );
  608 + break;
  609 +
  610 + case 34:
  611 + $patterns = array(6, 34, 62, 90, 118, 146);
  612 + $ecBlocks = array(
  613 + new EcBlocks(30, new EcBlock(13, 115), new EcBlock(6, 116)),
  614 + new EcBlocks(28, new EcBlock(14, 46), new EcBlock(23, 47)),
  615 + new EcBlocks(30, new EcBlock(44, 24), new EcBlock(7, 25)),
  616 + new EcBlocks(30, new EcBlock(59, 16), new EcBlock(1, 17)),
  617 + );
  618 + break;
  619 +
  620 + case 35:
  621 + $patterns = array(6, 30, 54, 78, 102, 126, 150);
  622 + $ecBlocks = array(
  623 + new EcBlocks(30, new EcBlock(12, 121), new EcBlock(7, 122)),
  624 + new EcBlocks(28, new EcBlock(12, 47), new EcBlock(26, 48)),
  625 + new EcBlocks(30, new EcBlock(39, 24), new EcBlock(14, 25)),
  626 + new EcBlocks(30, new EcBlock(22, 15), new EcBlock(41, 16)),
  627 + );
  628 + break;
  629 +
  630 + case 36:
  631 + $patterns = array(6, 24, 50, 76, 102, 128, 154);
  632 + $ecBlocks = array(
  633 + new EcBlocks(30, new EcBlock(6, 121), new EcBlock(14, 122)),
  634 + new EcBlocks(28, new EcBlock(6, 47), new EcBlock(34, 48)),
  635 + new EcBlocks(30, new EcBlock(46, 24), new EcBlock(10, 25)),
  636 + new EcBlocks(30, new EcBlock(2, 15), new EcBlock(64, 16)),
  637 + );
  638 + break;
  639 +
  640 + case 37:
  641 + $patterns = array(6, 28, 54, 80, 106, 132, 158);
  642 + $ecBlocks = array(
  643 + new EcBlocks(30, new EcBlock(17, 122), new EcBlock(4, 123)),
  644 + new EcBlocks(28, new EcBlock(29, 46), new EcBlock(14, 47)),
  645 + new EcBlocks(30, new EcBlock(49, 24), new EcBlock(10, 25)),
  646 + new EcBlocks(30, new EcBlock(24, 15), new EcBlock(46, 16)),
  647 + );
  648 + break;
  649 +
  650 + case 38:
  651 + $patterns = array(6, 32, 58, 84, 110, 136, 162);
  652 + $ecBlocks = array(
  653 + new EcBlocks(30, new EcBlock(4, 122), new EcBlock(18, 123)),
  654 + new EcBlocks(28, new EcBlock(13, 46), new EcBlock(32, 47)),
  655 + new EcBlocks(30, new EcBlock(48, 24), new EcBlock(14, 25)),
  656 + new EcBlocks(30, new EcBlock(42, 15), new EcBlock(32, 16)),
  657 + );
  658 + break;
  659 +
  660 + case 39:
  661 + $patterns = array(6, 26, 54, 82, 110, 138, 166);
  662 + $ecBlocks = array(
  663 + new EcBlocks(30, new EcBlock(20, 117), new EcBlock(4, 118)),
  664 + new EcBlocks(28, new EcBlock(40, 47), new EcBlock(7, 48)),
  665 + new EcBlocks(30, new EcBlock(43, 24), new EcBlock(22, 25)),
  666 + new EcBlocks(30, new EcBlock(10, 15), new EcBlock(67, 16)),
  667 + );
  668 + break;
  669 +
  670 + case 40:
  671 + $patterns = array(6, 30, 58, 86, 114, 142, 170);
  672 + $ecBlocks = array(
  673 + new EcBlocks(30, new EcBlock(19, 118), new EcBlock(6, 119)),
  674 + new EcBlocks(28, new EcBlock(18, 47), new EcBlock(31, 48)),
  675 + new EcBlocks(30, new EcBlock(34, 24), new EcBlock(34, 25)),
  676 + new EcBlocks(30, new EcBlock(20, 15), new EcBlock(61, 16)),
  677 + );
  678 + break;
  679 + }
  680 +
  681 + self::$versions[$versionNumber - 1] = new self(
  682 + $versionNumber,
  683 + SplFixedArray::fromArray($patterns, false),
  684 + SplFixedArray::fromArray($ecBlocks, false)
  685 + );
  686 + }
  687 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Encoder;
  11 +
  12 +use SplFixedArray;
  13 +
  14 +/**
  15 + * Block pair.
  16 + */
  17 +class BlockPair
  18 +{
  19 + /**
  20 + * Data bytes in the block.
  21 + *
  22 + * @var SplFixedArray
  23 + */
  24 + protected $dataBytes;
  25 +
  26 + /**
  27 + * Error correction bytes in the block.
  28 + *
  29 + * @var SplFixedArray
  30 + */
  31 + protected $errorCorrectionBytes;
  32 +
  33 + /**
  34 + * Creates a new block pair.
  35 + *
  36 + * @param SplFixedArray $data
  37 + * @param SplFixedArray $errorCorrection
  38 + */
  39 + public function __construct(SplFixedArray $data, SplFixedArray $errorCorrection)
  40 + {
  41 + $this->dataBytes = $data;
  42 + $this->errorCorrectionBytes = $errorCorrection;
  43 + }
  44 +
  45 + /**
  46 + * Gets the data bytes.
  47 + *
  48 + * @return SplFixedArray
  49 + */
  50 + public function getDataBytes()
  51 + {
  52 + return $this->dataBytes;
  53 + }
  54 +
  55 + /**
  56 + * Gets the error correction bytes.
  57 + *
  58 + * @return SplFixedArray
  59 + */
  60 + public function getErrorCorrectionBytes()
  61 + {
  62 + return $this->errorCorrectionBytes;
  63 + }
  64 +}
  1 +<?php
  2 +/**
  3 + * BaconQrCode
  4 + *
  5 + * @link http://github.com/Bacon/BaconQrCode For the canonical source repository
  6 + * @copyright 2013 Ben 'DASPRiD' Scholzen
  7 + * @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
  8 + */
  9 +
  10 +namespace BaconQrCode\Encoder;
  11 +
  12 +use SplFixedArray;
  13 +
  14 +/**
  15 + * Byte matrix.
  16 + */
  17 +class ByteMatrix
  18 +{
  19 + /**
  20 + * Bytes in the matrix, represented as array.
  21 + *
  22 + * @var SplFixedArray
  23 + */
  24 + protected $bytes;
  25 +
  26 + /**
  27 + * Width of the matrix.
  28 + *
  29 + * @var integer
  30 + */
  31 + protected $width;
  32 +
  33 + /**
  34 + * Height of the matrix.
  35 + *
  36 + * @var integer
  37 + */
  38 + protected $height;
  39 +
  40 + /**
  41 + * Creates a new byte matrix.
  42 + *
  43 + * @param integer $width
  44 + * @param integer $height
  45 + */
  46 + public function __construct($width, $height)
  47 + {
  48 + $this->height = $height;
  49 + $this->width = $width;
  50 + $this->bytes = new SplFixedArray($height);
  51 +
  52 + for ($y = 0; $y < $height; $y++) {
  53 + $this->bytes[$y] = new SplFixedArray($width);
  54 + }
  55 + }
  56 +
  57 + /**
  58 + * Gets the width of the matrix.
  59 + *
  60 + * @return integer
  61 + */
  62 + public function getWidth()
  63 + {
  64 + return $this->width;
  65 + }
  66 +
  67 + /**
  68 + * Gets the height of the matrix.
  69 + *
  70 + * @return integer
  71 + */
  72 + public function getHeight()
  73 + {
  74 + return $this->height;
  75 + }
  76 +
  77 + /**
  78 + * Gets the internal representation of the matrix.
  79 + *
  80 + * @return SplFixedArray
  81 + */
  82 + public function getArray()
  83 + {
  84 + return $this->bytes;
  85 + }
  86 +
  87 + /**
  88 + * Gets the byte for a specific position.
  89 + *
  90 + * @param integer $x
  91 + * @param integer $y
  92 + * @return integer
  93 + */
  94 + public function get($x, $y)
  95 + {
  96 + return $this->bytes[$y][$x];
  97 + }
  98 +
  99 + /**
  100 + * Sets the byte for a specific position.
  101 + *
  102 + * @param integer $x
  103 + * @param integer $y
  104 + * @param integer $value
  105 + * @return void
  106 + */
  107 + public function set($x, $y, $value)
  108 + {
  109 + $this->bytes[$y][$x] = (int) $value;
  110 + }
  111 +
  112 + /**
  113 + * Clears the matrix with a specific value.
  114 + *
  115 + * @param integer $value
  116 + * @return void
  117 + */
  118 + public function clear($value)
  119 + {
  120 + for ($y = 0; $y < $this->height; $y++) {
  121 + for ($x = 0; $x < $this->width; $x++) {
  122 + $this->bytes[$y][$x] = $value;
  123 + }
  124 + }
  125 + }
  126 +
  127 + /**
  128 + * Returns a string representation of the matrix.
  129 + *
  130 + * @return string
  131 + */
  132 + public function __toString()
  133 + {
  134 + $result = '';
  135 +
  136 + for ($y = 0; $y < $this->height; $y++) {
  137 + for ($x = 0; $x < $this->width; $x++) {
  138 + switch ($this->bytes[$y][$x]) {
  139 + case 0:
  140 + $result .= ' 0';
  141 + break;
  142 +
  143 + case 1:
  144 + $result .= ' 1';
  145 + break;
  146 +
  147 + default:
  148 + $result .= ' ';
  149 + break;
  150 + }
  151 + }
  152 +
  153 + $result .= "\n";
  154 + }
  155 +
  156 + return $result;
  157 + }
  158 +}