Passed
Push — master ( a3c0d0...678db7 )
by Cody
06:27 queued 03:12
created
lib/phpqrcode/tools/merge.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@
 block discarded – undo
51 51
     
52 52
     $outputCode = '';
53 53
     
54
-    foreach($fileList as $fileName) {
54
+    foreach ($fileList as $fileName) {
55 55
         $outputCode .= "\n\n".'//---- '.basename($fileName).' -----------------------------'."\n\n";
56 56
         $anotherCode = file_get_contents($fileName);
57
-        $anotherCode = preg_replace ('/^<\?php/', '', $anotherCode);
58
-        $anotherCode = preg_replace ('/\?>\*$/', '', $anotherCode);
57
+        $anotherCode = preg_replace('/^<\?php/', '', $anotherCode);
58
+        $anotherCode = preg_replace('/\?>\*$/', '', $anotherCode);
59 59
         $outputCode .= "\n\n".$anotherCode."\n\n";
60 60
     }
61 61
     
Please login to merge, or discard this patch.
lib/phpqrcode/tools/merged_config.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
5 5
  * Config file, tuned-up for merged verion
6 6
  */
7 7
      
8
-    define('QR_CACHEABLE', false);       // use cache - more disk reads but less CPU power, masks and format templates are stored there
9
-    define('QR_CACHE_DIR', false);       // used when QR_CACHEABLE === true
10
-    define('QR_LOG_DIR', false);         // default error logs dir   
8
+    define('QR_CACHEABLE', false); // use cache - more disk reads but less CPU power, masks and format templates are stored there
9
+    define('QR_CACHE_DIR', false); // used when QR_CACHEABLE === true
10
+    define('QR_LOG_DIR', false); // default error logs dir   
11 11
     
12
-    define('QR_FIND_BEST_MASK', true);                                                          // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
13
-    define('QR_FIND_FROM_RANDOM', 2);                                                       // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
14
-    define('QR_DEFAULT_MASK', 2);                                                               // when QR_FIND_BEST_MASK === false
12
+    define('QR_FIND_BEST_MASK', true); // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
13
+    define('QR_FIND_FROM_RANDOM', 2); // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
14
+    define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false
15 15
                                                   
16
-    define('QR_PNG_MAXIMUM_SIZE',  1024);                                                       // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images
16
+    define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images
17 17
                                                   
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
lib/phpqrcode/qrbitstream.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
             $bstream->allocate($bits);
50 50
             
51 51
             $mask = 1 << ($bits - 1);
52
-            for($i=0; $i<$bits; $i++) {
53
-                if($num & $mask) {
52
+            for ($i = 0; $i < $bits; $i++) {
53
+                if ($num & $mask) {
54 54
                     $bstream->data[$i] = 1;
55 55
                 } else {
56 56
                     $bstream->data[$i] = 0;
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
         {
67 67
             $bstream = new QRbitstream();
68 68
             $bstream->allocate($size * 8);
69
-            $p=0;
69
+            $p = 0;
70 70
 
71
-            for($i=0; $i<$size; $i++) {
71
+            for ($i = 0; $i < $size; $i++) {
72 72
                 $mask = 0x80;
73
-                for($j=0; $j<8; $j++) {
74
-                    if($data[$i] & $mask) {
73
+                for ($j = 0; $j < 8; $j++) {
74
+                    if ($data[$i] & $mask) {
75 75
                         $bstream->data[$p] = 1;
76 76
                     } else {
77 77
                         $bstream->data[$p] = 0;
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
                 return -1;
92 92
             }
93 93
             
94
-            if($arg->size() == 0) {
94
+            if ($arg->size() == 0) {
95 95
                 return 0;
96 96
             }
97 97
             
98
-            if($this->size() == 0) {
98
+            if ($this->size() == 0) {
99 99
                 $this->data = $arg->data;
100 100
                 return 0;
101 101
             }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
             $b = QRbitstream::newFromNum($bits, $num);
115 115
             
116
-            if(is_null($b))
116
+            if (is_null($b))
117 117
                 return -1;
118 118
 
119 119
             $ret = $this->append($b);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
             $b = QRbitstream::newFromBytes($size, $data);
132 132
             
133
-            if(is_null($b))
133
+            if (is_null($b))
134 134
                 return -1;
135 135
 
136 136
             $ret = $this->append($b);
@@ -145,18 +145,18 @@  discard block
 block discarded – undo
145 145
         
146 146
             $size = $this->size();
147 147
 
148
-            if($size == 0) {
148
+            if ($size == 0) {
149 149
                 return array();
150 150
             }
151 151
             
152
-            $data = array_fill(0, (int)(($size + 7) / 8), 0);
153
-            $bytes = (int)($size / 8);
152
+            $data = array_fill(0, (int) (($size + 7) / 8), 0);
153
+            $bytes = (int) ($size / 8);
154 154
 
155 155
             $p = 0;
156 156
             
157
-            for($i=0; $i<$bytes; $i++) {
157
+            for ($i = 0; $i < $bytes; $i++) {
158 158
                 $v = 0;
159
-                for($j=0; $j<8; $j++) {
159
+                for ($j = 0; $j < 8; $j++) {
160 160
                     $v = $v << 1;
161 161
                     $v |= $this->data[$p];
162 162
                     $p++;
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
                 $data[$i] = $v;
165 165
             }
166 166
             
167
-            if($size & 7) {
167
+            if ($size & 7) {
168 168
                 $v = 0;
169
-                for($j=0; $j<($size & 7); $j++) {
169
+                for ($j = 0; $j < ($size & 7); $j++) {
170 170
                     $v = $v << 1;
171 171
                     $v |= $this->data[$p];
172 172
                     $p++;
Please login to merge, or discard this patch.
lib/phpqrcode/qrsplit.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             if ($pos >= strlen($str))
51 51
                 return false;
52 52
             
53
-            return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
53
+            return ((ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9')));
54 54
         }
55 55
         
56 56
         //----------------------------------------------------------------------
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
                 
71 71
             $c = $this->dataStr[$pos];
72 72
             
73
-            if(self::isdigitat($this->dataStr, $pos)) {
73
+            if (self::isdigitat($this->dataStr, $pos)) {
74 74
                 return QR_MODE_NUM;
75
-            } else if(self::isalnumat($this->dataStr, $pos)) {
75
+            } else if (self::isalnumat($this->dataStr, $pos)) {
76 76
                 return QR_MODE_AN;
77
-            } else if($this->modeHint == QR_MODE_KANJI) {
77
+            } else if ($this->modeHint == QR_MODE_KANJI) {
78 78
             
79
-                if ($pos+1 < strlen($this->dataStr)) 
79
+                if ($pos + 1 < strlen($this->dataStr)) 
80 80
                 {
81
-                    $d = $this->dataStr[$pos+1];
81
+                    $d = $this->dataStr[$pos + 1];
82 82
                     $word = (ord($c) << 8) | ord($d);
83
-                    if(($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) {
83
+                    if (($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) {
84 84
                         return QR_MODE_KANJI;
85 85
                     }
86 86
                 }
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
             $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
96 96
 
97 97
             $p = 0;
98
-            while(self::isdigitat($this->dataStr, $p)) {
98
+            while (self::isdigitat($this->dataStr, $p)) {
99 99
                 $p++;
100 100
             }
101 101
             
102 102
             $run = $p;
103 103
             $mode = $this->identifyMode($p);
104 104
             
105
-            if($mode == QR_MODE_8) {
105
+            if ($mode == QR_MODE_8) {
106 106
                 $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln
107 107
                      + QRinput::estimateBitsMode8(1)         // + 4 + l8
108 108
                      - QRinput::estimateBitsMode8($run + 1); // - 4 - l8
109
-                if($dif > 0) {
109
+                if ($dif > 0) {
110 110
                     return $this->eat8();
111 111
                 }
112 112
             }
113
-            if($mode == QR_MODE_AN) {
113
+            if ($mode == QR_MODE_AN) {
114 114
                 $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln
115 115
                      + QRinput::estimateBitsModeAn(1)        // + 4 + la
116
-                     - QRinput::estimateBitsModeAn($run + 1);// - 4 - la
117
-                if($dif > 0) {
116
+                     - QRinput::estimateBitsModeAn($run + 1); // - 4 - la
117
+                if ($dif > 0) {
118 118
                     return $this->eatAn();
119 119
                 }
120 120
             }
121 121
             
122 122
             $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr));
123
-            if($ret < 0)
123
+            if ($ret < 0)
124 124
                 return -1;
125 125
 
126 126
             return $run;
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
         //----------------------------------------------------------------------
130 130
         public function eatAn()
131 131
         {
132
-            $la = QRspec::lengthIndicator(QR_MODE_AN,  $this->input->getVersion());
132
+            $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
133 133
             $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
134 134
 
135 135
             $p = 0;
136 136
             
137
-            while(self::isalnumat($this->dataStr, $p)) {
138
-                if(self::isdigitat($this->dataStr, $p)) {
137
+            while (self::isalnumat($this->dataStr, $p)) {
138
+                if (self::isdigitat($this->dataStr, $p)) {
139 139
                     $q = $p;
140
-                    while(self::isdigitat($this->dataStr, $q)) {
140
+                    while (self::isdigitat($this->dataStr, $q)) {
141 141
                         $q++;
142 142
                     }
143 143
                     
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                          + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
146 146
                          - QRinput::estimateBitsModeAn($q); // - 4 - la
147 147
                          
148
-                    if($dif < 0) {
148
+                    if ($dif < 0) {
149 149
                         break;
150 150
                     } else {
151 151
                         $p = $q;
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 
158 158
             $run = $p;
159 159
 
160
-            if(!self::isalnumat($this->dataStr, $p)) {
160
+            if (!self::isalnumat($this->dataStr, $p)) {
161 161
                 $dif = QRinput::estimateBitsModeAn($run) + 4 + $la
162 162
                      + QRinput::estimateBitsMode8(1) // + 4 + l8
163 163
                       - QRinput::estimateBitsMode8($run + 1); // - 4 - l8
164
-                if($dif > 0) {
164
+                if ($dif > 0) {
165 165
                     return $this->eat8();
166 166
                 }
167 167
             }
168 168
 
169 169
             $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr));
170
-            if($ret < 0)
170
+            if ($ret < 0)
171 171
                 return -1;
172 172
 
173 173
             return $run;
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
         {
179 179
             $p = 0;
180 180
             
181
-            while($this->identifyMode($p) == QR_MODE_KANJI) {
181
+            while ($this->identifyMode($p) == QR_MODE_KANJI) {
182 182
                 $p += 2;
183 183
             }
184 184
             
185 185
             $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr));
186
-            if($ret < 0)
186
+            if ($ret < 0)
187 187
                 return -1;
188 188
 
189 189
             return $ret;
@@ -198,34 +198,34 @@  discard block
 block discarded – undo
198 198
             $p = 1;
199 199
             $dataStrLen = strlen($this->dataStr);
200 200
             
201
-            while($p < $dataStrLen) {
201
+            while ($p < $dataStrLen) {
202 202
                 
203 203
                 $mode = $this->identifyMode($p);
204
-                if($mode == QR_MODE_KANJI) {
204
+                if ($mode == QR_MODE_KANJI) {
205 205
                     break;
206 206
                 }
207
-                if($mode == QR_MODE_NUM) {
207
+                if ($mode == QR_MODE_NUM) {
208 208
                     $q = $p;
209
-                    while(self::isdigitat($this->dataStr, $q)) {
209
+                    while (self::isdigitat($this->dataStr, $q)) {
210 210
                         $q++;
211 211
                     }
212 212
                     $dif = QRinput::estimateBitsMode8($p) // + 4 + l8
213 213
                          + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
214 214
                          - QRinput::estimateBitsMode8($q); // - 4 - l8
215
-                    if($dif < 0) {
215
+                    if ($dif < 0) {
216 216
                         break;
217 217
                     } else {
218 218
                         $p = $q;
219 219
                     }
220
-                } else if($mode == QR_MODE_AN) {
220
+                } else if ($mode == QR_MODE_AN) {
221 221
                     $q = $p;
222
-                    while(self::isalnumat($this->dataStr, $q)) {
222
+                    while (self::isalnumat($this->dataStr, $q)) {
223 223
                         $q++;
224 224
                     }
225 225
                     $dif = QRinput::estimateBitsMode8($p)  // + 4 + l8
226 226
                          + QRinput::estimateBitsModeAn($q - $p) + 4 + $la
227 227
                          - QRinput::estimateBitsMode8($q); // - 4 - l8
228
-                    if($dif < 0) {
228
+                    if ($dif < 0) {
229 229
                         break;
230 230
                     } else {
231 231
                         $p = $q;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             $run = $p;
239 239
             $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
240 240
             
241
-            if($ret < 0)
241
+            if ($ret < 0)
242 242
                 return -1;
243 243
 
244 244
             return $run;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         {
250 250
             while (strlen($this->dataStr) > 0)
251 251
             {
252
-                if($this->dataStr == '')
252
+                if ($this->dataStr == '')
253 253
                     return 0;
254 254
 
255 255
                 $mode = $this->identifyMode(0);
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
                 
267 267
                 }
268 268
 
269
-                if($length == 0) return 0;
270
-                if($length < 0)  return -1;
269
+                if ($length == 0) return 0;
270
+                if ($length < 0)  return -1;
271 271
                 
272 272
                 $this->dataStr = substr($this->dataStr, $length);
273 273
             }
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
             $stringLen = strlen($this->dataStr);
280 280
             $p = 0;
281 281
             
282
-            while ($p<$stringLen) {
282
+            while ($p < $stringLen) {
283 283
                 $mode = self::identifyMode(substr($this->dataStr, $p));
284
-                if($mode == QR_MODE_KANJI) {
284
+                if ($mode == QR_MODE_KANJI) {
285 285
                     $p += 2;
286 286
                 } else {
287 287
                     if (ord($this->dataStr[$p]) >= ord('a') && ord($this->dataStr[$p]) <= ord('z')) {
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
         //----------------------------------------------------------------------
298 298
         public static function splitStringToQRinput($string, QRinput $input, $modeHint, $casesensitive = true)
299 299
         {
300
-            if(is_null($string) || $string == '\0' || $string == '') {
300
+            if (is_null($string) || $string == '\0' || $string == '') {
301 301
                 throw new Exception('empty string!!!');
302 302
             }
303 303
 
304 304
             $split = new QRsplit($string, $input, $modeHint);
305 305
             
306
-            if(!$casesensitive)
306
+            if (!$casesensitive)
307 307
                 $split->toUpper();
308 308
                 
309 309
             return $split->splitString();
Please login to merge, or discard this patch.
lib/phpqrcode/qrinput.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 26
  */
27 27
  
28
-    define('STRUCTURE_HEADER_BITS',  20);
28
+    define('STRUCTURE_HEADER_BITS', 20);
29 29
     define('MAX_STRUCTURED_SYMBOLS', 16);
30 30
 
31 31
     class QRinputItem {
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
             $setData = array_slice($data, 0, $size);
41 41
             
42 42
             if (count($setData) < $size) {
43
-                $setData = array_merge($setData, array_fill(0,$size-count($setData),0));
43
+                $setData = array_merge($setData, array_fill(0, $size - count($setData), 0));
44 44
             }
45 45
         
46
-            if(!QRinput::check($mode, $size, $setData)) {
47
-                throw new Exception('Error m:'.$mode.',s:'.$size.',d:'.join(',',$setData));
46
+            if (!QRinput::check($mode, $size, $setData)) {
47
+                throw new Exception('Error m:'.$mode.',s:'.$size.',d:'.join(',', $setData));
48 48
                 return null;
49 49
             }
50 50
             
@@ -59,26 +59,26 @@  discard block
 block discarded – undo
59 59
         {
60 60
             try {
61 61
             
62
-                $words = (int)($this->size / 3);
62
+                $words = (int) ($this->size / 3);
63 63
                 $bs = new QRbitstream();
64 64
                 
65 65
                 $val = 0x1;
66 66
                 $bs->appendNum(4, $val);
67 67
                 $bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size);
68 68
 
69
-                for($i=0; $i<$words; $i++) {
70
-                    $val  = (ord($this->data[$i*3  ]) - ord('0')) * 100;
71
-                    $val += (ord($this->data[$i*3+1]) - ord('0')) * 10;
72
-                    $val += (ord($this->data[$i*3+2]) - ord('0'));
69
+                for ($i = 0; $i < $words; $i++) {
70
+                    $val  = (ord($this->data[$i * 3]) - ord('0')) * 100;
71
+                    $val += (ord($this->data[$i * 3 + 1]) - ord('0')) * 10;
72
+                    $val += (ord($this->data[$i * 3 + 2]) - ord('0'));
73 73
                     $bs->appendNum(10, $val);
74 74
                 }
75 75
 
76
-                if($this->size - $words * 3 == 1) {
77
-                    $val = ord($this->data[$words*3]) - ord('0');
76
+                if ($this->size - $words * 3 == 1) {
77
+                    $val = ord($this->data[$words * 3]) - ord('0');
78 78
                     $bs->appendNum(4, $val);
79
-                } else if($this->size - $words * 3 == 2) {
80
-                    $val  = (ord($this->data[$words*3  ]) - ord('0')) * 10;
81
-                    $val += (ord($this->data[$words*3+1]) - ord('0'));
79
+                } else if ($this->size - $words * 3 == 2) {
80
+                    $val  = (ord($this->data[$words * 3]) - ord('0')) * 10;
81
+                    $val += (ord($this->data[$words * 3 + 1]) - ord('0'));
82 82
                     $bs->appendNum(7, $val);
83 83
                 }
84 84
 
@@ -94,20 +94,20 @@  discard block
 block discarded – undo
94 94
         public function encodeModeAn($version)
95 95
         {
96 96
             try {
97
-                $words = (int)($this->size / 2);
97
+                $words = (int) ($this->size / 2);
98 98
                 $bs = new QRbitstream();
99 99
                 
100 100
                 $bs->appendNum(4, 0x02);
101 101
                 $bs->appendNum(QRspec::lengthIndicator(QR_MODE_AN, $version), $this->size);
102 102
 
103
-                for($i=0; $i<$words; $i++) {
104
-                    $val  = (int)QRinput::lookAnTable(ord($this->data[$i*2  ])) * 45;
105
-                    $val += (int)QRinput::lookAnTable(ord($this->data[$i*2+1]));
103
+                for ($i = 0; $i < $words; $i++) {
104
+                    $val  = (int) QRinput::lookAnTable(ord($this->data[$i * 2])) * 45;
105
+                    $val += (int) QRinput::lookAnTable(ord($this->data[$i * 2 + 1]));
106 106
 
107 107
                     $bs->appendNum(11, $val);
108 108
                 }
109 109
 
110
-                if($this->size & 1) {
110
+                if ($this->size & 1) {
111 111
                     $val = QRinput::lookAnTable(ord($this->data[$words * 2]));
112 112
                     $bs->appendNum(6, $val);
113 113
                 }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                 $bs->appendNum(4, 0x4);
130 130
                 $bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size);
131 131
 
132
-                for($i=0; $i<$this->size; $i++) {
132
+                for ($i = 0; $i < $this->size; $i++) {
133 133
                     $bs->appendNum(8, ord($this->data[$i]));
134 134
                 }
135 135
 
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
                 $bs = new QRbitrtream();
150 150
                 
151 151
                 $bs->appendNum(4, 0x8);
152
-                $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2));
152
+                $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int) ($this->size / 2));
153 153
 
154
-                for($i=0; $i<$this->size; $i+=2) {
155
-                    $val = (ord($this->data[$i]) << 8) | ord($this->data[$i+1]);
156
-                    if($val <= 0x9ffc) {
154
+                for ($i = 0; $i < $this->size; $i += 2) {
155
+                    $val = (ord($this->data[$i]) << 8) | ord($this->data[$i + 1]);
156
+                    if ($val <= 0x9ffc) {
157 157
                         $val -= 0x8140;
158 158
                     } else {
159 159
                         $val -= 0xc140;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         public function encodeModeStructure()
178 178
         {
179 179
             try {
180
-                $bs =  new QRbitstream();
180
+                $bs = new QRbitstream();
181 181
                 
182 182
                 $bs->appendNum(4, 0x03);
183 183
                 $bs->appendNum(4, ord($this->data[1]) - 1);
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
         {
198 198
             $bits = 0;
199 199
 
200
-            if($version == 0) 
200
+            if ($version == 0) 
201 201
                 $version = 1;
202 202
 
203
-            switch($this->mode) {
204
-                case QR_MODE_NUM:        $bits = QRinput::estimateBitsModeNum($this->size);    break;
205
-                case QR_MODE_AN:        $bits = QRinput::estimateBitsModeAn($this->size);    break;
206
-                case QR_MODE_8:            $bits = QRinput::estimateBitsMode8($this->size);    break;
207
-                case QR_MODE_KANJI:        $bits = QRinput::estimateBitsModeKanji($this->size);break;
203
+            switch ($this->mode) {
204
+                case QR_MODE_NUM:        $bits = QRinput::estimateBitsModeNum($this->size); break;
205
+                case QR_MODE_AN:        $bits = QRinput::estimateBitsModeAn($this->size); break;
206
+                case QR_MODE_8:            $bits = QRinput::estimateBitsMode8($this->size); break;
207
+                case QR_MODE_KANJI:        $bits = QRinput::estimateBitsModeKanji($this->size); break;
208 208
                 case QR_MODE_STRUCTURE:    return STRUCTURE_HEADER_BITS;            
209 209
                 default:
210 210
                     return 0;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
             $l = QRspec::lengthIndicator($this->mode, $version);
214 214
             $m = 1 << $l;
215
-            $num = (int)(($this->size + $m - 1) / $m);
215
+            $num = (int) (($this->size + $m - 1) / $m);
216 216
 
217 217
             $bits += $num * (4 + $l);
218 218
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                 unset($this->bstream);
228 228
                 $words = QRspec::maximumWords($this->mode, $version);
229 229
                 
230
-                if($this->size > $words) {
230
+                if ($this->size > $words) {
231 231
                 
232 232
                     $st1 = new QRinputItem($this->mode, $words, $this->data);
233 233
                     $st2 = new QRinputItem($this->mode, $this->size - $words, array_slice($this->data, $words));
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
                     
247 247
                     $ret = 0;
248 248
                     
249
-                    switch($this->mode) {
250
-                        case QR_MODE_NUM:        $ret = $this->encodeModeNum($version);    break;
251
-                        case QR_MODE_AN:        $ret = $this->encodeModeAn($version);    break;
252
-                        case QR_MODE_8:            $ret = $this->encodeMode8($version);    break;
253
-                        case QR_MODE_KANJI:        $ret = $this->encodeModeKanji($version);break;
254
-                        case QR_MODE_STRUCTURE:    $ret = $this->encodeModeStructure();    break;
249
+                    switch ($this->mode) {
250
+                        case QR_MODE_NUM:        $ret = $this->encodeModeNum($version); break;
251
+                        case QR_MODE_AN:        $ret = $this->encodeModeAn($version); break;
252
+                        case QR_MODE_8:            $ret = $this->encodeMode8($version); break;
253
+                        case QR_MODE_KANJI:        $ret = $this->encodeModeKanji($version); break;
254
+                        case QR_MODE_STRUCTURE:    $ret = $this->encodeModeStructure(); break;
255 255
                         
256 256
                         default:
257 257
                             break;
258 258
                     }
259 259
                     
260
-                    if($ret < 0)
260
+                    if ($ret < 0)
261 261
                         return -1;
262 262
                 }
263 263
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         //----------------------------------------------------------------------
300 300
         public function setVersion($version)
301 301
         {
302
-            if($version < 0 || $version > QRSPEC_VERSION_MAX) {
302
+            if ($version < 0 || $version > QRSPEC_VERSION_MAX) {
303 303
                 throw new Exception('Invalid version no');
304 304
                 return -1;
305 305
             }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
         //----------------------------------------------------------------------
319 319
         public function setErrorCorrectionLevel($level)
320 320
         {
321
-            if($level > QR_ECLEVEL_H) {
321
+            if ($level > QR_ECLEVEL_H) {
322 322
                 throw new Exception('Invalid ECLEVEL');
323 323
                 return -1;
324 324
             }
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
         
351 351
         public function insertStructuredAppendHeader($size, $index, $parity)
352 352
         {
353
-            if( $size > MAX_STRUCTURED_SYMBOLS ) {
353
+            if ($size > MAX_STRUCTURED_SYMBOLS) {
354 354
                 throw new Exception('insertStructuredAppendHeader wrong size');
355 355
             }
356 356
             
357
-            if( $index <= 0 || $index > MAX_STRUCTURED_SYMBOLS ) {
357
+            if ($index <= 0 || $index > MAX_STRUCTURED_SYMBOLS) {
358 358
                 throw new Exception('insertStructuredAppendHeader wrong index');
359 359
             }
360 360
 
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
         {
375 375
             $parity = 0;
376 376
             
377
-            foreach($this->items as $item) {
378
-                if($item->mode != QR_MODE_STRUCTURE) {
379
-                    for($i=$item->size-1; $i>=0; $i--) {
377
+            foreach ($this->items as $item) {
378
+                if ($item->mode != QR_MODE_STRUCTURE) {
379
+                    for ($i = $item->size - 1; $i >= 0; $i--) {
380 380
                         $parity ^= $item->data[$i];
381 381
                     }
382 382
                 }
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
         //----------------------------------------------------------------------
389 389
         public static function checkModeNum($size, $data)
390 390
         {
391
-            for($i=0; $i<$size; $i++) {
392
-                if((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))){
391
+            for ($i = 0; $i < $size; $i++) {
392
+                if ((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))) {
393 393
                     return false;
394 394
                 }
395 395
             }
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
         //----------------------------------------------------------------------
401 401
         public static function estimateBitsModeNum($size)
402 402
         {
403
-            $w = (int)$size / 3;
403
+            $w = (int) $size / 3;
404 404
             $bits = $w * 10;
405 405
             
406
-            switch($size - $w * 3) {
406
+            switch ($size - $w * 3) {
407 407
                 case 1:
408 408
                     $bits += 4;
409 409
                     break;
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
             -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
423 423
             -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
424 424
             36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,
425
-             0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 44, -1, -1, -1, -1, -1,
425
+             0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,
426 426
             -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
427 427
             25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
428 428
             -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
         //----------------------------------------------------------------------
433 433
         public static function lookAnTable($c)
434 434
         {
435
-            return (($c > 127)?-1:self::$anTable[$c]);
435
+            return (($c > 127) ?-1 : self::$anTable[$c]);
436 436
         }
437 437
         
438 438
         //----------------------------------------------------------------------
439 439
         public static function checkModeAn($size, $data)
440 440
         {
441
-            for($i=0; $i<$size; $i++) {
441
+            for ($i = 0; $i < $size; $i++) {
442 442
                 if (self::lookAnTable(ord($data[$i])) == -1) {
443 443
                     return false;
444 444
                 }
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
         //----------------------------------------------------------------------
451 451
         public static function estimateBitsModeAn($size)
452 452
         {
453
-            $w = (int)($size / 2);
453
+            $w = (int) ($size / 2);
454 454
             $bits = $w * 11;
455 455
             
456
-            if($size & 1) {
456
+            if ($size & 1) {
457 457
                 $bits += 6;
458 458
             }
459 459
 
@@ -469,18 +469,18 @@  discard block
 block discarded – undo
469 469
         //----------------------------------------------------------------------
470 470
         public function estimateBitsModeKanji($size)
471 471
         {
472
-            return (int)(($size / 2) * 13);
472
+            return (int) (($size / 2) * 13);
473 473
         }
474 474
         
475 475
         //----------------------------------------------------------------------
476 476
         public static function checkModeKanji($size, $data)
477 477
         {
478
-            if($size & 1)
478
+            if ($size & 1)
479 479
                 return false;
480 480
 
481
-            for($i=0; $i<$size; $i+=2) {
482
-                $val = (ord($data[$i]) << 8) | ord($data[$i+1]);
483
-                if( $val < 0x8140 
481
+            for ($i = 0; $i < $size; $i += 2) {
482
+                $val = (ord($data[$i]) << 8) | ord($data[$i + 1]);
483
+                if ($val < 0x8140 
484 484
                 || ($val > 0x9ffc && $val < 0xe040) 
485 485
                 || $val > 0xebbf) {
486 486
                     return false;
@@ -496,12 +496,12 @@  discard block
 block discarded – undo
496 496
 
497 497
         public static function check($mode, $size, $data)
498 498
         {
499
-            if($size <= 0) 
499
+            if ($size <= 0) 
500 500
                 return false;
501 501
 
502
-            switch($mode) {
503
-                case QR_MODE_NUM:       return self::checkModeNum($size, $data);   break;
504
-                case QR_MODE_AN:        return self::checkModeAn($size, $data);    break;
502
+            switch ($mode) {
503
+                case QR_MODE_NUM:       return self::checkModeNum($size, $data); break;
504
+                case QR_MODE_AN:        return self::checkModeAn($size, $data); break;
505 505
                 case QR_MODE_KANJI:     return self::checkModeKanji($size, $data); break;
506 506
                 case QR_MODE_8:         return true; break;
507 507
                 case QR_MODE_STRUCTURE: return true; break;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         {
520 520
             $bits = 0;
521 521
 
522
-            foreach($this->items as $item) {
522
+            foreach ($this->items as $item) {
523 523
                 $bits += $item->estimateBitStreamSizeOfEntry($version);
524 524
             }
525 525
 
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
             do {
535 535
                 $prev = $version;
536 536
                 $bits = $this->estimateBitStreamSize($prev);
537
-                $version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
537
+                $version = QRspec::getMinimumVersion((int) (($bits + 7) / 8), $this->level);
538 538
                 if ($version < 0) {
539 539
                     return -1;
540 540
                 }
@@ -547,32 +547,32 @@  discard block
 block discarded – undo
547 547
         public static function lengthOfCode($mode, $version, $bits)
548 548
         {
549 549
             $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version);
550
-            switch($mode) {
550
+            switch ($mode) {
551 551
                 case QR_MODE_NUM:
552
-                    $chunks = (int)($payload / 10);
552
+                    $chunks = (int) ($payload / 10);
553 553
                     $remain = $payload - $chunks * 10;
554 554
                     $size = $chunks * 3;
555
-                    if($remain >= 7) {
555
+                    if ($remain >= 7) {
556 556
                         $size += 2;
557
-                    } else if($remain >= 4) {
557
+                    } else if ($remain >= 4) {
558 558
                         $size += 1;
559 559
                     }
560 560
                     break;
561 561
                 case QR_MODE_AN:
562
-                    $chunks = (int)($payload / 11);
562
+                    $chunks = (int) ($payload / 11);
563 563
                     $remain = $payload - $chunks * 11;
564 564
                     $size = $chunks * 2;
565
-                    if($remain >= 6) 
565
+                    if ($remain >= 6) 
566 566
                         $size++;
567 567
                     break;
568 568
                 case QR_MODE_8:
569
-                    $size = (int)($payload / 8);
569
+                    $size = (int) ($payload / 8);
570 570
                     break;
571 571
                 case QR_MODE_KANJI:
572
-                    $size = (int)(($payload / 13) * 2);
572
+                    $size = (int) (($payload / 13) * 2);
573 573
                     break;
574 574
                 case QR_MODE_STRUCTURE:
575
-                    $size = (int)($payload / 8);
575
+                    $size = (int) ($payload / 8);
576 576
                     break;
577 577
                 default:
578 578
                     $size = 0;
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
             }
581 581
             
582 582
             $maxsize = QRspec::maximumWords($mode, $version);
583
-            if($size < 0) $size = 0;
584
-            if($size > $maxsize) $size = $maxsize;
583
+            if ($size < 0) $size = 0;
584
+            if ($size > $maxsize) $size = $maxsize;
585 585
 
586 586
             return $size;
587 587
         }
@@ -591,10 +591,10 @@  discard block
 block discarded – undo
591 591
         {
592 592
             $total = 0;
593 593
 
594
-            foreach($this->items as $item) {
594
+            foreach ($this->items as $item) {
595 595
                 $bits = $item->encodeBitStream($this->version);
596 596
                 
597
-                if($bits < 0) 
597
+                if ($bits < 0) 
598 598
                     return -1;
599 599
                     
600 600
                 $total += $bits;
@@ -607,21 +607,21 @@  discard block
 block discarded – undo
607 607
         public function convertData()
608 608
         {
609 609
             $ver = $this->estimateVersion();
610
-            if($ver > $this->getVersion()) {
610
+            if ($ver > $this->getVersion()) {
611 611
                 $this->setVersion($ver);
612 612
             }
613 613
 
614
-            for(;;) {
614
+            for (;;) {
615 615
                 $bits = $this->createBitStream();
616 616
                 
617
-                if($bits < 0) 
617
+                if ($bits < 0) 
618 618
                     return -1;
619 619
                     
620
-                $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
621
-                if($ver < 0) {
620
+                $ver = QRspec::getMinimumVersion((int) (($bits + 7) / 8), $this->level);
621
+                if ($ver < 0) {
622 622
                     throw new Exception('WRONG VERSION');
623 623
                     return -1;
624
-                } else if($ver > $this->getVersion()) {
624
+                } else if ($ver > $this->getVersion()) {
625 625
                     $this->setVersion($ver);
626 626
                 } else {
627 627
                     break;
@@ -647,26 +647,26 @@  discard block
 block discarded – undo
647 647
             }
648 648
 
649 649
             $bits += 4;
650
-            $words = (int)(($bits + 7) / 8);
650
+            $words = (int) (($bits + 7) / 8);
651 651
 
652 652
             $padding = new QRbitstream();
653 653
             $ret = $padding->appendNum($words * 8 - $bits + 4, 0);
654 654
             
655
-            if($ret < 0) 
655
+            if ($ret < 0) 
656 656
                 return $ret;
657 657
 
658 658
             $padlen = $maxwords - $words;
659 659
             
660
-            if($padlen > 0) {
660
+            if ($padlen > 0) {
661 661
                 
662 662
                 $padbuf = array();
663
-                for($i=0; $i<$padlen; $i++) {
664
-                    $padbuf[$i] = ($i&1)?0x11:0xec;
663
+                for ($i = 0; $i < $padlen; $i++) {
664
+                    $padbuf[$i] = ($i & 1) ? 0x11 : 0xec;
665 665
                 }
666 666
                 
667 667
                 $ret = $padding->appendBytes($padlen, $padbuf);
668 668
                 
669
-                if($ret < 0)
669
+                if ($ret < 0)
670 670
                     return $ret;
671 671
                 
672 672
             }
@@ -679,15 +679,15 @@  discard block
 block discarded – undo
679 679
         //----------------------------------------------------------------------
680 680
         public function mergeBitStream()
681 681
         {
682
-            if($this->convertData() < 0) {
682
+            if ($this->convertData() < 0) {
683 683
                 return null;
684 684
             }
685 685
 
686 686
             $bstream = new QRbitstream();
687 687
             
688
-            foreach($this->items as $item) {
688
+            foreach ($this->items as $item) {
689 689
                 $ret = $bstream->append($item->bstream);
690
-                if($ret < 0) {
690
+                if ($ret < 0) {
691 691
                     return null;
692 692
                 }
693 693
             }
@@ -701,12 +701,12 @@  discard block
 block discarded – undo
701 701
 
702 702
             $bstream = $this->mergeBitStream();
703 703
             
704
-            if($bstream == null) {
704
+            if ($bstream == null) {
705 705
                 return null;
706 706
             }
707 707
             
708 708
             $ret = $this->appendPaddingBit($bstream);
709
-            if($ret < 0) {
709
+            if ($ret < 0) {
710 710
                 return null;
711 711
             }
712 712
 
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
         public function getByteStream()
718 718
         {
719 719
             $bstream = $this->getBitStream();
720
-            if($bstream == null) {
720
+            if ($bstream == null) {
721 721
                 return null;
722 722
             }
723 723
             
Please login to merge, or discard this patch.
lib/phpqrcode/qrspec.php 1 patch
Spacing   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -32,57 +32,57 @@  discard block
 block discarded – undo
32 32
  */
33 33
  
34 34
     define('QRSPEC_VERSION_MAX', 40);
35
-    define('QRSPEC_WIDTH_MAX',   177);
35
+    define('QRSPEC_WIDTH_MAX', 177);
36 36
 
37
-    define('QRCAP_WIDTH',        0);
38
-    define('QRCAP_WORDS',        1);
39
-    define('QRCAP_REMINDER',     2);
40
-    define('QRCAP_EC',           3);
37
+    define('QRCAP_WIDTH', 0);
38
+    define('QRCAP_WORDS', 1);
39
+    define('QRCAP_REMINDER', 2);
40
+    define('QRCAP_EC', 3);
41 41
 
42 42
     class QRspec {
43 43
     
44 44
         public static $capacity = array(
45
-            array(  0,    0, 0, array(   0,    0,    0,    0)),
46
-            array( 21,   26, 0, array(   7,   10,   13,   17)), // 1
47
-            array( 25,   44, 7, array(  10,   16,   22,   28)),
48
-            array( 29,   70, 7, array(  15,   26,   36,   44)),
49
-            array( 33,  100, 7, array(  20,   36,   52,   64)),
50
-            array( 37,  134, 7, array(  26,   48,   72,   88)), // 5
51
-            array( 41,  172, 7, array(  36,   64,   96,  112)),
52
-            array( 45,  196, 0, array(  40,   72,  108,  130)),
53
-            array( 49,  242, 0, array(  48,   88,  132,  156)),
54
-            array( 53,  292, 0, array(  60,  110,  160,  192)),
55
-            array( 57,  346, 0, array(  72,  130,  192,  224)), //10
56
-            array( 61,  404, 0, array(  80,  150,  224,  264)),
57
-            array( 65,  466, 0, array(  96,  176,  260,  308)),
58
-            array( 69,  532, 0, array( 104,  198,  288,  352)),
59
-            array( 73,  581, 3, array( 120,  216,  320,  384)),
60
-            array( 77,  655, 3, array( 132,  240,  360,  432)), //15
61
-            array( 81,  733, 3, array( 144,  280,  408,  480)),
62
-            array( 85,  815, 3, array( 168,  308,  448,  532)),
63
-            array( 89,  901, 3, array( 180,  338,  504,  588)),
64
-            array( 93,  991, 3, array( 196,  364,  546,  650)),
65
-            array( 97, 1085, 3, array( 224,  416,  600,  700)), //20
66
-            array(101, 1156, 4, array( 224,  442,  644,  750)),
67
-            array(105, 1258, 4, array( 252,  476,  690,  816)),
68
-            array(109, 1364, 4, array( 270,  504,  750,  900)),
69
-            array(113, 1474, 4, array( 300,  560,  810,  960)),
70
-            array(117, 1588, 4, array( 312,  588,  870, 1050)), //25
71
-            array(121, 1706, 4, array( 336,  644,  952, 1110)),
72
-            array(125, 1828, 4, array( 360,  700, 1020, 1200)),
73
-            array(129, 1921, 3, array( 390,  728, 1050, 1260)),
74
-            array(133, 2051, 3, array( 420,  784, 1140, 1350)),
75
-            array(137, 2185, 3, array( 450,  812, 1200, 1440)), //30
76
-            array(141, 2323, 3, array( 480,  868, 1290, 1530)),
77
-            array(145, 2465, 3, array( 510,  924, 1350, 1620)),
78
-            array(149, 2611, 3, array( 540,  980, 1440, 1710)),
79
-            array(153, 2761, 3, array( 570, 1036, 1530, 1800)),
80
-            array(157, 2876, 0, array( 570, 1064, 1590, 1890)), //35
81
-            array(161, 3034, 0, array( 600, 1120, 1680, 1980)),
82
-            array(165, 3196, 0, array( 630, 1204, 1770, 2100)),
83
-            array(169, 3362, 0, array( 660, 1260, 1860, 2220)),
84
-            array(173, 3532, 0, array( 720, 1316, 1950, 2310)),
85
-            array(177, 3706, 0, array( 750, 1372, 2040, 2430)) //40
45
+            array(0, 0, 0, array(0, 0, 0, 0)),
46
+            array(21, 26, 0, array(7, 10, 13, 17)), // 1
47
+            array(25, 44, 7, array(10, 16, 22, 28)),
48
+            array(29, 70, 7, array(15, 26, 36, 44)),
49
+            array(33, 100, 7, array(20, 36, 52, 64)),
50
+            array(37, 134, 7, array(26, 48, 72, 88)), // 5
51
+            array(41, 172, 7, array(36, 64, 96, 112)),
52
+            array(45, 196, 0, array(40, 72, 108, 130)),
53
+            array(49, 242, 0, array(48, 88, 132, 156)),
54
+            array(53, 292, 0, array(60, 110, 160, 192)),
55
+            array(57, 346, 0, array(72, 130, 192, 224)), //10
56
+            array(61, 404, 0, array(80, 150, 224, 264)),
57
+            array(65, 466, 0, array(96, 176, 260, 308)),
58
+            array(69, 532, 0, array(104, 198, 288, 352)),
59
+            array(73, 581, 3, array(120, 216, 320, 384)),
60
+            array(77, 655, 3, array(132, 240, 360, 432)), //15
61
+            array(81, 733, 3, array(144, 280, 408, 480)),
62
+            array(85, 815, 3, array(168, 308, 448, 532)),
63
+            array(89, 901, 3, array(180, 338, 504, 588)),
64
+            array(93, 991, 3, array(196, 364, 546, 650)),
65
+            array(97, 1085, 3, array(224, 416, 600, 700)), //20
66
+            array(101, 1156, 4, array(224, 442, 644, 750)),
67
+            array(105, 1258, 4, array(252, 476, 690, 816)),
68
+            array(109, 1364, 4, array(270, 504, 750, 900)),
69
+            array(113, 1474, 4, array(300, 560, 810, 960)),
70
+            array(117, 1588, 4, array(312, 588, 870, 1050)), //25
71
+            array(121, 1706, 4, array(336, 644, 952, 1110)),
72
+            array(125, 1828, 4, array(360, 700, 1020, 1200)),
73
+            array(129, 1921, 3, array(390, 728, 1050, 1260)),
74
+            array(133, 2051, 3, array(420, 784, 1140, 1350)),
75
+            array(137, 2185, 3, array(450, 812, 1200, 1440)), //30
76
+            array(141, 2323, 3, array(480, 868, 1290, 1530)),
77
+            array(145, 2465, 3, array(510, 924, 1350, 1620)),
78
+            array(149, 2611, 3, array(540, 980, 1440, 1710)),
79
+            array(153, 2761, 3, array(570, 1036, 1530, 1800)),
80
+            array(157, 2876, 0, array(570, 1064, 1590, 1890)), //35
81
+            array(161, 3034, 0, array(600, 1120, 1680, 1980)),
82
+            array(165, 3196, 0, array(630, 1204, 1770, 2100)),
83
+            array(169, 3362, 0, array(660, 1260, 1860, 2220)),
84
+            array(173, 3532, 0, array(720, 1316, 1950, 2310)),
85
+            array(177, 3706, 0, array(750, 1372, 2040, 2430)) //40
86 86
         );
87 87
         
88 88
         //----------------------------------------------------------------------
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
         public static function getMinimumVersion($size, $level)
114 114
         {
115 115
 
116
-            for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) {
117
-                $words  = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level];
118
-                if($words >= $size) 
116
+            for ($i = 1; $i <= QRSPEC_VERSION_MAX; $i++) {
117
+                $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level];
118
+                if ($words >= $size) 
119 119
                     return $i;
120 120
             }
121 121
 
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
         
127 127
         public static $lengthTableBits = array(
128 128
             array(10, 12, 14),
129
-            array( 9, 11, 13),
130
-            array( 8, 16, 16),
131
-            array( 8, 10, 12)
129
+            array(9, 11, 13),
130
+            array(8, 16, 16),
131
+            array(8, 10, 12)
132 132
         );
133 133
         
134 134
         //----------------------------------------------------------------------
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
         //----------------------------------------------------------------------
152 152
         public static function maximumWords($mode, $version)
153 153
         {
154
-            if($mode == QR_MODE_STRUCTURE) 
154
+            if ($mode == QR_MODE_STRUCTURE) 
155 155
                 return 3;
156 156
                 
157
-            if($version <= 9) {
157
+            if ($version <= 9) {
158 158
                 $l = 0;
159
-            } else if($version <= 26) {
159
+            } else if ($version <= 26) {
160 160
                 $l = 1;
161 161
             } else {
162 162
                 $l = 2;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             $bits = self::$lengthTableBits[$mode][$l];
166 166
             $words = (1 << $bits) - 1;
167 167
             
168
-            if($mode == QR_MODE_KANJI) {
168
+            if ($mode == QR_MODE_KANJI) {
169 169
                 $words *= 2; // the number of bytes is required
170 170
             }
171 171
 
@@ -177,47 +177,47 @@  discard block
 block discarded – undo
177 177
         // See Table 12-16 (pp.30-36), JIS X0510:2004.
178 178
 
179 179
         public static $eccTable = array(
180
-            array(array( 0,  0), array( 0,  0), array( 0,  0), array( 0,  0)),
181
-            array(array( 1,  0), array( 1,  0), array( 1,  0), array( 1,  0)), // 1
182
-            array(array( 1,  0), array( 1,  0), array( 1,  0), array( 1,  0)),
183
-            array(array( 1,  0), array( 1,  0), array( 2,  0), array( 2,  0)),
184
-            array(array( 1,  0), array( 2,  0), array( 2,  0), array( 4,  0)),
185
-            array(array( 1,  0), array( 2,  0), array( 2,  2), array( 2,  2)), // 5
186
-            array(array( 2,  0), array( 4,  0), array( 4,  0), array( 4,  0)),
187
-            array(array( 2,  0), array( 4,  0), array( 2,  4), array( 4,  1)),
188
-            array(array( 2,  0), array( 2,  2), array( 4,  2), array( 4,  2)),
189
-            array(array( 2,  0), array( 3,  2), array( 4,  4), array( 4,  4)),
190
-            array(array( 2,  2), array( 4,  1), array( 6,  2), array( 6,  2)), //10
191
-            array(array( 4,  0), array( 1,  4), array( 4,  4), array( 3,  8)),
192
-            array(array( 2,  2), array( 6,  2), array( 4,  6), array( 7,  4)),
193
-            array(array( 4,  0), array( 8,  1), array( 8,  4), array(12,  4)),
194
-            array(array( 3,  1), array( 4,  5), array(11,  5), array(11,  5)),
195
-            array(array( 5,  1), array( 5,  5), array( 5,  7), array(11,  7)), //15
196
-            array(array( 5,  1), array( 7,  3), array(15,  2), array( 3, 13)),
197
-            array(array( 1,  5), array(10,  1), array( 1, 15), array( 2, 17)),
198
-            array(array( 5,  1), array( 9,  4), array(17,  1), array( 2, 19)),
199
-            array(array( 3,  4), array( 3, 11), array(17,  4), array( 9, 16)),
200
-            array(array( 3,  5), array( 3, 13), array(15,  5), array(15, 10)), //20
201
-            array(array( 4,  4), array(17,  0), array(17,  6), array(19,  6)),
202
-            array(array( 2,  7), array(17,  0), array( 7, 16), array(34,  0)),
203
-            array(array( 4,  5), array( 4, 14), array(11, 14), array(16, 14)),
204
-            array(array( 6,  4), array( 6, 14), array(11, 16), array(30,  2)),
205
-            array(array( 8,  4), array( 8, 13), array( 7, 22), array(22, 13)), //25
206
-            array(array(10,  2), array(19,  4), array(28,  6), array(33,  4)),
207
-            array(array( 8,  4), array(22,  3), array( 8, 26), array(12, 28)),
208
-            array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)),
209
-            array(array( 7,  7), array(21,  7), array( 1, 37), array(19, 26)),
210
-            array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), //30
211
-            array(array(13,  3), array( 2, 29), array(42,  1), array(23, 28)),
212
-            array(array(17,  0), array(10, 23), array(10, 35), array(19, 35)),
213
-            array(array(17,  1), array(14, 21), array(29, 19), array(11, 46)),
214
-            array(array(13,  6), array(14, 23), array(44,  7), array(59,  1)),
215
-            array(array(12,  7), array(12, 26), array(39, 14), array(22, 41)), //35
216
-            array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)),
217
-            array(array(17,  4), array(29, 14), array(49, 10), array(24, 46)),
218
-            array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)),
219
-            array(array(20,  4), array(40,  7), array(43, 22), array(10, 67)),
220
-            array(array(19,  6), array(18, 31), array(34, 34), array(20, 61)),//40
180
+            array(array(0, 0), array(0, 0), array(0, 0), array(0, 0)),
181
+            array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), // 1
182
+            array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)),
183
+            array(array(1, 0), array(1, 0), array(2, 0), array(2, 0)),
184
+            array(array(1, 0), array(2, 0), array(2, 0), array(4, 0)),
185
+            array(array(1, 0), array(2, 0), array(2, 2), array(2, 2)), // 5
186
+            array(array(2, 0), array(4, 0), array(4, 0), array(4, 0)),
187
+            array(array(2, 0), array(4, 0), array(2, 4), array(4, 1)),
188
+            array(array(2, 0), array(2, 2), array(4, 2), array(4, 2)),
189
+            array(array(2, 0), array(3, 2), array(4, 4), array(4, 4)),
190
+            array(array(2, 2), array(4, 1), array(6, 2), array(6, 2)), //10
191
+            array(array(4, 0), array(1, 4), array(4, 4), array(3, 8)),
192
+            array(array(2, 2), array(6, 2), array(4, 6), array(7, 4)),
193
+            array(array(4, 0), array(8, 1), array(8, 4), array(12, 4)),
194
+            array(array(3, 1), array(4, 5), array(11, 5), array(11, 5)),
195
+            array(array(5, 1), array(5, 5), array(5, 7), array(11, 7)), //15
196
+            array(array(5, 1), array(7, 3), array(15, 2), array(3, 13)),
197
+            array(array(1, 5), array(10, 1), array(1, 15), array(2, 17)),
198
+            array(array(5, 1), array(9, 4), array(17, 1), array(2, 19)),
199
+            array(array(3, 4), array(3, 11), array(17, 4), array(9, 16)),
200
+            array(array(3, 5), array(3, 13), array(15, 5), array(15, 10)), //20
201
+            array(array(4, 4), array(17, 0), array(17, 6), array(19, 6)),
202
+            array(array(2, 7), array(17, 0), array(7, 16), array(34, 0)),
203
+            array(array(4, 5), array(4, 14), array(11, 14), array(16, 14)),
204
+            array(array(6, 4), array(6, 14), array(11, 16), array(30, 2)),
205
+            array(array(8, 4), array(8, 13), array(7, 22), array(22, 13)), //25
206
+            array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)),
207
+            array(array(8, 4), array(22, 3), array(8, 26), array(12, 28)),
208
+            array(array(3, 10), array(3, 23), array(4, 31), array(11, 31)),
209
+            array(array(7, 7), array(21, 7), array(1, 37), array(19, 26)),
210
+            array(array(5, 10), array(19, 10), array(15, 25), array(23, 25)), //30
211
+            array(array(13, 3), array(2, 29), array(42, 1), array(23, 28)),
212
+            array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)),
213
+            array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)),
214
+            array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)),
215
+            array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), //35
216
+            array(array(6, 14), array(6, 34), array(46, 10), array(2, 64)),
217
+            array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)),
218
+            array(array(4, 18), array(13, 32), array(48, 14), array(42, 32)),
219
+            array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)),
220
+            array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)), //40
221 221
         );                                                                       
222 222
 
223 223
         //----------------------------------------------------------------------
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         public static function getEccSpec($version, $level, array &$spec)
227 227
         {
228 228
             if (count($spec) < 5) {
229
-                $spec = array(0,0,0,0,0);
229
+                $spec = array(0, 0, 0, 0, 0);
230 230
             }
231 231
 
232 232
             $b1   = self::$eccTable[$version][$level][0];
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
             $data = self::getDataLength($version, $level);
235 235
             $ecc  = self::getECCLength($version, $level);
236 236
 
237
-            if($b2 == 0) {
237
+            if ($b2 == 0) {
238 238
                 $spec[0] = $b1;
239
-                $spec[1] = (int)($data / $b1);
240
-                $spec[2] = (int)($ecc / $b1);
239
+                $spec[1] = (int) ($data / $b1);
240
+                $spec[2] = (int) ($ecc / $b1);
241 241
                 $spec[3] = 0; 
242 242
                 $spec[4] = 0;
243 243
             } else {
244 244
                 $spec[0] = $b1;
245
-                $spec[1] = (int)($data / ($b1 + $b2));
246
-                $spec[2] = (int)($ecc  / ($b1 + $b2));
245
+                $spec[1] = (int) ($data / ($b1 + $b2));
246
+                $spec[2] = (int) ($ecc / ($b1 + $b2));
247 247
                 $spec[3] = $b2;
248 248
                 $spec[4] = $spec[1] + 1;
249 249
             }
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
         // See Table 1 in Appendix E (pp.71) of JIS X0510:2004.
260 260
          
261 261
         public static $alignmentPattern = array(      
262
-            array( 0,  0),
263
-            array( 0,  0), array(18,  0), array(22,  0), array(26,  0), array(30,  0), // 1- 5
264
-            array(34,  0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10
262
+            array(0, 0),
263
+            array(0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5
264
+            array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10
265 265
             array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), //11-15
266 266
             array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), //16-20
267 267
             array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), //21-25
@@ -287,28 +287,28 @@  discard block
 block discarded – undo
287 287
                 "\xa1\xa1\xa1\xa1\xa1"
288 288
             );                        
289 289
             
290
-            $yStart = $oy-2;         
291
-            $xStart = $ox-2;
290
+            $yStart = $oy - 2;         
291
+            $xStart = $ox - 2;
292 292
             
293
-            for($y=0; $y<5; $y++) {
294
-                QRstr::set($frame, $xStart, $yStart+$y, $finder[$y]);
293
+            for ($y = 0; $y < 5; $y++) {
294
+                QRstr::set($frame, $xStart, $yStart + $y, $finder[$y]);
295 295
             }
296 296
         }
297 297
 
298 298
         //----------------------------------------------------------------------
299 299
         public static function putAlignmentPattern($version, &$frame, $width)
300 300
         {
301
-            if($version < 2)
301
+            if ($version < 2)
302 302
                 return;
303 303
 
304 304
             $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0];
305
-            if($d < 0) {
305
+            if ($d < 0) {
306 306
                 $w = 2;
307 307
             } else {
308
-                $w = (int)(($width - self::$alignmentPattern[$version][0]) / $d + 2);
308
+                $w = (int) (($width - self::$alignmentPattern[$version][0]) / $d + 2);
309 309
             }
310 310
 
311
-            if($w * $w - 3 == 1) {
311
+            if ($w * $w - 3 == 1) {
312 312
                 $x = self::$alignmentPattern[$version][0];
313 313
                 $y = self::$alignmentPattern[$version][0];
314 314
                 self::putAlignmentMarker($frame, $x, $y);
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
             }
317 317
 
318 318
             $cx = self::$alignmentPattern[$version][0];
319
-            for($x=1; $x<$w - 1; $x++) {
319
+            for ($x = 1; $x < $w - 1; $x++) {
320 320
                 self::putAlignmentMarker($frame, 6, $cx);
321
-                self::putAlignmentMarker($frame, $cx,  6);
321
+                self::putAlignmentMarker($frame, $cx, 6);
322 322
                 $cx += $d;
323 323
             }
324 324
 
325 325
             $cy = self::$alignmentPattern[$version][0];
326
-            for($y=0; $y<$w-1; $y++) {
326
+            for ($y = 0; $y < $w - 1; $y++) {
327 327
                 $cx = self::$alignmentPattern[$version][0];
328
-                for($x=0; $x<$w-1; $x++) {
328
+                for ($x = 0; $x < $w - 1; $x++) {
329 329
                     self::putAlignmentMarker($frame, $cx, $cy);
330 330
                     $cx += $d;
331 331
                 }
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
         //----------------------------------------------------------------------
352 352
         public static function getVersionPattern($version)
353 353
         {
354
-            if($version < 7 || $version > QRSPEC_VERSION_MAX)
354
+            if ($version < 7 || $version > QRSPEC_VERSION_MAX)
355 355
                 return 0;
356 356
 
357
-            return self::$versionPattern[$version -7];
357
+            return self::$versionPattern[$version - 7];
358 358
         }
359 359
 
360 360
         // Format information --------------------------------------------------
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
 
370 370
         public static function getFormatInfo($mask, $level)
371 371
         {
372
-            if($mask < 0 || $mask > 7)
372
+            if ($mask < 0 || $mask > 7)
373 373
                 return 0;
374 374
                 
375
-            if($level < 0 || $level > 3)
375
+            if ($level < 0 || $level > 3)
376 376
                 return 0;                
377 377
 
378 378
             return self::$formatInfo[$level][$mask];
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
                 "\xc1\xc1\xc1\xc1\xc1\xc1\xc1"
402 402
             );                            
403 403
             
404
-            for($y=0; $y<7; $y++) {
405
-                QRstr::set($frame, $ox, $oy+$y, $finder[$y]);
404
+            for ($y = 0; $y < 7; $y++) {
405
+                QRstr::set($frame, $ox, $oy + $y, $finder[$y]);
406 406
             }
407 407
         }
408 408
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
         public static function createFrame($version)
411 411
         {
412 412
             $width = self::$capacity[$version][QRCAP_WIDTH];
413
-            $frameLine = str_repeat ("\0", $width);
413
+            $frameLine = str_repeat("\0", $width);
414 414
             $frame = array_fill(0, $width, $frameLine);
415 415
 
416 416
             // Finder pattern
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
             // Separator
422 422
             $yOffset = $width - 7;
423 423
             
424
-            for($y=0; $y<7; $y++) {
424
+            for ($y = 0; $y < 7; $y++) {
425 425
                 $frame[$y][7] = "\xc0";
426 426
                 $frame[$y][$width - 8] = "\xc0";
427 427
                 $frame[$yOffset][7] = "\xc0";
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
             $setPattern = str_repeat("\xc0", 8);
432 432
             
433 433
             QRstr::set($frame, 0, 7, $setPattern);
434
-            QRstr::set($frame, $width-8, 7, $setPattern);
434
+            QRstr::set($frame, $width - 8, 7, $setPattern);
435 435
             QRstr::set($frame, 0, $width - 8, $setPattern);
436 436
         
437 437
             // Format info
@@ -441,38 +441,38 @@  discard block
 block discarded – undo
441 441
             
442 442
             $yOffset = $width - 8;
443 443
 
444
-            for($y=0; $y<8; $y++,$yOffset++) {
444
+            for ($y = 0; $y < 8; $y++, $yOffset++) {
445 445
                 $frame[$y][8] = "\x84";
446 446
                 $frame[$yOffset][8] = "\x84";
447 447
             }
448 448
 
449 449
             // Timing pattern  
450 450
             
451
-            for($i=1; $i<$width-15; $i++) {
452
-                $frame[6][7+$i] = chr(0x90 | ($i & 1));
453
-                $frame[7+$i][6] = chr(0x90 | ($i & 1));
451
+            for ($i = 1; $i < $width - 15; $i++) {
452
+                $frame[6][7 + $i] = chr(0x90 | ($i & 1));
453
+                $frame[7 + $i][6] = chr(0x90 | ($i & 1));
454 454
             }
455 455
             
456 456
             // Alignment pattern  
457 457
             self::putAlignmentPattern($version, $frame, $width);
458 458
             
459 459
             // Version information 
460
-            if($version >= 7) {
460
+            if ($version >= 7) {
461 461
                 $vinf = self::getVersionPattern($version);
462 462
 
463 463
                 $v = $vinf;
464 464
                 
465
-                for($x=0; $x<6; $x++) {
466
-                    for($y=0; $y<3; $y++) {
467
-                        $frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));
465
+                for ($x = 0; $x < 6; $x++) {
466
+                    for ($y = 0; $y < 3; $y++) {
467
+                        $frame[($width - 11) + $y][$x] = chr(0x88 | ($v & 1));
468 468
                         $v = $v >> 1;
469 469
                     }
470 470
                 }
471 471
 
472 472
                 $v = $vinf;
473
-                for($y=0; $y<6; $y++) {
474
-                    for($x=0; $x<3; $x++) {
475
-                        $frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1));
473
+                for ($y = 0; $y < 6; $y++) {
474
+                    for ($x = 0; $x < 3; $x++) {
475
+                        $frame[$y][$x + ($width - 11)] = chr(0x88 | ($v & 1));
476 476
                         $v = $v >> 1;
477 477
                     }
478 478
                 }
@@ -506,16 +506,16 @@  discard block
 block discarded – undo
506 506
             } else {
507 507
             
508 508
                 foreach ($frame as &$frameLine) {
509
-                    $frameLine = join('<span class="m">&nbsp;</span>',  explode("\xc0", $frameLine));
509
+                    $frameLine = join('<span class="m">&nbsp;</span>', explode("\xc0", $frameLine));
510 510
                     $frameLine = join('<span class="m">&#9618;</span>', explode("\xc1", $frameLine));
511
-                    $frameLine = join('<span class="p">&nbsp;</span>',  explode("\xa0", $frameLine));
511
+                    $frameLine = join('<span class="p">&nbsp;</span>', explode("\xa0", $frameLine));
512 512
                     $frameLine = join('<span class="p">&#9618;</span>', explode("\xa1", $frameLine));
513 513
                     $frameLine = join('<span class="s">&#9671;</span>', explode("\x84", $frameLine)); //format 0
514 514
                     $frameLine = join('<span class="s">&#9670;</span>', explode("\x85", $frameLine)); //format 1
515 515
                     $frameLine = join('<span class="x">&#9762;</span>', explode("\x81", $frameLine)); //special bit
516
-                    $frameLine = join('<span class="c">&nbsp;</span>',  explode("\x90", $frameLine)); //clock 0
516
+                    $frameLine = join('<span class="c">&nbsp;</span>', explode("\x90", $frameLine)); //clock 0
517 517
                     $frameLine = join('<span class="c">&#9719;</span>', explode("\x91", $frameLine)); //clock 1
518
-                    $frameLine = join('<span class="f">&nbsp;</span>',  explode("\x88", $frameLine)); //version
518
+                    $frameLine = join('<span class="f">&nbsp;</span>', explode("\x88", $frameLine)); //version
519 519
                     $frameLine = join('<span class="f">&#9618;</span>', explode("\x89", $frameLine)); //version
520 520
                     $frameLine = join('&#9830;', explode("\x01", $frameLine));
521 521
                     $frameLine = join('&#8901;', explode("\0", $frameLine));
@@ -553,10 +553,10 @@  discard block
 block discarded – undo
553 553
         //----------------------------------------------------------------------
554 554
         public static function newFrame($version)
555 555
         {
556
-            if($version < 1 || $version > QRSPEC_VERSION_MAX) 
556
+            if ($version < 1 || $version > QRSPEC_VERSION_MAX) 
557 557
                 return null;
558 558
 
559
-            if(!isset(self::$frames[$version])) {
559
+            if (!isset(self::$frames[$version])) {
560 560
                 
561 561
                 $fileName = QR_CACHE_DIR.'frame_'.$version.'.dat';
562 562
                 
@@ -572,21 +572,21 @@  discard block
 block discarded – undo
572 572
                 }
573 573
             }
574 574
             
575
-            if(is_null(self::$frames[$version]))
575
+            if (is_null(self::$frames[$version]))
576 576
                 return null;
577 577
 
578 578
             return self::$frames[$version];
579 579
         }
580 580
 
581 581
         //----------------------------------------------------------------------
582
-        public static function rsBlockNum($spec)     { return $spec[0] + $spec[3]; }
583
-        public static function rsBlockNum1($spec)    { return $spec[0]; }
584
-        public static function rsDataCodes1($spec)   { return $spec[1]; }
585
-        public static function rsEccCodes1($spec)    { return $spec[2]; }
586
-        public static function rsBlockNum2($spec)    { return $spec[3]; }
587
-        public static function rsDataCodes2($spec)   { return $spec[4]; }
588
-        public static function rsEccCodes2($spec)    { return $spec[2]; }
589
-        public static function rsDataLength($spec)   { return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]);    }
590
-        public static function rsEccLength($spec)    { return ($spec[0] + $spec[3]) * $spec[2]; }
582
+        public static function rsBlockNum($spec) { return $spec[0] + $spec[3]; }
583
+        public static function rsBlockNum1($spec) { return $spec[0]; }
584
+        public static function rsDataCodes1($spec) { return $spec[1]; }
585
+        public static function rsEccCodes1($spec) { return $spec[2]; }
586
+        public static function rsBlockNum2($spec) { return $spec[3]; }
587
+        public static function rsDataCodes2($spec) { return $spec[4]; }
588
+        public static function rsEccCodes2($spec) { return $spec[2]; }
589
+        public static function rsDataLength($spec) { return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]); }
590
+        public static function rsEccLength($spec) { return ($spec[0] + $spec[3]) * $spec[2]; }
591 591
         
592 592
     }
593 593
\ No newline at end of file
Please login to merge, or discard this patch.
lib/phpqrcode/qrmask.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
         public function writeFormatInformation($width, &$frame, $mask, $level)
45 45
         {
46 46
             $blacks = 0;
47
-            $format =  QRspec::getFormatInfo($mask, $level);
47
+            $format = QRspec::getFormatInfo($mask, $level);
48 48
 
49
-            for($i=0; $i<8; $i++) {
50
-                if($format & 1) {
49
+            for ($i = 0; $i < 8; $i++) {
50
+                if ($format & 1) {
51 51
                     $blacks += 2;
52 52
                     $v = 0x85;
53 53
                 } else {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                 }
56 56
                 
57 57
                 $frame[8][$width - 1 - $i] = chr($v);
58
-                if($i < 6) {
58
+                if ($i < 6) {
59 59
                     $frame[$i][8] = chr($v);
60 60
                 } else {
61 61
                     $frame[$i + 1][8] = chr($v);
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
                 $format = $format >> 1;
64 64
             }
65 65
             
66
-            for($i=0; $i<7; $i++) {
67
-                if($format & 1) {
66
+            for ($i = 0; $i < 7; $i++) {
67
+                if ($format & 1) {
68 68
                     $blacks += 2;
69 69
                     $v = 0x85;
70 70
                 } else {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 }
73 73
                 
74 74
                 $frame[$width - 7 + $i][8] = chr($v);
75
-                if($i == 0) {
75
+                if ($i == 0) {
76 76
                     $frame[8][7] = chr($v);
77 77
                 } else {
78 78
                     $frame[8][6 - $i] = chr($v);
@@ -85,27 +85,27 @@  discard block
 block discarded – undo
85 85
         }
86 86
         
87 87
         //----------------------------------------------------------------------
88
-        public function mask0($x, $y) { return ($x+$y)&1;                       }
89
-        public function mask1($x, $y) { return ($y&1);                          }
90
-        public function mask2($x, $y) { return ($x%3);                          }
91
-        public function mask3($x, $y) { return ($x+$y)%3;                       }
92
-        public function mask4($x, $y) { return (((int)($y/2))+((int)($x/3)))&1; }
93
-        public function mask5($x, $y) { return (($x*$y)&1)+($x*$y)%3;           }
94
-        public function mask6($x, $y) { return ((($x*$y)&1)+($x*$y)%3)&1;       }
95
-        public function mask7($x, $y) { return ((($x*$y)%3)+(($x+$y)&1))&1;     }
88
+        public function mask0($x, $y) { return ($x + $y) & 1; }
89
+        public function mask1($x, $y) { return ($y & 1); }
90
+        public function mask2($x, $y) { return ($x % 3); }
91
+        public function mask3($x, $y) { return ($x + $y) % 3; }
92
+        public function mask4($x, $y) { return (((int) ($y / 2)) + ((int) ($x / 3))) & 1; }
93
+        public function mask5($x, $y) { return (($x * $y) & 1) + ($x * $y) % 3; }
94
+        public function mask6($x, $y) { return ((($x * $y) & 1) + ($x * $y) % 3) & 1; }
95
+        public function mask7($x, $y) { return ((($x * $y) % 3) + (($x + $y) & 1)) & 1; }
96 96
         
97 97
         //----------------------------------------------------------------------
98 98
         private function generateMaskNo($maskNo, $width, $frame)
99 99
         {
100 100
             $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
101 101
             
102
-            for($y=0; $y<$width; $y++) {
103
-                for($x=0; $x<$width; $x++) {
104
-                    if(ord($frame[$y][$x]) & 0x80) {
102
+            for ($y = 0; $y < $width; $y++) {
103
+                for ($x = 0; $x < $width; $x++) {
104
+                    if (ord($frame[$y][$x]) & 0x80) {
105 105
                         $bitMask[$y][$x] = 0;
106 106
                     } else {
107 107
                         $maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y);
108
-                        $bitMask[$y][$x] = ($maskFunc == 0)?1:0;
108
+                        $bitMask[$y][$x] = ($maskFunc == 0) ? 1 : 0;
109 109
                     }
110 110
                     
111 111
                 }
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
                 
164 164
             $d = $s;
165 165
 
166
-            for($y=0; $y<$width; $y++) {
167
-                for($x=0; $x<$width; $x++) {
168
-                    if($bitMask[$y][$x] == 1) {
169
-                        $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]);
166
+            for ($y = 0; $y < $width; $y++) {
167
+                for ($x = 0; $x < $width; $x++) {
168
+                    if ($bitMask[$y][$x] == 1) {
169
+                        $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int) $bitMask[$y][$x]);
170 170
                     }
171
-                    $b += (int)(ord($d[$y][$x]) & 1);
171
+                    $b += (int) (ord($d[$y][$x]) & 1);
172 172
                 }
173 173
             }
174 174
 
@@ -190,21 +190,21 @@  discard block
 block discarded – undo
190 190
         {
191 191
             $demerit = 0;
192 192
 
193
-            for($i=0; $i<$length; $i++) {
193
+            for ($i = 0; $i < $length; $i++) {
194 194
                 
195
-                if($this->runLength[$i] >= 5) {
195
+                if ($this->runLength[$i] >= 5) {
196 196
                     $demerit += (N1 + ($this->runLength[$i] - 5));
197 197
                 }
198
-                if($i & 1) {
199
-                    if(($i >= 3) && ($i < ($length-2)) && ($this->runLength[$i] % 3 == 0)) {
200
-                        $fact = (int)($this->runLength[$i] / 3);
201
-                        if(($this->runLength[$i-2] == $fact) &&
202
-                           ($this->runLength[$i-1] == $fact) &&
203
-                           ($this->runLength[$i+1] == $fact) &&
204
-                           ($this->runLength[$i+2] == $fact)) {
205
-                            if(($this->runLength[$i-3] < 0) || ($this->runLength[$i-3] >= (4 * $fact))) {
198
+                if ($i & 1) {
199
+                    if (($i >= 3) && ($i < ($length - 2)) && ($this->runLength[$i] % 3 == 0)) {
200
+                        $fact = (int) ($this->runLength[$i] / 3);
201
+                        if (($this->runLength[$i - 2] == $fact) &&
202
+                           ($this->runLength[$i - 1] == $fact) &&
203
+                           ($this->runLength[$i + 1] == $fact) &&
204
+                           ($this->runLength[$i + 2] == $fact)) {
205
+                            if (($this->runLength[$i - 3] < 0) || ($this->runLength[$i - 3] >= (4 * $fact))) {
206 206
                                 $demerit += N3;
207
-                            } else if((($i+3) >= $length) || ($this->runLength[$i+3] >= (4 * $fact))) {
207
+                            } else if ((($i + 3) >= $length) || ($this->runLength[$i + 3] >= (4 * $fact))) {
208 208
                                 $demerit += N3;
209 209
                             }
210 210
                         }
@@ -220,30 +220,30 @@  discard block
 block discarded – undo
220 220
             $head = 0;
221 221
             $demerit = 0;
222 222
 
223
-            for($y=0; $y<$width; $y++) {
223
+            for ($y = 0; $y < $width; $y++) {
224 224
                 $head = 0;
225 225
                 $this->runLength[0] = 1;
226 226
                 
227 227
                 $frameY = $frame[$y];
228 228
                 
229
-                if ($y>0)
230
-                    $frameYM = $frame[$y-1];
229
+                if ($y > 0)
230
+                    $frameYM = $frame[$y - 1];
231 231
                 
232
-                for($x=0; $x<$width; $x++) {
233
-                    if(($x > 0) && ($y > 0)) {
234
-                        $b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]);
235
-                        $w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]);
232
+                for ($x = 0; $x < $width; $x++) {
233
+                    if (($x > 0) && ($y > 0)) {
234
+                        $b22 = ord($frameY[$x]) & ord($frameY[$x - 1]) & ord($frameYM[$x]) & ord($frameYM[$x - 1]);
235
+                        $w22 = ord($frameY[$x]) | ord($frameY[$x - 1]) | ord($frameYM[$x]) | ord($frameYM[$x - 1]);
236 236
                         
237
-                        if(($b22 | ($w22 ^ 1))&1) {                                                                     
237
+                        if (($b22 | ($w22 ^ 1)) & 1) {                                                                     
238 238
                             $demerit += N2;
239 239
                         }
240 240
                     }
241
-                    if(($x == 0) && (ord($frameY[$x]) & 1)) {
241
+                    if (($x == 0) && (ord($frameY[$x]) & 1)) {
242 242
                         $this->runLength[0] = -1;
243 243
                         $head = 1;
244 244
                         $this->runLength[$head] = 1;
245
-                    } else if($x > 0) {
246
-                        if((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) {
245
+                    } else if ($x > 0) {
246
+                        if ((ord($frameY[$x]) ^ ord($frameY[$x - 1])) & 1) {
247 247
                             $head++;
248 248
                             $this->runLength[$head] = 1;
249 249
                         } else {
@@ -252,20 +252,20 @@  discard block
 block discarded – undo
252 252
                     }
253 253
                 }
254 254
     
255
-                $demerit += $this->calcN1N3($head+1);
255
+                $demerit += $this->calcN1N3($head + 1);
256 256
             }
257 257
 
258
-            for($x=0; $x<$width; $x++) {
258
+            for ($x = 0; $x < $width; $x++) {
259 259
                 $head = 0;
260 260
                 $this->runLength[0] = 1;
261 261
                 
262
-                for($y=0; $y<$width; $y++) {
263
-                    if($y == 0 && (ord($frame[$y][$x]) & 1)) {
262
+                for ($y = 0; $y < $width; $y++) {
263
+                    if ($y == 0 && (ord($frame[$y][$x]) & 1)) {
264 264
                         $this->runLength[0] = -1;
265 265
                         $head = 1;
266 266
                         $this->runLength[$head] = 1;
267
-                    } else if($y > 0) {
268
-                        if((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) {
267
+                    } else if ($y > 0) {
268
+                        if ((ord($frame[$y][$x]) ^ ord($frame[$y - 1][$x])) & 1) {
269 269
                             $head++;
270 270
                             $this->runLength[$head] = 1;
271 271
                         } else {
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                     }
275 275
                 }
276 276
             
277
-                $demerit += $this->calcN1N3($head+1);
277
+                $demerit += $this->calcN1N3($head + 1);
278 278
             }
279 279
 
280 280
             return $demerit;
@@ -288,13 +288,13 @@  discard block
 block discarded – undo
288 288
             $bestMaskNum = 0;
289 289
             $bestMask = array();
290 290
             
291
-            $checked_masks = array(0,1,2,3,4,5,6,7);
291
+            $checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7);
292 292
             
293 293
             if (QR_FIND_FROM_RANDOM !== false) {
294 294
             
295
-                $howManuOut = 8-(QR_FIND_FROM_RANDOM % 9);
296
-                for ($i = 0; $i <  $howManuOut; $i++) {
297
-                    $remPos = rand (0, count($checked_masks)-1);
295
+                $howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9);
296
+                for ($i = 0; $i < $howManuOut; $i++) {
297
+                    $remPos = rand(0, count($checked_masks) - 1);
298 298
                     unset($checked_masks[$remPos]);
299 299
                     $checked_masks = array_values($checked_masks);
300 300
                 }
@@ -303,18 +303,18 @@  discard block
 block discarded – undo
303 303
             
304 304
             $bestMask = $frame;
305 305
              
306
-            foreach($checked_masks as $i) {
306
+            foreach ($checked_masks as $i) {
307 307
                 $mask = array_fill(0, $width, str_repeat("\0", $width));
308 308
 
309 309
                 $demerit = 0;
310 310
                 $blacks = 0;
311 311
                 $blacks  = $this->makeMaskNo($i, $width, $frame, $mask);
312 312
                 $blacks += $this->writeFormatInformation($width, $mask, $i, $level);
313
-                $blacks  = (int)(100 * $blacks / ($width * $width));
314
-                $demerit = (int)((int)(abs($blacks - 50) / 5) * N4);
313
+                $blacks  = (int) (100 * $blacks / ($width * $width));
314
+                $demerit = (int) ((int) (abs($blacks - 50) / 5) * N4);
315 315
                 $demerit += $this->evaluateSymbol($width, $mask);
316 316
                 
317
-                if($demerit < $minDemerit) {
317
+                if ($demerit < $minDemerit) {
318 318
                     $minDemerit = $demerit;
319 319
                     $bestMask = $mask;
320 320
                     $bestMaskNum = $i;
Please login to merge, or discard this patch.
lib/phpqrcode/qrconfig.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
5 5
  * Config file, feel free to modify
6 6
  */
7 7
      
8
-    define('QR_CACHEABLE', true);                                                               // use cache - more disk reads but less CPU power, masks and format templates are stored there
9
-    define('QR_CACHE_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR);  // used when QR_CACHEABLE === true
10
-    define('QR_LOG_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR);                                // default error logs dir   
8
+    define('QR_CACHEABLE', true); // use cache - more disk reads but less CPU power, masks and format templates are stored there
9
+    define('QR_CACHE_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR); // used when QR_CACHEABLE === true
10
+    define('QR_LOG_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR); // default error logs dir   
11 11
     
12
-    define('QR_FIND_BEST_MASK', true);                                                          // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
13
-    define('QR_FIND_FROM_RANDOM', false);                                                       // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
14
-    define('QR_DEFAULT_MASK', 2);                                                               // when QR_FIND_BEST_MASK === false
12
+    define('QR_FIND_BEST_MASK', true); // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
13
+    define('QR_FIND_FROM_RANDOM', false); // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
14
+    define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false
15 15
                                                   
16
-    define('QR_PNG_MAXIMUM_SIZE',  1024);                                                       // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images
16
+    define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images
17 17
                                                   
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
lib/phpqrcode/index.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
     //processing form input
43 43
     //remember to sanitize user input in real-life solution !!!
44 44
     $errorCorrectionLevel = 'L';
45
-    if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
45
+    if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L', 'M', 'Q', 'H')))
46 46
         $errorCorrectionLevel = $_REQUEST['level'];    
47 47
 
48 48
     $matrixPointSize = 4;
49 49
     if (isset($_REQUEST['size']))
50
-        $matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);
50
+        $matrixPointSize = min(max((int) $_REQUEST['size'], 1), 10);
51 51
 
52 52
 
53 53
     if (isset($_REQUEST['data'])) { 
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
     
74 74
     //config form
75 75
     echo '<form action="index.php" method="post">
76
-        Data:&nbsp;<input name="data" value="'.(isset($_REQUEST['data'])?htmlspecialchars($_REQUEST['data']):'PHP QR Code :)').'" />&nbsp;
76
+        Data:&nbsp;<input name="data" value="'.(isset($_REQUEST['data']) ?htmlspecialchars($_REQUEST['data']) : 'PHP QR Code :)').'" />&nbsp;
77 77
         ECC:&nbsp;<select name="level">
78
-            <option value="L"'.(($errorCorrectionLevel=='L')?' selected':'').'>L - smallest</option>
79
-            <option value="M"'.(($errorCorrectionLevel=='M')?' selected':'').'>M</option>
80
-            <option value="Q"'.(($errorCorrectionLevel=='Q')?' selected':'').'>Q</option>
81
-            <option value="H"'.(($errorCorrectionLevel=='H')?' selected':'').'>H - best</option>
78
+            <option value="L"'.(($errorCorrectionLevel == 'L') ? ' selected' : '').'>L - smallest</option>
79
+            <option value="M"'.(($errorCorrectionLevel == 'M') ? ' selected' : '').'>M</option>
80
+            <option value="Q"'.(($errorCorrectionLevel == 'Q') ? ' selected' : '').'>Q</option>
81
+            <option value="H"'.(($errorCorrectionLevel == 'H') ? ' selected' : '').'>H - best</option>
82 82
         </select>&nbsp;
83 83
         Size:&nbsp;<select name="size">';
84 84
         
85
-    for($i=1;$i<=10;$i++)
86
-        echo '<option value="'.$i.'"'.(($matrixPointSize==$i)?' selected':'').'>'.$i.'</option>';
85
+    for ($i = 1; $i <= 10; $i++)
86
+        echo '<option value="'.$i.'"'.(($matrixPointSize == $i) ? ' selected' : '').'>'.$i.'</option>';
87 87
         
88 88
     echo '</select>&nbsp;
89 89
         <input type="submit" value="GENERATE"></form><hr/>';
Please login to merge, or discard this patch.