Passed
Branch master (de5173)
by Cody
11:03
created
lib/floIcon.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 block discarded – undo
4 4
 require_once "jimIcon.php";
5 5
 
6 6
 class floIconIcon {
7
-        function getImageResource() {
8
-                return $this->img;
9
-        }
7
+		function getImageResource() {
8
+				return $this->img;
9
+		}
10 10
 }
11 11
 
12 12
 class floIcon {
13
-        function readICO($file) {
14
-                $jim = new jimIcon();
15
-                $icon = new floIconIcon();
16
-                $icon->img = $jim->fromiconstring(file_get_contents($file));
17
-                $this->images = array($icon);
18
-        }
13
+		function readICO($file) {
14
+				$jim = new jimIcon();
15
+				$icon = new floIconIcon();
16
+				$icon->img = $jim->fromiconstring(file_get_contents($file));
17
+				$this->images = array($icon);
18
+		}
19 19
 }
20 20
 ?>
Please login to merge, or discard this patch.
lib/phpqrcode/qrconst.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@
 block discarded – undo
45 45
 	// Supported output formats
46 46
 	
47 47
 	define('QR_FORMAT_TEXT', 0);
48
-	define('QR_FORMAT_PNG',  1);
48
+	define('QR_FORMAT_PNG', 1);
49 49
 	
50 50
 	class qrstr {
51 51
 		public static function set(&$srctab, $x, $y, $repl, $replLen = false) {
52
-			$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
52
+			$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false) ?substr($repl, 0, $replLen) : $repl, $x, ($replLen !== false) ? $replLen : strlen($repl));
53 53
 		}
54 54
 	}	
55 55
\ No newline at end of file
Please login to merge, or discard this patch.
lib/phpqrcode/tools/merge.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -25,46 +25,46 @@
 block discarded – undo
25 25
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 26
  */
27 27
  
28
-    $QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
29
-    $QR_TOOLSDIR = dirname(__FILE__).DIRECTORY_SEPARATOR;
28
+	$QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
29
+	$QR_TOOLSDIR = dirname(__FILE__).DIRECTORY_SEPARATOR;
30 30
     
31
-    $outputFile = $QR_BASEDIR.'phpqrcode.php';
31
+	$outputFile = $QR_BASEDIR.'phpqrcode.php';
32 32
     
33
-    // Required libs
33
+	// Required libs
34 34
     
35
-    $fileList = array(
36
-        $QR_BASEDIR.'qrconst.php',
37
-        $QR_TOOLSDIR.'merged_config.php',
38
-        $QR_BASEDIR.'qrtools.php',
39
-        $QR_BASEDIR.'qrspec.php',
40
-        $QR_BASEDIR.'qrimage.php',
41
-        $QR_BASEDIR.'qrinput.php',
42
-        $QR_BASEDIR.'qrbitstream.php',
43
-        $QR_BASEDIR.'qrsplit.php',
44
-        $QR_BASEDIR.'qrrscode.php',
45
-        $QR_BASEDIR.'qrmask.php',
46
-        $QR_BASEDIR.'qrencode.php'
47
-    );
35
+	$fileList = array(
36
+		$QR_BASEDIR.'qrconst.php',
37
+		$QR_TOOLSDIR.'merged_config.php',
38
+		$QR_BASEDIR.'qrtools.php',
39
+		$QR_BASEDIR.'qrspec.php',
40
+		$QR_BASEDIR.'qrimage.php',
41
+		$QR_BASEDIR.'qrinput.php',
42
+		$QR_BASEDIR.'qrbitstream.php',
43
+		$QR_BASEDIR.'qrsplit.php',
44
+		$QR_BASEDIR.'qrrscode.php',
45
+		$QR_BASEDIR.'qrmask.php',
46
+		$QR_BASEDIR.'qrencode.php'
47
+	);
48 48
     
49
-    $headerFile = $QR_TOOLSDIR.'merged_header.php';
50
-    $versionFile = $QR_BASEDIR.'VERSION';
49
+	$headerFile = $QR_TOOLSDIR.'merged_header.php';
50
+	$versionFile = $QR_BASEDIR.'VERSION';
51 51
     
52
-    $outputCode = '';
52
+	$outputCode = '';
53 53
     
54
-    foreach($fileList as $fileName) {
55
-        $outputCode .= "\n\n".'//---- '.basename($fileName).' -----------------------------'."\n\n";
56
-        $anotherCode = file_get_contents($fileName);
57
-        $anotherCode = preg_replace ('/^<\?php/', '', $anotherCode);
58
-        $anotherCode = preg_replace ('/\?>\*$/', '', $anotherCode);
59
-        $outputCode .= "\n\n".$anotherCode."\n\n";
60
-    }
54
+	foreach($fileList as $fileName) {
55
+		$outputCode .= "\n\n".'//---- '.basename($fileName).' -----------------------------'."\n\n";
56
+		$anotherCode = file_get_contents($fileName);
57
+		$anotherCode = preg_replace ('/^<\?php/', '', $anotherCode);
58
+		$anotherCode = preg_replace ('/\?>\*$/', '', $anotherCode);
59
+		$outputCode .= "\n\n".$anotherCode."\n\n";
60
+	}
61 61
     
62 62
 	$versionDataEx = explode("\n", file_get_contents($versionFile));
63 63
 	
64
-    $outputContents = file_get_contents($headerFile);
65
-    $outputContents .= "\n\n/*\n * Version: ".trim($versionDataEx[0])."\n * Build: ".trim($versionDataEx[1])."\n */\n\n";
66
-    $outputContents .= $outputCode;
64
+	$outputContents = file_get_contents($headerFile);
65
+	$outputContents .= "\n\n/*\n * Version: ".trim($versionDataEx[0])."\n * Build: ".trim($versionDataEx[1])."\n */\n\n";
66
+	$outputContents .= $outputCode;
67 67
     
68
-    file_put_contents($outputFile, $outputContents);
68
+	file_put_contents($outputFile, $outputContents);
69 69
     
70
-    
71 70
\ No newline at end of file
71
+	
72 72
\ No newline at end of file
Please login to merge, or discard this 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 2 patches
Indentation   +8 added lines, -8 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
17
-                                                  
18 16
\ No newline at end of file
17
+	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
18
+												  
19 19
\ No newline at end of file
Please login to merge, or discard this 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 3 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -25,156 +25,156 @@
 block discarded – undo
25 25
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 26
  */
27 27
      
28
-    class QRbitstream {
28
+	class QRbitstream {
29 29
     
30
-        public $data = array();
30
+		public $data = array();
31 31
         
32
-        //----------------------------------------------------------------------
33
-        public function size()
34
-        {
35
-            return count($this->data);
36
-        }
32
+		//----------------------------------------------------------------------
33
+		public function size()
34
+		{
35
+			return count($this->data);
36
+		}
37 37
         
38
-        //----------------------------------------------------------------------
39
-        public function allocate($setLength)
40
-        {
41
-            $this->data = array_fill(0, $setLength, 0);
42
-            return 0;
43
-        }
38
+		//----------------------------------------------------------------------
39
+		public function allocate($setLength)
40
+		{
41
+			$this->data = array_fill(0, $setLength, 0);
42
+			return 0;
43
+		}
44 44
     
45
-        //----------------------------------------------------------------------
46
-        public static function newFromNum($bits, $num)
47
-        {
48
-            $bstream = new QRbitstream();
49
-            $bstream->allocate($bits);
45
+		//----------------------------------------------------------------------
46
+		public static function newFromNum($bits, $num)
47
+		{
48
+			$bstream = new QRbitstream();
49
+			$bstream->allocate($bits);
50 50
             
51
-            $mask = 1 << ($bits - 1);
52
-            for($i=0; $i<$bits; $i++) {
53
-                if($num & $mask) {
54
-                    $bstream->data[$i] = 1;
55
-                } else {
56
-                    $bstream->data[$i] = 0;
57
-                }
58
-                $mask = $mask >> 1;
59
-            }
51
+			$mask = 1 << ($bits - 1);
52
+			for($i=0; $i<$bits; $i++) {
53
+				if($num & $mask) {
54
+					$bstream->data[$i] = 1;
55
+				} else {
56
+					$bstream->data[$i] = 0;
57
+				}
58
+				$mask = $mask >> 1;
59
+			}
60 60
 
61
-            return $bstream;
62
-        }
61
+			return $bstream;
62
+		}
63 63
         
64
-        //----------------------------------------------------------------------
65
-        public static function newFromBytes($size, $data)
66
-        {
67
-            $bstream = new QRbitstream();
68
-            $bstream->allocate($size * 8);
69
-            $p=0;
64
+		//----------------------------------------------------------------------
65
+		public static function newFromBytes($size, $data)
66
+		{
67
+			$bstream = new QRbitstream();
68
+			$bstream->allocate($size * 8);
69
+			$p=0;
70 70
 
71
-            for($i=0; $i<$size; $i++) {
72
-                $mask = 0x80;
73
-                for($j=0; $j<8; $j++) {
74
-                    if($data[$i] & $mask) {
75
-                        $bstream->data[$p] = 1;
76
-                    } else {
77
-                        $bstream->data[$p] = 0;
78
-                    }
79
-                    $p++;
80
-                    $mask = $mask >> 1;
81
-                }
82
-            }
71
+			for($i=0; $i<$size; $i++) {
72
+				$mask = 0x80;
73
+				for($j=0; $j<8; $j++) {
74
+					if($data[$i] & $mask) {
75
+						$bstream->data[$p] = 1;
76
+					} else {
77
+						$bstream->data[$p] = 0;
78
+					}
79
+					$p++;
80
+					$mask = $mask >> 1;
81
+				}
82
+			}
83 83
 
84
-            return $bstream;
85
-        }
84
+			return $bstream;
85
+		}
86 86
         
87
-        //----------------------------------------------------------------------
88
-        public function append(QRbitstream $arg)
89
-        {
90
-            if (is_null($arg)) {
91
-                return -1;
92
-            }
87
+		//----------------------------------------------------------------------
88
+		public function append(QRbitstream $arg)
89
+		{
90
+			if (is_null($arg)) {
91
+				return -1;
92
+			}
93 93
             
94
-            if($arg->size() == 0) {
95
-                return 0;
96
-            }
94
+			if($arg->size() == 0) {
95
+				return 0;
96
+			}
97 97
             
98
-            if($this->size() == 0) {
99
-                $this->data = $arg->data;
100
-                return 0;
101
-            }
98
+			if($this->size() == 0) {
99
+				$this->data = $arg->data;
100
+				return 0;
101
+			}
102 102
             
103
-            $this->data = array_values(array_merge($this->data, $arg->data));
103
+			$this->data = array_values(array_merge($this->data, $arg->data));
104 104
 
105
-            return 0;
106
-        }
105
+			return 0;
106
+		}
107 107
         
108
-        //----------------------------------------------------------------------
109
-        public function appendNum($bits, $num)
110
-        {
111
-            if ($bits == 0) 
112
-                return 0;
108
+		//----------------------------------------------------------------------
109
+		public function appendNum($bits, $num)
110
+		{
111
+			if ($bits == 0) 
112
+				return 0;
113 113
 
114
-            $b = QRbitstream::newFromNum($bits, $num);
114
+			$b = QRbitstream::newFromNum($bits, $num);
115 115
             
116
-            if(is_null($b))
117
-                return -1;
116
+			if(is_null($b))
117
+				return -1;
118 118
 
119
-            $ret = $this->append($b);
120
-            unset($b);
119
+			$ret = $this->append($b);
120
+			unset($b);
121 121
 
122
-            return $ret;
123
-        }
122
+			return $ret;
123
+		}
124 124
 
125
-        //----------------------------------------------------------------------
126
-        public function appendBytes($size, $data)
127
-        {
128
-            if ($size == 0) 
129
-                return 0;
125
+		//----------------------------------------------------------------------
126
+		public function appendBytes($size, $data)
127
+		{
128
+			if ($size == 0) 
129
+				return 0;
130 130
 
131
-            $b = QRbitstream::newFromBytes($size, $data);
131
+			$b = QRbitstream::newFromBytes($size, $data);
132 132
             
133
-            if(is_null($b))
134
-                return -1;
133
+			if(is_null($b))
134
+				return -1;
135 135
 
136
-            $ret = $this->append($b);
137
-            unset($b);
136
+			$ret = $this->append($b);
137
+			unset($b);
138 138
 
139
-            return $ret;
140
-        }
139
+			return $ret;
140
+		}
141 141
         
142
-        //----------------------------------------------------------------------
143
-        public function toByte()
144
-        {
142
+		//----------------------------------------------------------------------
143
+		public function toByte()
144
+		{
145 145
         
146
-            $size = $this->size();
146
+			$size = $this->size();
147 147
 
148
-            if($size == 0) {
149
-                return array();
150
-            }
148
+			if($size == 0) {
149
+				return array();
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
-            $p = 0;
155
+			$p = 0;
156 156
             
157
-            for($i=0; $i<$bytes; $i++) {
158
-                $v = 0;
159
-                for($j=0; $j<8; $j++) {
160
-                    $v = $v << 1;
161
-                    $v |= $this->data[$p];
162
-                    $p++;
163
-                }
164
-                $data[$i] = $v;
165
-            }
157
+			for($i=0; $i<$bytes; $i++) {
158
+				$v = 0;
159
+				for($j=0; $j<8; $j++) {
160
+					$v = $v << 1;
161
+					$v |= $this->data[$p];
162
+					$p++;
163
+				}
164
+				$data[$i] = $v;
165
+			}
166 166
             
167
-            if($size & 7) {
168
-                $v = 0;
169
-                for($j=0; $j<($size & 7); $j++) {
170
-                    $v = $v << 1;
171
-                    $v |= $this->data[$p];
172
-                    $p++;
173
-                }
174
-                $data[$bytes] = $v;
175
-            }
167
+			if($size & 7) {
168
+				$v = 0;
169
+				for($j=0; $j<($size & 7); $j++) {
170
+					$v = $v << 1;
171
+					$v |= $this->data[$p];
172
+					$p++;
173
+				}
174
+				$data[$bytes] = $v;
175
+			}
176 176
 
177
-            return $data;
178
-        }
177
+			return $data;
178
+		}
179 179
 
180
-    }
180
+	}
Please login to merge, or discard this 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.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -108,13 +108,15 @@  discard block
 block discarded – undo
108 108
         //----------------------------------------------------------------------
109 109
         public function appendNum($bits, $num)
110 110
         {
111
-            if ($bits == 0) 
112
-                return 0;
111
+            if ($bits == 0) {
112
+                            return 0;
113
+            }
113 114
 
114 115
             $b = QRbitstream::newFromNum($bits, $num);
115 116
             
116
-            if(is_null($b))
117
-                return -1;
117
+            if(is_null($b)) {
118
+                            return -1;
119
+            }
118 120
 
119 121
             $ret = $this->append($b);
120 122
             unset($b);
@@ -125,13 +127,15 @@  discard block
 block discarded – undo
125 127
         //----------------------------------------------------------------------
126 128
         public function appendBytes($size, $data)
127 129
         {
128
-            if ($size == 0) 
129
-                return 0;
130
+            if ($size == 0) {
131
+                            return 0;
132
+            }
130 133
 
131 134
             $b = QRbitstream::newFromBytes($size, $data);
132 135
             
133
-            if(is_null($b))
134
-                return -1;
136
+            if(is_null($b)) {
137
+                            return -1;
138
+            }
135 139
 
136 140
             $ret = $this->append($b);
137 141
             unset($b);
Please login to merge, or discard this patch.
lib/phpqrcode/qrsplit.php 4 patches
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -30,282 +30,282 @@
 block discarded – undo
30 30
  * License along with this library; if not, write to the Free Software
31 31
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 32
  */
33
-    class QRsplit {
33
+	class QRsplit {
34 34
 
35
-        public $dataStr = '';
36
-        public $input;
37
-        public $modeHint;
35
+		public $dataStr = '';
36
+		public $input;
37
+		public $modeHint;
38 38
 
39
-        //----------------------------------------------------------------------
40
-        public function __construct($dataStr, $input, $modeHint) 
41
-        {
42
-            $this->dataStr  = $dataStr;
43
-            $this->input    = $input;
44
-            $this->modeHint = $modeHint;
45
-        }
39
+		//----------------------------------------------------------------------
40
+		public function __construct($dataStr, $input, $modeHint) 
41
+		{
42
+			$this->dataStr  = $dataStr;
43
+			$this->input    = $input;
44
+			$this->modeHint = $modeHint;
45
+		}
46 46
         
47
-        //----------------------------------------------------------------------
48
-        public static function isdigitat($str, $pos)
49
-        {    
50
-            if ($pos >= strlen($str))
51
-                return false;
47
+		//----------------------------------------------------------------------
48
+		public static function isdigitat($str, $pos)
49
+		{    
50
+			if ($pos >= strlen($str))
51
+				return false;
52 52
             
53
-            return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
54
-        }
53
+			return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
54
+		}
55 55
         
56
-        //----------------------------------------------------------------------
57
-        public static function isalnumat($str, $pos)
58
-        {
59
-            if ($pos >= strlen($str))
60
-                return false;
56
+		//----------------------------------------------------------------------
57
+		public static function isalnumat($str, $pos)
58
+		{
59
+			if ($pos >= strlen($str))
60
+				return false;
61 61
                 
62
-            return (QRinput::lookAnTable(ord($str[$pos])) >= 0);
63
-        }
62
+			return (QRinput::lookAnTable(ord($str[$pos])) >= 0);
63
+		}
64 64
 
65
-        //----------------------------------------------------------------------
66
-        public function identifyMode($pos)
67
-        {
68
-            if ($pos >= strlen($this->dataStr)) 
69
-                return QR_MODE_NUL;
65
+		//----------------------------------------------------------------------
66
+		public function identifyMode($pos)
67
+		{
68
+			if ($pos >= strlen($this->dataStr)) 
69
+				return QR_MODE_NUL;
70 70
                 
71
-            $c = $this->dataStr[$pos];
71
+			$c = $this->dataStr[$pos];
72 72
             
73
-            if(self::isdigitat($this->dataStr, $pos)) {
74
-                return QR_MODE_NUM;
75
-            } else if(self::isalnumat($this->dataStr, $pos)) {
76
-                return QR_MODE_AN;
77
-            } else if($this->modeHint == QR_MODE_KANJI) {
73
+			if(self::isdigitat($this->dataStr, $pos)) {
74
+				return QR_MODE_NUM;
75
+			} else if(self::isalnumat($this->dataStr, $pos)) {
76
+				return QR_MODE_AN;
77
+			} else if($this->modeHint == QR_MODE_KANJI) {
78 78
             
79
-                if ($pos+1 < strlen($this->dataStr)) 
80
-                {
81
-                    $d = $this->dataStr[$pos+1];
82
-                    $word = (ord($c) << 8) | ord($d);
83
-                    if(($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) {
84
-                        return QR_MODE_KANJI;
85
-                    }
86
-                }
87
-            }
79
+				if ($pos+1 < strlen($this->dataStr)) 
80
+				{
81
+					$d = $this->dataStr[$pos+1];
82
+					$word = (ord($c) << 8) | ord($d);
83
+					if(($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) {
84
+						return QR_MODE_KANJI;
85
+					}
86
+				}
87
+			}
88 88
 
89
-            return QR_MODE_8;
90
-        } 
89
+			return QR_MODE_8;
90
+		} 
91 91
         
92
-        //----------------------------------------------------------------------
93
-        public function eatNum()
94
-        {
95
-            $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
92
+		//----------------------------------------------------------------------
93
+		public function eatNum()
94
+		{
95
+			$ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
96 96
 
97
-            $p = 0;
98
-            while(self::isdigitat($this->dataStr, $p)) {
99
-                $p++;
100
-            }
97
+			$p = 0;
98
+			while(self::isdigitat($this->dataStr, $p)) {
99
+				$p++;
100
+			}
101 101
             
102
-            $run = $p;
103
-            $mode = $this->identifyMode($p);
102
+			$run = $p;
103
+			$mode = $this->identifyMode($p);
104 104
             
105
-            if($mode == QR_MODE_8) {
106
-                $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln
107
-                     + QRinput::estimateBitsMode8(1)         // + 4 + l8
108
-                     - QRinput::estimateBitsMode8($run + 1); // - 4 - l8
109
-                if($dif > 0) {
110
-                    return $this->eat8();
111
-                }
112
-            }
113
-            if($mode == QR_MODE_AN) {
114
-                $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln
115
-                     + QRinput::estimateBitsModeAn(1)        // + 4 + la
116
-                     - QRinput::estimateBitsModeAn($run + 1);// - 4 - la
117
-                if($dif > 0) {
118
-                    return $this->eatAn();
119
-                }
120
-            }
105
+			if($mode == QR_MODE_8) {
106
+				$dif = QRinput::estimateBitsModeNum($run) + 4 + $ln
107
+					 + QRinput::estimateBitsMode8(1)         // + 4 + l8
108
+					 - QRinput::estimateBitsMode8($run + 1); // - 4 - l8
109
+				if($dif > 0) {
110
+					return $this->eat8();
111
+				}
112
+			}
113
+			if($mode == QR_MODE_AN) {
114
+				$dif = QRinput::estimateBitsModeNum($run) + 4 + $ln
115
+					 + QRinput::estimateBitsModeAn(1)        // + 4 + la
116
+					 - QRinput::estimateBitsModeAn($run + 1);// - 4 - la
117
+				if($dif > 0) {
118
+					return $this->eatAn();
119
+				}
120
+			}
121 121
             
122
-            $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr));
123
-            if($ret < 0)
124
-                return -1;
122
+			$ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr));
123
+			if($ret < 0)
124
+				return -1;
125 125
 
126
-            return $run;
127
-        }
126
+			return $run;
127
+		}
128 128
         
129
-        //----------------------------------------------------------------------
130
-        public function eatAn()
131
-        {
132
-            $la = QRspec::lengthIndicator(QR_MODE_AN,  $this->input->getVersion());
133
-            $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
129
+		//----------------------------------------------------------------------
130
+		public function eatAn()
131
+		{
132
+			$la = QRspec::lengthIndicator(QR_MODE_AN,  $this->input->getVersion());
133
+			$ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
134 134
 
135
-            $p = 0;
135
+			$p = 0;
136 136
             
137
-            while(self::isalnumat($this->dataStr, $p)) {
138
-                if(self::isdigitat($this->dataStr, $p)) {
139
-                    $q = $p;
140
-                    while(self::isdigitat($this->dataStr, $q)) {
141
-                        $q++;
142
-                    }
137
+			while(self::isalnumat($this->dataStr, $p)) {
138
+				if(self::isdigitat($this->dataStr, $p)) {
139
+					$q = $p;
140
+					while(self::isdigitat($this->dataStr, $q)) {
141
+						$q++;
142
+					}
143 143
                     
144
-                    $dif = QRinput::estimateBitsModeAn($p) // + 4 + la
145
-                         + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
146
-                         - QRinput::estimateBitsModeAn($q); // - 4 - la
144
+					$dif = QRinput::estimateBitsModeAn($p) // + 4 + la
145
+						 + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
146
+						 - QRinput::estimateBitsModeAn($q); // - 4 - la
147 147
                          
148
-                    if($dif < 0) {
149
-                        break;
150
-                    } else {
151
-                        $p = $q;
152
-                    }
153
-                } else {
154
-                    $p++;
155
-                }
156
-            }
148
+					if($dif < 0) {
149
+						break;
150
+					} else {
151
+						$p = $q;
152
+					}
153
+				} else {
154
+					$p++;
155
+				}
156
+			}
157 157
 
158
-            $run = $p;
158
+			$run = $p;
159 159
 
160
-            if(!self::isalnumat($this->dataStr, $p)) {
161
-                $dif = QRinput::estimateBitsModeAn($run) + 4 + $la
162
-                     + QRinput::estimateBitsMode8(1) // + 4 + l8
163
-                      - QRinput::estimateBitsMode8($run + 1); // - 4 - l8
164
-                if($dif > 0) {
165
-                    return $this->eat8();
166
-                }
167
-            }
160
+			if(!self::isalnumat($this->dataStr, $p)) {
161
+				$dif = QRinput::estimateBitsModeAn($run) + 4 + $la
162
+					 + QRinput::estimateBitsMode8(1) // + 4 + l8
163
+					  - QRinput::estimateBitsMode8($run + 1); // - 4 - l8
164
+				if($dif > 0) {
165
+					return $this->eat8();
166
+				}
167
+			}
168 168
 
169
-            $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr));
170
-            if($ret < 0)
171
-                return -1;
169
+			$ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr));
170
+			if($ret < 0)
171
+				return -1;
172 172
 
173
-            return $run;
174
-        }
173
+			return $run;
174
+		}
175 175
         
176
-        //----------------------------------------------------------------------
177
-        public function eatKanji()
178
-        {
179
-            $p = 0;
176
+		//----------------------------------------------------------------------
177
+		public function eatKanji()
178
+		{
179
+			$p = 0;
180 180
             
181
-            while($this->identifyMode($p) == QR_MODE_KANJI) {
182
-                $p += 2;
183
-            }
181
+			while($this->identifyMode($p) == QR_MODE_KANJI) {
182
+				$p += 2;
183
+			}
184 184
             
185
-            $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr));
186
-            if($ret < 0)
187
-                return -1;
185
+			$ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr));
186
+			if($ret < 0)
187
+				return -1;
188 188
 
189
-            return $ret;
190
-        }
189
+			return $ret;
190
+		}
191 191
 
192
-        //----------------------------------------------------------------------
193
-        public function eat8()
194
-        {
195
-            $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
196
-            $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
192
+		//----------------------------------------------------------------------
193
+		public function eat8()
194
+		{
195
+			$la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
196
+			$ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
197 197
 
198
-            $p = 1;
199
-            $dataStrLen = strlen($this->dataStr);
198
+			$p = 1;
199
+			$dataStrLen = strlen($this->dataStr);
200 200
             
201
-            while($p < $dataStrLen) {
201
+			while($p < $dataStrLen) {
202 202
                 
203
-                $mode = $this->identifyMode($p);
204
-                if($mode == QR_MODE_KANJI) {
205
-                    break;
206
-                }
207
-                if($mode == QR_MODE_NUM) {
208
-                    $q = $p;
209
-                    while(self::isdigitat($this->dataStr, $q)) {
210
-                        $q++;
211
-                    }
212
-                    $dif = QRinput::estimateBitsMode8($p) // + 4 + l8
213
-                         + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
214
-                         - QRinput::estimateBitsMode8($q); // - 4 - l8
215
-                    if($dif < 0) {
216
-                        break;
217
-                    } else {
218
-                        $p = $q;
219
-                    }
220
-                } else if($mode == QR_MODE_AN) {
221
-                    $q = $p;
222
-                    while(self::isalnumat($this->dataStr, $q)) {
223
-                        $q++;
224
-                    }
225
-                    $dif = QRinput::estimateBitsMode8($p)  // + 4 + l8
226
-                         + QRinput::estimateBitsModeAn($q - $p) + 4 + $la
227
-                         - QRinput::estimateBitsMode8($q); // - 4 - l8
228
-                    if($dif < 0) {
229
-                        break;
230
-                    } else {
231
-                        $p = $q;
232
-                    }
233
-                } else {
234
-                    $p++;
235
-                }
236
-            }
203
+				$mode = $this->identifyMode($p);
204
+				if($mode == QR_MODE_KANJI) {
205
+					break;
206
+				}
207
+				if($mode == QR_MODE_NUM) {
208
+					$q = $p;
209
+					while(self::isdigitat($this->dataStr, $q)) {
210
+						$q++;
211
+					}
212
+					$dif = QRinput::estimateBitsMode8($p) // + 4 + l8
213
+						 + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln
214
+						 - QRinput::estimateBitsMode8($q); // - 4 - l8
215
+					if($dif < 0) {
216
+						break;
217
+					} else {
218
+						$p = $q;
219
+					}
220
+				} else if($mode == QR_MODE_AN) {
221
+					$q = $p;
222
+					while(self::isalnumat($this->dataStr, $q)) {
223
+						$q++;
224
+					}
225
+					$dif = QRinput::estimateBitsMode8($p)  // + 4 + l8
226
+						 + QRinput::estimateBitsModeAn($q - $p) + 4 + $la
227
+						 - QRinput::estimateBitsMode8($q); // - 4 - l8
228
+					if($dif < 0) {
229
+						break;
230
+					} else {
231
+						$p = $q;
232
+					}
233
+				} else {
234
+					$p++;
235
+				}
236
+			}
237 237
 
238
-            $run = $p;
239
-            $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
238
+			$run = $p;
239
+			$ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
240 240
             
241
-            if($ret < 0)
242
-                return -1;
241
+			if($ret < 0)
242
+				return -1;
243 243
 
244
-            return $run;
245
-        }
244
+			return $run;
245
+		}
246 246
 
247
-        //----------------------------------------------------------------------
248
-        public function splitString()
249
-        {
250
-            while (strlen($this->dataStr) > 0)
251
-            {
252
-                if($this->dataStr == '')
253
-                    return 0;
247
+		//----------------------------------------------------------------------
248
+		public function splitString()
249
+		{
250
+			while (strlen($this->dataStr) > 0)
251
+			{
252
+				if($this->dataStr == '')
253
+					return 0;
254 254
 
255
-                $mode = $this->identifyMode(0);
255
+				$mode = $this->identifyMode(0);
256 256
                 
257
-                switch ($mode) {
258
-                    case QR_MODE_NUM: $length = $this->eatNum(); break;
259
-                    case QR_MODE_AN:  $length = $this->eatAn(); break;
260
-                    case QR_MODE_KANJI:
261
-                        if ($this->modeHint == QR_MODE_KANJI)
262
-                                $length = $this->eatKanji();
263
-                        else    $length = $this->eat8();
264
-                        break;
265
-                    default: $length = $this->eat8(); break;
257
+				switch ($mode) {
258
+					case QR_MODE_NUM: $length = $this->eatNum(); break;
259
+					case QR_MODE_AN:  $length = $this->eatAn(); break;
260
+					case QR_MODE_KANJI:
261
+						if ($this->modeHint == QR_MODE_KANJI)
262
+								$length = $this->eatKanji();
263
+						else    $length = $this->eat8();
264
+						break;
265
+					default: $length = $this->eat8(); break;
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
-                $this->dataStr = substr($this->dataStr, $length);
273
-            }
274
-        }
272
+				$this->dataStr = substr($this->dataStr, $length);
273
+			}
274
+		}
275 275
 
276
-        //----------------------------------------------------------------------
277
-        public function toUpper()
278
-        {
279
-            $stringLen = strlen($this->dataStr);
280
-            $p = 0;
276
+		//----------------------------------------------------------------------
277
+		public function toUpper()
278
+		{
279
+			$stringLen = strlen($this->dataStr);
280
+			$p = 0;
281 281
             
282
-            while ($p<$stringLen) {
283
-                $mode = self::identifyMode(substr($this->dataStr, $p));
284
-                if($mode == QR_MODE_KANJI) {
285
-                    $p += 2;
286
-                } else {
287
-                    if (ord($this->dataStr[$p]) >= ord('a') && ord($this->dataStr[$p]) <= ord('z')) {
288
-                        $this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32);
289
-                    }
290
-                    $p++;
291
-                }
292
-            }
282
+			while ($p<$stringLen) {
283
+				$mode = self::identifyMode(substr($this->dataStr, $p));
284
+				if($mode == QR_MODE_KANJI) {
285
+					$p += 2;
286
+				} else {
287
+					if (ord($this->dataStr[$p]) >= ord('a') && ord($this->dataStr[$p]) <= ord('z')) {
288
+						$this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32);
289
+					}
290
+					$p++;
291
+				}
292
+			}
293 293
 
294
-            return $this->dataStr;
295
-        }
294
+			return $this->dataStr;
295
+		}
296 296
 
297
-        //----------------------------------------------------------------------
298
-        public static function splitStringToQRinput($string, QRinput $input, $modeHint, $casesensitive = true)
299
-        {
300
-            if(is_null($string) || $string == '\0' || $string == '') {
301
-                throw new Exception('empty string!!!');
302
-            }
297
+		//----------------------------------------------------------------------
298
+		public static function splitStringToQRinput($string, QRinput $input, $modeHint, $casesensitive = true)
299
+		{
300
+			if(is_null($string) || $string == '\0' || $string == '') {
301
+				throw new Exception('empty string!!!');
302
+			}
303 303
 
304
-            $split = new QRsplit($string, $input, $modeHint);
304
+			$split = new QRsplit($string, $input, $modeHint);
305 305
             
306
-            if(!$casesensitive)
307
-                $split->toUpper();
306
+			if(!$casesensitive)
307
+				$split->toUpper();
308 308
                 
309
-            return $split->splitString();
310
-        }
311
-    }
309
+			return $split->splitString();
310
+		}
311
+	}
Please login to merge, or discard this patch.
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -255,14 +255,14 @@
 block discarded – undo
255 255
                 $mode = $this->identifyMode(0);
256 256
                 
257 257
                 switch ($mode) {
258
-                    case QR_MODE_NUM: $length = $this->eatNum(); break;
259
-                    case QR_MODE_AN:  $length = $this->eatAn(); break;
260
-                    case QR_MODE_KANJI:
261
-                        if ($this->modeHint == QR_MODE_KANJI)
262
-                                $length = $this->eatKanji();
263
-                        else    $length = $this->eat8();
264
-                        break;
265
-                    default: $length = $this->eat8(); break;
258
+                case QR_MODE_NUM: $length = $this->eatNum(); break;
259
+                case QR_MODE_AN:  $length = $this->eatAn(); break;
260
+                case QR_MODE_KANJI:
261
+                    if ($this->modeHint == QR_MODE_KANJI)
262
+                            $length = $this->eatKanji();
263
+                    else    $length = $this->eat8();
264
+                    break;
265
+                default: $length = $this->eat8(); break;
266 266
                 
267 267
                 }
268 268
 
Please login to merge, or discard this 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.
Braces   +38 added lines, -23 removed lines patch added patch discarded remove patch
@@ -47,8 +47,9 @@  discard block
 block discarded – undo
47 47
         //----------------------------------------------------------------------
48 48
         public static function isdigitat($str, $pos)
49 49
         {    
50
-            if ($pos >= strlen($str))
51
-                return false;
50
+            if ($pos >= strlen($str)) {
51
+                            return false;
52
+            }
52 53
             
53 54
             return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
54 55
         }
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
         //----------------------------------------------------------------------
57 58
         public static function isalnumat($str, $pos)
58 59
         {
59
-            if ($pos >= strlen($str))
60
-                return false;
60
+            if ($pos >= strlen($str)) {
61
+                            return false;
62
+            }
61 63
                 
62 64
             return (QRinput::lookAnTable(ord($str[$pos])) >= 0);
63 65
         }
@@ -65,8 +67,9 @@  discard block
 block discarded – undo
65 67
         //----------------------------------------------------------------------
66 68
         public function identifyMode($pos)
67 69
         {
68
-            if ($pos >= strlen($this->dataStr)) 
69
-                return QR_MODE_NUL;
70
+            if ($pos >= strlen($this->dataStr)) {
71
+                            return QR_MODE_NUL;
72
+            }
70 73
                 
71 74
             $c = $this->dataStr[$pos];
72 75
             
@@ -120,8 +123,9 @@  discard block
 block discarded – undo
120 123
             }
121 124
             
122 125
             $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr));
123
-            if($ret < 0)
124
-                return -1;
126
+            if($ret < 0) {
127
+                            return -1;
128
+            }
125 129
 
126 130
             return $run;
127 131
         }
@@ -167,8 +171,9 @@  discard block
 block discarded – undo
167 171
             }
168 172
 
169 173
             $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr));
170
-            if($ret < 0)
171
-                return -1;
174
+            if($ret < 0) {
175
+                            return -1;
176
+            }
172 177
 
173 178
             return $run;
174 179
         }
@@ -183,8 +188,9 @@  discard block
 block discarded – undo
183 188
             }
184 189
             
185 190
             $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr));
186
-            if($ret < 0)
187
-                return -1;
191
+            if($ret < 0) {
192
+                            return -1;
193
+            }
188 194
 
189 195
             return $ret;
190 196
         }
@@ -238,8 +244,9 @@  discard block
 block discarded – undo
238 244
             $run = $p;
239 245
             $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
240 246
             
241
-            if($ret < 0)
242
-                return -1;
247
+            if($ret < 0) {
248
+                            return -1;
249
+            }
243 250
 
244 251
             return $run;
245 252
         }
@@ -249,8 +256,9 @@  discard block
 block discarded – undo
249 256
         {
250 257
             while (strlen($this->dataStr) > 0)
251 258
             {
252
-                if($this->dataStr == '')
253
-                    return 0;
259
+                if($this->dataStr == '') {
260
+                                    return 0;
261
+                }
254 262
 
255 263
                 $mode = $this->identifyMode(0);
256 264
                 
@@ -258,16 +266,22 @@  discard block
 block discarded – undo
258 266
                     case QR_MODE_NUM: $length = $this->eatNum(); break;
259 267
                     case QR_MODE_AN:  $length = $this->eatAn(); break;
260 268
                     case QR_MODE_KANJI:
261
-                        if ($this->modeHint == QR_MODE_KANJI)
262
-                                $length = $this->eatKanji();
263
-                        else    $length = $this->eat8();
269
+                        if ($this->modeHint == QR_MODE_KANJI) {
270
+                                                        $length = $this->eatKanji();
271
+                        } else {
272
+                        	$length = $this->eat8();
273
+                        }
264 274
                         break;
265 275
                     default: $length = $this->eat8(); break;
266 276
                 
267 277
                 }
268 278
 
269
-                if($length == 0) return 0;
270
-                if($length < 0)  return -1;
279
+                if($length == 0) {
280
+                	return 0;
281
+                }
282
+                if($length < 0) {
283
+                	return -1;
284
+                }
271 285
                 
272 286
                 $this->dataStr = substr($this->dataStr, $length);
273 287
             }
@@ -303,8 +317,9 @@  discard block
 block discarded – undo
303 317
 
304 318
             $split = new QRsplit($string, $input, $modeHint);
305 319
             
306
-            if(!$casesensitive)
307
-                $split->toUpper();
320
+            if(!$casesensitive) {
321
+                            $split->toUpper();
322
+            }
308 323
                 
309 324
             return $split->splitString();
310 325
         }
Please login to merge, or discard this patch.
lib/phpqrcode/qrinput.php 4 patches
Indentation   +619 added lines, -619 removed lines patch added patch discarded remove patch
@@ -25,705 +25,705 @@
 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);
29
-    define('MAX_STRUCTURED_SYMBOLS', 16);
28
+	define('STRUCTURE_HEADER_BITS',  20);
29
+	define('MAX_STRUCTURED_SYMBOLS', 16);
30 30
 
31
-    class QRinputItem {
31
+	class QRinputItem {
32 32
     
33
-        public $mode;
34
-        public $size;
35
-        public $data;
36
-        public $bstream;
37
-
38
-        public function __construct($mode, $size, $data, $bstream = null) 
39
-        {
40
-            $setData = array_slice($data, 0, $size);
33
+		public $mode;
34
+		public $size;
35
+		public $data;
36
+		public $bstream;
37
+
38
+		public function __construct($mode, $size, $data, $bstream = null) 
39
+		{
40
+			$setData = array_slice($data, 0, $size);
41 41
             
42
-            if (count($setData) < $size) {
43
-                $setData = array_merge($setData, array_fill(0,$size-count($setData),0));
44
-            }
45
-        
46
-            if(!QRinput::check($mode, $size, $setData)) {
47
-                throw new Exception('Error m:'.$mode.',s:'.$size.',d:'.join(',',$setData));
48
-                return null;
49
-            }
42
+			if (count($setData) < $size) {
43
+				$setData = array_merge($setData, array_fill(0,$size-count($setData),0));
44
+			}
45
+        
46
+			if(!QRinput::check($mode, $size, $setData)) {
47
+				throw new Exception('Error m:'.$mode.',s:'.$size.',d:'.join(',',$setData));
48
+				return null;
49
+			}
50 50
             
51
-            $this->mode = $mode;
52
-            $this->size = $size;
53
-            $this->data = $setData;
54
-            $this->bstream = $bstream;
55
-        }
56
-        
57
-        //----------------------------------------------------------------------
58
-        public function encodeModeNum($version)
59
-        {
60
-            try {
51
+			$this->mode = $mode;
52
+			$this->size = $size;
53
+			$this->data = $setData;
54
+			$this->bstream = $bstream;
55
+		}
56
+        
57
+		//----------------------------------------------------------------------
58
+		public function encodeModeNum($version)
59
+		{
60
+			try {
61 61
             
62
-                $words = (int)($this->size / 3);
63
-                $bs = new QRbitstream();
62
+				$words = (int)($this->size / 3);
63
+				$bs = new QRbitstream();
64 64
                 
65
-                $val = 0x1;
66
-                $bs->appendNum(4, $val);
67
-                $bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size);
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'));
73
-                    $bs->appendNum(10, $val);
74
-                }
75
-
76
-                if($this->size - $words * 3 == 1) {
77
-                    $val = ord($this->data[$words*3]) - ord('0');
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'));
82
-                    $bs->appendNum(7, $val);
83
-                }
84
-
85
-                $this->bstream = $bs;
86
-                return 0;
65
+				$val = 0x1;
66
+				$bs->appendNum(4, $val);
67
+				$bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size);
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'));
73
+					$bs->appendNum(10, $val);
74
+				}
75
+
76
+				if($this->size - $words * 3 == 1) {
77
+					$val = ord($this->data[$words*3]) - ord('0');
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'));
82
+					$bs->appendNum(7, $val);
83
+				}
84
+
85
+				$this->bstream = $bs;
86
+				return 0;
87 87
                 
88
-            } catch (Exception $e) {
89
-                return -1;
90
-            }
91
-        }
92
-        
93
-        //----------------------------------------------------------------------
94
-        public function encodeModeAn($version)
95
-        {
96
-            try {
97
-                $words = (int)($this->size / 2);
98
-                $bs = new QRbitstream();
88
+			} catch (Exception $e) {
89
+				return -1;
90
+			}
91
+		}
92
+        
93
+		//----------------------------------------------------------------------
94
+		public function encodeModeAn($version)
95
+		{
96
+			try {
97
+				$words = (int)($this->size / 2);
98
+				$bs = new QRbitstream();
99 99
                 
100
-                $bs->appendNum(4, 0x02);
101
-                $bs->appendNum(QRspec::lengthIndicator(QR_MODE_AN, $version), $this->size);
100
+				$bs->appendNum(4, 0x02);
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
-                    $bs->appendNum(11, $val);
108
-                }
107
+					$bs->appendNum(11, $val);
108
+				}
109 109
 
110
-                if($this->size & 1) {
111
-                    $val = QRinput::lookAnTable(ord($this->data[$words * 2]));
112
-                    $bs->appendNum(6, $val);
113
-                }
110
+				if($this->size & 1) {
111
+					$val = QRinput::lookAnTable(ord($this->data[$words * 2]));
112
+					$bs->appendNum(6, $val);
113
+				}
114 114
         
115
-                $this->bstream = $bs;
116
-                return 0;
115
+				$this->bstream = $bs;
116
+				return 0;
117 117
             
118
-            } catch (Exception $e) {
119
-                return -1;
120
-            }
121
-        }
122
-        
123
-        //----------------------------------------------------------------------
124
-        public function encodeMode8($version)
125
-        {
126
-            try {
127
-                $bs = new QRbitstream();
128
-
129
-                $bs->appendNum(4, 0x4);
130
-                $bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size);
131
-
132
-                for($i=0; $i<$this->size; $i++) {
133
-                    $bs->appendNum(8, ord($this->data[$i]));
134
-                }
135
-
136
-                $this->bstream = $bs;
137
-                return 0;
118
+			} catch (Exception $e) {
119
+				return -1;
120
+			}
121
+		}
122
+        
123
+		//----------------------------------------------------------------------
124
+		public function encodeMode8($version)
125
+		{
126
+			try {
127
+				$bs = new QRbitstream();
128
+
129
+				$bs->appendNum(4, 0x4);
130
+				$bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size);
131
+
132
+				for($i=0; $i<$this->size; $i++) {
133
+					$bs->appendNum(8, ord($this->data[$i]));
134
+				}
135
+
136
+				$this->bstream = $bs;
137
+				return 0;
138 138
             
139
-            } catch (Exception $e) {
140
-                return -1;
141
-            }
142
-        }
139
+			} catch (Exception $e) {
140
+				return -1;
141
+			}
142
+		}
143 143
         
144
-        //----------------------------------------------------------------------
145
-        public function encodeModeKanji($version)
146
-        {
147
-            try {
144
+		//----------------------------------------------------------------------
145
+		public function encodeModeKanji($version)
146
+		{
147
+			try {
148 148
 
149
-                $bs = new QRbitrtream();
149
+				$bs = new QRbitrtream();
150 150
                 
151
-                $bs->appendNum(4, 0x8);
152
-                $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2));
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) {
157
-                        $val -= 0x8140;
158
-                    } else {
159
-                        $val -= 0xc140;
160
-                    }
151
+				$bs->appendNum(4, 0x8);
152
+				$bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2));
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) {
157
+						$val -= 0x8140;
158
+					} else {
159
+						$val -= 0xc140;
160
+					}
161 161
                     
162
-                    $h = ($val >> 8) * 0xc0;
163
-                    $val = ($val & 0xff) + $h;
162
+					$h = ($val >> 8) * 0xc0;
163
+					$val = ($val & 0xff) + $h;
164 164
 
165
-                    $bs->appendNum(13, $val);
166
-                }
165
+					$bs->appendNum(13, $val);
166
+				}
167 167
 
168
-                $this->bstream = $bs;
169
-                return 0;
168
+				$this->bstream = $bs;
169
+				return 0;
170 170
             
171
-            } catch (Exception $e) {
172
-                return -1;
173
-            }
174
-        }
175
-
176
-        //----------------------------------------------------------------------
177
-        public function encodeModeStructure()
178
-        {
179
-            try {
180
-                $bs =  new QRbitstream();
171
+			} catch (Exception $e) {
172
+				return -1;
173
+			}
174
+		}
175
+
176
+		//----------------------------------------------------------------------
177
+		public function encodeModeStructure()
178
+		{
179
+			try {
180
+				$bs =  new QRbitstream();
181 181
                 
182
-                $bs->appendNum(4, 0x03);
183
-                $bs->appendNum(4, ord($this->data[1]) - 1);
184
-                $bs->appendNum(4, ord($this->data[0]) - 1);
185
-                $bs->appendNum(8, ord($this->data[2]));
182
+				$bs->appendNum(4, 0x03);
183
+				$bs->appendNum(4, ord($this->data[1]) - 1);
184
+				$bs->appendNum(4, ord($this->data[0]) - 1);
185
+				$bs->appendNum(8, ord($this->data[2]));
186 186
 
187
-                $this->bstream = $bs;
188
-                return 0;
187
+				$this->bstream = $bs;
188
+				return 0;
189 189
             
190
-            } catch (Exception $e) {
191
-                return -1;
192
-            }
193
-        }
194
-        
195
-        //----------------------------------------------------------------------
196
-        public function estimateBitStreamSizeOfEntry($version)
197
-        {
198
-            $bits = 0;
199
-
200
-            if($version == 0) 
201
-                $version = 1;
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;
208
-                case QR_MODE_STRUCTURE:    return STRUCTURE_HEADER_BITS;            
209
-                default:
210
-                    return 0;
211
-            }
212
-
213
-            $l = QRspec::lengthIndicator($this->mode, $version);
214
-            $m = 1 << $l;
215
-            $num = (int)(($this->size + $m - 1) / $m);
216
-
217
-            $bits += $num * (4 + $l);
218
-
219
-            return $bits;
220
-        }
221
-        
222
-        //----------------------------------------------------------------------
223
-        public function encodeBitStream($version)
224
-        {
225
-            try {
190
+			} catch (Exception $e) {
191
+				return -1;
192
+			}
193
+		}
194
+        
195
+		//----------------------------------------------------------------------
196
+		public function estimateBitStreamSizeOfEntry($version)
197
+		{
198
+			$bits = 0;
199
+
200
+			if($version == 0) 
201
+				$version = 1;
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;
208
+				case QR_MODE_STRUCTURE:    return STRUCTURE_HEADER_BITS;            
209
+				default:
210
+					return 0;
211
+			}
212
+
213
+			$l = QRspec::lengthIndicator($this->mode, $version);
214
+			$m = 1 << $l;
215
+			$num = (int)(($this->size + $m - 1) / $m);
216
+
217
+			$bits += $num * (4 + $l);
218
+
219
+			return $bits;
220
+		}
221
+        
222
+		//----------------------------------------------------------------------
223
+		public function encodeBitStream($version)
224
+		{
225
+			try {
226 226
             
227
-                unset($this->bstream);
228
-                $words = QRspec::maximumWords($this->mode, $version);
227
+				unset($this->bstream);
228
+				$words = QRspec::maximumWords($this->mode, $version);
229 229
                 
230
-                if($this->size > $words) {
230
+				if($this->size > $words) {
231 231
                 
232
-                    $st1 = new QRinputItem($this->mode, $words, $this->data);
233
-                    $st2 = new QRinputItem($this->mode, $this->size - $words, array_slice($this->data, $words));
232
+					$st1 = new QRinputItem($this->mode, $words, $this->data);
233
+					$st2 = new QRinputItem($this->mode, $this->size - $words, array_slice($this->data, $words));
234 234
 
235
-                    $st1->encodeBitStream($version);
236
-                    $st2->encodeBitStream($version);
235
+					$st1->encodeBitStream($version);
236
+					$st2->encodeBitStream($version);
237 237
                     
238
-                    $this->bstream = new QRbitstream();
239
-                    $this->bstream->append($st1->bstream);
240
-                    $this->bstream->append($st2->bstream);
238
+					$this->bstream = new QRbitstream();
239
+					$this->bstream->append($st1->bstream);
240
+					$this->bstream->append($st2->bstream);
241 241
                     
242
-                    unset($st1);
243
-                    unset($st2);
242
+					unset($st1);
243
+					unset($st2);
244 244
                     
245
-                } else {
245
+				} else {
246 246
                     
247
-                    $ret = 0;
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
-                        default:
257
-                            break;
258
-                    }
256
+						default:
257
+							break;
258
+					}
259 259
                     
260
-                    if($ret < 0)
261
-                        return -1;
262
-                }
260
+					if($ret < 0)
261
+						return -1;
262
+				}
263 263
 
264
-                return $this->bstream->size();
264
+				return $this->bstream->size();
265 265
             
266
-            } catch (Exception $e) {
267
-                return -1;
268
-            }
269
-        }
270
-    };
266
+			} catch (Exception $e) {
267
+				return -1;
268
+			}
269
+		}
270
+	};
271 271
     
272
-    //##########################################################################
272
+	//##########################################################################
273 273
 
274
-    class QRinput {
274
+	class QRinput {
275 275
 
276
-        public $items;
276
+		public $items;
277 277
         
278
-        private $version;
279
-        private $level;
278
+		private $version;
279
+		private $level;
280 280
         
281
-        //----------------------------------------------------------------------
282
-        public function __construct($version = 0, $level = QR_ECLEVEL_L)
283
-        {
284
-            if ($version < 0 || $version > QRSPEC_VERSION_MAX || $level > QR_ECLEVEL_H) {
285
-                throw new Exception('Invalid version no');
286
-                return NULL;
287
-            }
281
+		//----------------------------------------------------------------------
282
+		public function __construct($version = 0, $level = QR_ECLEVEL_L)
283
+		{
284
+			if ($version < 0 || $version > QRSPEC_VERSION_MAX || $level > QR_ECLEVEL_H) {
285
+				throw new Exception('Invalid version no');
286
+				return NULL;
287
+			}
288 288
             
289
-            $this->version = $version;
290
-            $this->level = $level;
291
-        }
292
-        
293
-        //----------------------------------------------------------------------
294
-        public function getVersion()
295
-        {
296
-            return $this->version;
297
-        }
298
-        
299
-        //----------------------------------------------------------------------
300
-        public function setVersion($version)
301
-        {
302
-            if($version < 0 || $version > QRSPEC_VERSION_MAX) {
303
-                throw new Exception('Invalid version no');
304
-                return -1;
305
-            }
306
-
307
-            $this->version = $version;
308
-
309
-            return 0;
310
-        }
311
-        
312
-        //----------------------------------------------------------------------
313
-        public function getErrorCorrectionLevel()
314
-        {
315
-            return $this->level;
316
-        }
317
-
318
-        //----------------------------------------------------------------------
319
-        public function setErrorCorrectionLevel($level)
320
-        {
321
-            if($level > QR_ECLEVEL_H) {
322
-                throw new Exception('Invalid ECLEVEL');
323
-                return -1;
324
-            }
325
-
326
-            $this->level = $level;
327
-
328
-            return 0;
329
-        }
330
-        
331
-        //----------------------------------------------------------------------
332
-        public function appendEntry(QRinputItem $entry)
333
-        {
334
-            $this->items[] = $entry;
335
-        }
336
-        
337
-        //----------------------------------------------------------------------
338
-        public function append($mode, $size, $data)
339
-        {
340
-            try {
341
-                $entry = new QRinputItem($mode, $size, $data);
342
-                $this->items[] = $entry;
343
-                return 0;
344
-            } catch (Exception $e) {
345
-                return -1;
346
-            }
347
-        }
348
-        
349
-        //----------------------------------------------------------------------
350
-        
351
-        public function insertStructuredAppendHeader($size, $index, $parity)
352
-        {
353
-            if( $size > MAX_STRUCTURED_SYMBOLS ) {
354
-                throw new Exception('insertStructuredAppendHeader wrong size');
355
-            }
289
+			$this->version = $version;
290
+			$this->level = $level;
291
+		}
292
+        
293
+		//----------------------------------------------------------------------
294
+		public function getVersion()
295
+		{
296
+			return $this->version;
297
+		}
298
+        
299
+		//----------------------------------------------------------------------
300
+		public function setVersion($version)
301
+		{
302
+			if($version < 0 || $version > QRSPEC_VERSION_MAX) {
303
+				throw new Exception('Invalid version no');
304
+				return -1;
305
+			}
306
+
307
+			$this->version = $version;
308
+
309
+			return 0;
310
+		}
311
+        
312
+		//----------------------------------------------------------------------
313
+		public function getErrorCorrectionLevel()
314
+		{
315
+			return $this->level;
316
+		}
317
+
318
+		//----------------------------------------------------------------------
319
+		public function setErrorCorrectionLevel($level)
320
+		{
321
+			if($level > QR_ECLEVEL_H) {
322
+				throw new Exception('Invalid ECLEVEL');
323
+				return -1;
324
+			}
325
+
326
+			$this->level = $level;
327
+
328
+			return 0;
329
+		}
330
+        
331
+		//----------------------------------------------------------------------
332
+		public function appendEntry(QRinputItem $entry)
333
+		{
334
+			$this->items[] = $entry;
335
+		}
336
+        
337
+		//----------------------------------------------------------------------
338
+		public function append($mode, $size, $data)
339
+		{
340
+			try {
341
+				$entry = new QRinputItem($mode, $size, $data);
342
+				$this->items[] = $entry;
343
+				return 0;
344
+			} catch (Exception $e) {
345
+				return -1;
346
+			}
347
+		}
348
+        
349
+		//----------------------------------------------------------------------
350
+        
351
+		public function insertStructuredAppendHeader($size, $index, $parity)
352
+		{
353
+			if( $size > MAX_STRUCTURED_SYMBOLS ) {
354
+				throw new Exception('insertStructuredAppendHeader wrong size');
355
+			}
356 356
             
357
-            if( $index <= 0 || $index > MAX_STRUCTURED_SYMBOLS ) {
358
-                throw new Exception('insertStructuredAppendHeader wrong index');
359
-            }
357
+			if( $index <= 0 || $index > MAX_STRUCTURED_SYMBOLS ) {
358
+				throw new Exception('insertStructuredAppendHeader wrong index');
359
+			}
360 360
 
361
-            $buf = array($size, $index, $parity);
361
+			$buf = array($size, $index, $parity);
362 362
             
363
-            try {
364
-                $entry = new QRinputItem(QR_MODE_STRUCTURE, 3, buf);
365
-                array_unshift($this->items, $entry);
366
-                return 0;
367
-            } catch (Exception $e) {
368
-                return -1;
369
-            }
370
-        }
371
-
372
-        //----------------------------------------------------------------------
373
-        public function calcParity()
374
-        {
375
-            $parity = 0;
363
+			try {
364
+				$entry = new QRinputItem(QR_MODE_STRUCTURE, 3, buf);
365
+				array_unshift($this->items, $entry);
366
+				return 0;
367
+			} catch (Exception $e) {
368
+				return -1;
369
+			}
370
+		}
371
+
372
+		//----------------------------------------------------------------------
373
+		public function calcParity()
374
+		{
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--) {
380
-                        $parity ^= $item->data[$i];
381
-                    }
382
-                }
383
-            }
384
-
385
-            return $parity;
386
-        }
387
-        
388
-        //----------------------------------------------------------------------
389
-        public static function checkModeNum($size, $data)
390
-        {
391
-            for($i=0; $i<$size; $i++) {
392
-                if((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))){
393
-                    return false;
394
-                }
395
-            }
396
-
397
-            return true;
398
-        }
399
-
400
-        //----------------------------------------------------------------------
401
-        public static function estimateBitsModeNum($size)
402
-        {
403
-            $w = (int)$size / 3;
404
-            $bits = $w * 10;
377
+			foreach($this->items as $item) {
378
+				if($item->mode != QR_MODE_STRUCTURE) {
379
+					for($i=$item->size-1; $i>=0; $i--) {
380
+						$parity ^= $item->data[$i];
381
+					}
382
+				}
383
+			}
384
+
385
+			return $parity;
386
+		}
387
+        
388
+		//----------------------------------------------------------------------
389
+		public static function checkModeNum($size, $data)
390
+		{
391
+			for($i=0; $i<$size; $i++) {
392
+				if((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))){
393
+					return false;
394
+				}
395
+			}
396
+
397
+			return true;
398
+		}
399
+
400
+		//----------------------------------------------------------------------
401
+		public static function estimateBitsModeNum($size)
402
+		{
403
+			$w = (int)$size / 3;
404
+			$bits = $w * 10;
405 405
             
406
-            switch($size - $w * 3) {
407
-                case 1:
408
-                    $bits += 4;
409
-                    break;
410
-                case 2:
411
-                    $bits += 7;
412
-                    break;
413
-                default:
414
-                    break;
415
-            }
416
-
417
-            return $bits;
418
-        }
419
-        
420
-        //----------------------------------------------------------------------
421
-        public static $anTable = array(
422
-            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
423
-            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
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,
426
-            -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
427
-            25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
428
-            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
429
-            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
430
-        );
431
-        
432
-        //----------------------------------------------------------------------
433
-        public static function lookAnTable($c)
434
-        {
435
-            return (($c > 127)?-1:self::$anTable[$c]);
436
-        }
437
-        
438
-        //----------------------------------------------------------------------
439
-        public static function checkModeAn($size, $data)
440
-        {
441
-            for($i=0; $i<$size; $i++) {
442
-                if (self::lookAnTable(ord($data[$i])) == -1) {
443
-                    return false;
444
-                }
445
-            }
446
-
447
-            return true;
448
-        }
449
-        
450
-        //----------------------------------------------------------------------
451
-        public static function estimateBitsModeAn($size)
452
-        {
453
-            $w = (int)($size / 2);
454
-            $bits = $w * 11;
406
+			switch($size - $w * 3) {
407
+				case 1:
408
+					$bits += 4;
409
+					break;
410
+				case 2:
411
+					$bits += 7;
412
+					break;
413
+				default:
414
+					break;
415
+			}
416
+
417
+			return $bits;
418
+		}
419
+        
420
+		//----------------------------------------------------------------------
421
+		public static $anTable = array(
422
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
423
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
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,
426
+			-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
427
+			25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
428
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
429
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
430
+		);
431
+        
432
+		//----------------------------------------------------------------------
433
+		public static function lookAnTable($c)
434
+		{
435
+			return (($c > 127)?-1:self::$anTable[$c]);
436
+		}
437
+        
438
+		//----------------------------------------------------------------------
439
+		public static function checkModeAn($size, $data)
440
+		{
441
+			for($i=0; $i<$size; $i++) {
442
+				if (self::lookAnTable(ord($data[$i])) == -1) {
443
+					return false;
444
+				}
445
+			}
446
+
447
+			return true;
448
+		}
449
+        
450
+		//----------------------------------------------------------------------
451
+		public static function estimateBitsModeAn($size)
452
+		{
453
+			$w = (int)($size / 2);
454
+			$bits = $w * 11;
455 455
             
456
-            if($size & 1) {
457
-                $bits += 6;
458
-            }
456
+			if($size & 1) {
457
+				$bits += 6;
458
+			}
459 459
 
460
-            return $bits;
461
-        }
460
+			return $bits;
461
+		}
462 462
     
463
-        //----------------------------------------------------------------------
464
-        public static function estimateBitsMode8($size)
465
-        {
466
-            return $size * 8;
467
-        }
468
-        
469
-        //----------------------------------------------------------------------
470
-        public function estimateBitsModeKanji($size)
471
-        {
472
-            return (int)(($size / 2) * 13);
473
-        }
474
-        
475
-        //----------------------------------------------------------------------
476
-        public static function checkModeKanji($size, $data)
477
-        {
478
-            if($size & 1)
479
-                return false;
480
-
481
-            for($i=0; $i<$size; $i+=2) {
482
-                $val = (ord($data[$i]) << 8) | ord($data[$i+1]);
483
-                if( $val < 0x8140 
484
-                || ($val > 0x9ffc && $val < 0xe040) 
485
-                || $val > 0xebbf) {
486
-                    return false;
487
-                }
488
-            }
489
-
490
-            return true;
491
-        }
492
-
493
-        /***********************************************************************
463
+		//----------------------------------------------------------------------
464
+		public static function estimateBitsMode8($size)
465
+		{
466
+			return $size * 8;
467
+		}
468
+        
469
+		//----------------------------------------------------------------------
470
+		public function estimateBitsModeKanji($size)
471
+		{
472
+			return (int)(($size / 2) * 13);
473
+		}
474
+        
475
+		//----------------------------------------------------------------------
476
+		public static function checkModeKanji($size, $data)
477
+		{
478
+			if($size & 1)
479
+				return false;
480
+
481
+			for($i=0; $i<$size; $i+=2) {
482
+				$val = (ord($data[$i]) << 8) | ord($data[$i+1]);
483
+				if( $val < 0x8140 
484
+				|| ($val > 0x9ffc && $val < 0xe040) 
485
+				|| $val > 0xebbf) {
486
+					return false;
487
+				}
488
+			}
489
+
490
+			return true;
491
+		}
492
+
493
+		/***********************************************************************
494 494
          * Validation
495 495
          **********************************************************************/
496 496
 
497
-        public static function check($mode, $size, $data)
498
-        {
499
-            if($size <= 0) 
500
-                return false;
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;
505
-                case QR_MODE_KANJI:     return self::checkModeKanji($size, $data); break;
506
-                case QR_MODE_8:         return true; break;
507
-                case QR_MODE_STRUCTURE: return true; break;
497
+		public static function check($mode, $size, $data)
498
+		{
499
+			if($size <= 0) 
500
+				return false;
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;
505
+				case QR_MODE_KANJI:     return self::checkModeKanji($size, $data); break;
506
+				case QR_MODE_8:         return true; break;
507
+				case QR_MODE_STRUCTURE: return true; break;
508 508
                 
509
-                default:
510
-                    break;
511
-            }
512
-
513
-            return false;
514
-        }
515
-        
516
-        
517
-        //----------------------------------------------------------------------
518
-        public function estimateBitStreamSize($version)
519
-        {
520
-            $bits = 0;
521
-
522
-            foreach($this->items as $item) {
523
-                $bits += $item->estimateBitStreamSizeOfEntry($version);
524
-            }
525
-
526
-            return $bits;
527
-        }
528
-        
529
-        //----------------------------------------------------------------------
530
-        public function estimateVersion()
531
-        {
532
-            $version = 0;
533
-            $prev = 0;
534
-            do {
535
-                $prev = $version;
536
-                $bits = $this->estimateBitStreamSize($prev);
537
-                $version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
538
-                if ($version < 0) {
539
-                    return -1;
540
-                }
541
-            } while ($version > $prev);
542
-
543
-            return $version;
544
-        }
545
-        
546
-        //----------------------------------------------------------------------
547
-        public static function lengthOfCode($mode, $version, $bits)
548
-        {
549
-            $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version);
550
-            switch($mode) {
551
-                case QR_MODE_NUM:
552
-                    $chunks = (int)($payload / 10);
553
-                    $remain = $payload - $chunks * 10;
554
-                    $size = $chunks * 3;
555
-                    if($remain >= 7) {
556
-                        $size += 2;
557
-                    } else if($remain >= 4) {
558
-                        $size += 1;
559
-                    }
560
-                    break;
561
-                case QR_MODE_AN:
562
-                    $chunks = (int)($payload / 11);
563
-                    $remain = $payload - $chunks * 11;
564
-                    $size = $chunks * 2;
565
-                    if($remain >= 6) 
566
-                        $size++;
567
-                    break;
568
-                case QR_MODE_8:
569
-                    $size = (int)($payload / 8);
570
-                    break;
571
-                case QR_MODE_KANJI:
572
-                    $size = (int)(($payload / 13) * 2);
573
-                    break;
574
-                case QR_MODE_STRUCTURE:
575
-                    $size = (int)($payload / 8);
576
-                    break;
577
-                default:
578
-                    $size = 0;
579
-                    break;
580
-            }
509
+				default:
510
+					break;
511
+			}
512
+
513
+			return false;
514
+		}
515
+        
516
+        
517
+		//----------------------------------------------------------------------
518
+		public function estimateBitStreamSize($version)
519
+		{
520
+			$bits = 0;
521
+
522
+			foreach($this->items as $item) {
523
+				$bits += $item->estimateBitStreamSizeOfEntry($version);
524
+			}
525
+
526
+			return $bits;
527
+		}
528
+        
529
+		//----------------------------------------------------------------------
530
+		public function estimateVersion()
531
+		{
532
+			$version = 0;
533
+			$prev = 0;
534
+			do {
535
+				$prev = $version;
536
+				$bits = $this->estimateBitStreamSize($prev);
537
+				$version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
538
+				if ($version < 0) {
539
+					return -1;
540
+				}
541
+			} while ($version > $prev);
542
+
543
+			return $version;
544
+		}
545
+        
546
+		//----------------------------------------------------------------------
547
+		public static function lengthOfCode($mode, $version, $bits)
548
+		{
549
+			$payload = $bits - 4 - QRspec::lengthIndicator($mode, $version);
550
+			switch($mode) {
551
+				case QR_MODE_NUM:
552
+					$chunks = (int)($payload / 10);
553
+					$remain = $payload - $chunks * 10;
554
+					$size = $chunks * 3;
555
+					if($remain >= 7) {
556
+						$size += 2;
557
+					} else if($remain >= 4) {
558
+						$size += 1;
559
+					}
560
+					break;
561
+				case QR_MODE_AN:
562
+					$chunks = (int)($payload / 11);
563
+					$remain = $payload - $chunks * 11;
564
+					$size = $chunks * 2;
565
+					if($remain >= 6) 
566
+						$size++;
567
+					break;
568
+				case QR_MODE_8:
569
+					$size = (int)($payload / 8);
570
+					break;
571
+				case QR_MODE_KANJI:
572
+					$size = (int)(($payload / 13) * 2);
573
+					break;
574
+				case QR_MODE_STRUCTURE:
575
+					$size = (int)($payload / 8);
576
+					break;
577
+				default:
578
+					$size = 0;
579
+					break;
580
+			}
581 581
             
582
-            $maxsize = QRspec::maximumWords($mode, $version);
583
-            if($size < 0) $size = 0;
584
-            if($size > $maxsize) $size = $maxsize;
582
+			$maxsize = QRspec::maximumWords($mode, $version);
583
+			if($size < 0) $size = 0;
584
+			if($size > $maxsize) $size = $maxsize;
585 585
 
586
-            return $size;
587
-        }
586
+			return $size;
587
+		}
588 588
         
589
-        //----------------------------------------------------------------------
590
-        public function createBitStream()
591
-        {
592
-            $total = 0;
589
+		//----------------------------------------------------------------------
590
+		public function createBitStream()
591
+		{
592
+			$total = 0;
593 593
 
594
-            foreach($this->items as $item) {
595
-                $bits = $item->encodeBitStream($this->version);
594
+			foreach($this->items as $item) {
595
+				$bits = $item->encodeBitStream($this->version);
596 596
                 
597
-                if($bits < 0) 
598
-                    return -1;
597
+				if($bits < 0) 
598
+					return -1;
599 599
                     
600
-                $total += $bits;
601
-            }
602
-
603
-            return $total;
604
-        }
605
-        
606
-        //----------------------------------------------------------------------
607
-        public function convertData()
608
-        {
609
-            $ver = $this->estimateVersion();
610
-            if($ver > $this->getVersion()) {
611
-                $this->setVersion($ver);
612
-            }
613
-
614
-            for(;;) {
615
-                $bits = $this->createBitStream();
600
+				$total += $bits;
601
+			}
602
+
603
+			return $total;
604
+		}
605
+        
606
+		//----------------------------------------------------------------------
607
+		public function convertData()
608
+		{
609
+			$ver = $this->estimateVersion();
610
+			if($ver > $this->getVersion()) {
611
+				$this->setVersion($ver);
612
+			}
613
+
614
+			for(;;) {
615
+				$bits = $this->createBitStream();
616 616
                 
617
-                if($bits < 0) 
618
-                    return -1;
617
+				if($bits < 0) 
618
+					return -1;
619 619
                     
620
-                $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
621
-                if($ver < 0) {
622
-                    throw new Exception('WRONG VERSION');
623
-                    return -1;
624
-                } else if($ver > $this->getVersion()) {
625
-                    $this->setVersion($ver);
626
-                } else {
627
-                    break;
628
-                }
629
-            }
630
-
631
-            return 0;
632
-        }
633
-        
634
-        //----------------------------------------------------------------------
635
-        public function appendPaddingBit(&$bstream)
636
-        {
637
-            $bits = $bstream->size();
638
-            $maxwords = QRspec::getDataLength($this->version, $this->level);
639
-            $maxbits = $maxwords * 8;
640
-
641
-            if ($maxbits == $bits) {
642
-                return 0;
643
-            }
644
-
645
-            if ($maxbits - $bits < 5) {
646
-                return $bstream->appendNum($maxbits - $bits, 0);
647
-            }
648
-
649
-            $bits += 4;
650
-            $words = (int)(($bits + 7) / 8);
651
-
652
-            $padding = new QRbitstream();
653
-            $ret = $padding->appendNum($words * 8 - $bits + 4, 0);
620
+				$ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
621
+				if($ver < 0) {
622
+					throw new Exception('WRONG VERSION');
623
+					return -1;
624
+				} else if($ver > $this->getVersion()) {
625
+					$this->setVersion($ver);
626
+				} else {
627
+					break;
628
+				}
629
+			}
630
+
631
+			return 0;
632
+		}
633
+        
634
+		//----------------------------------------------------------------------
635
+		public function appendPaddingBit(&$bstream)
636
+		{
637
+			$bits = $bstream->size();
638
+			$maxwords = QRspec::getDataLength($this->version, $this->level);
639
+			$maxbits = $maxwords * 8;
640
+
641
+			if ($maxbits == $bits) {
642
+				return 0;
643
+			}
644
+
645
+			if ($maxbits - $bits < 5) {
646
+				return $bstream->appendNum($maxbits - $bits, 0);
647
+			}
648
+
649
+			$bits += 4;
650
+			$words = (int)(($bits + 7) / 8);
651
+
652
+			$padding = new QRbitstream();
653
+			$ret = $padding->appendNum($words * 8 - $bits + 4, 0);
654 654
             
655
-            if($ret < 0) 
656
-                return $ret;
655
+			if($ret < 0) 
656
+				return $ret;
657 657
 
658
-            $padlen = $maxwords - $words;
658
+			$padlen = $maxwords - $words;
659 659
             
660
-            if($padlen > 0) {
660
+			if($padlen > 0) {
661 661
                 
662
-                $padbuf = array();
663
-                for($i=0; $i<$padlen; $i++) {
664
-                    $padbuf[$i] = ($i&1)?0x11:0xec;
665
-                }
662
+				$padbuf = array();
663
+				for($i=0; $i<$padlen; $i++) {
664
+					$padbuf[$i] = ($i&1)?0x11:0xec;
665
+				}
666 666
                 
667
-                $ret = $padding->appendBytes($padlen, $padbuf);
667
+				$ret = $padding->appendBytes($padlen, $padbuf);
668 668
                 
669
-                if($ret < 0)
670
-                    return $ret;
669
+				if($ret < 0)
670
+					return $ret;
671 671
                 
672
-            }
672
+			}
673 673
 
674
-            $ret = $bstream->append($padding);
674
+			$ret = $bstream->append($padding);
675 675
             
676
-            return $ret;
677
-        }
676
+			return $ret;
677
+		}
678 678
 
679
-        //----------------------------------------------------------------------
680
-        public function mergeBitStream()
681
-        {
682
-            if($this->convertData() < 0) {
683
-                return null;
684
-            }
679
+		//----------------------------------------------------------------------
680
+		public function mergeBitStream()
681
+		{
682
+			if($this->convertData() < 0) {
683
+				return null;
684
+			}
685 685
 
686
-            $bstream = new QRbitstream();
686
+			$bstream = new QRbitstream();
687 687
             
688
-            foreach($this->items as $item) {
689
-                $ret = $bstream->append($item->bstream);
690
-                if($ret < 0) {
691
-                    return null;
692
-                }
693
-            }
688
+			foreach($this->items as $item) {
689
+				$ret = $bstream->append($item->bstream);
690
+				if($ret < 0) {
691
+					return null;
692
+				}
693
+			}
694 694
 
695
-            return $bstream;
696
-        }
695
+			return $bstream;
696
+		}
697 697
 
698
-        //----------------------------------------------------------------------
699
-        public function getBitStream()
700
-        {
698
+		//----------------------------------------------------------------------
699
+		public function getBitStream()
700
+		{
701 701
 
702
-            $bstream = $this->mergeBitStream();
702
+			$bstream = $this->mergeBitStream();
703 703
             
704
-            if($bstream == null) {
705
-                return null;
706
-            }
704
+			if($bstream == null) {
705
+				return null;
706
+			}
707 707
             
708
-            $ret = $this->appendPaddingBit($bstream);
709
-            if($ret < 0) {
710
-                return null;
711
-            }
712
-
713
-            return $bstream;
714
-        }
715
-        
716
-        //----------------------------------------------------------------------
717
-        public function getByteStream()
718
-        {
719
-            $bstream = $this->getBitStream();
720
-            if($bstream == null) {
721
-                return null;
722
-            }
708
+			$ret = $this->appendPaddingBit($bstream);
709
+			if($ret < 0) {
710
+				return null;
711
+			}
712
+
713
+			return $bstream;
714
+		}
715
+        
716
+		//----------------------------------------------------------------------
717
+		public function getByteStream()
718
+		{
719
+			$bstream = $this->getBitStream();
720
+			if($bstream == null) {
721
+				return null;
722
+			}
723 723
             
724
-            return $bstream->toByte();
725
-        }
726
-    }
724
+			return $bstream->toByte();
725
+		}
726
+	}
727 727
         
728 728
         
729
-    
730 729
\ No newline at end of file
730
+	
731 731
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
                 $version = 1;
202 202
 
203 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
-                case QR_MODE_STRUCTURE:    return STRUCTURE_HEADER_BITS;            
209
-                default:
210
-                    return 0;
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
+            case QR_MODE_STRUCTURE:    return STRUCTURE_HEADER_BITS;            
209
+            default:
210
+                return 0;
211 211
             }
212 212
 
213 213
             $l = QRspec::lengthIndicator($this->mode, $version);
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
                     $ret = 0;
248 248
                     
249 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;
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
-                        default:
257
-                            break;
256
+                    default:
257
+                        break;
258 258
                     }
259 259
                     
260 260
                     if($ret < 0)
@@ -404,14 +404,14 @@  discard block
 block discarded – undo
404 404
             $bits = $w * 10;
405 405
             
406 406
             switch($size - $w * 3) {
407
-                case 1:
408
-                    $bits += 4;
409
-                    break;
410
-                case 2:
411
-                    $bits += 7;
412
-                    break;
413
-                default:
414
-                    break;
407
+            case 1:
408
+                $bits += 4;
409
+                break;
410
+            case 2:
411
+                $bits += 7;
412
+                break;
413
+            default:
414
+                break;
415 415
             }
416 416
 
417 417
             return $bits;
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
                 return false;
501 501
 
502 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
-                case QR_MODE_KANJI:     return self::checkModeKanji($size, $data); break;
506
-                case QR_MODE_8:         return true; break;
507
-                case QR_MODE_STRUCTURE: return true; break;
503
+            case QR_MODE_NUM:       return self::checkModeNum($size, $data);   break;
504
+            case QR_MODE_AN:        return self::checkModeAn($size, $data);    break;
505
+            case QR_MODE_KANJI:     return self::checkModeKanji($size, $data); break;
506
+            case QR_MODE_8:         return true; break;
507
+            case QR_MODE_STRUCTURE: return true; break;
508 508
                 
509
-                default:
510
-                    break;
509
+            default:
510
+                break;
511 511
             }
512 512
 
513 513
             return false;
@@ -548,35 +548,35 @@  discard block
 block discarded – undo
548 548
         {
549 549
             $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version);
550 550
             switch($mode) {
551
-                case QR_MODE_NUM:
552
-                    $chunks = (int)($payload / 10);
553
-                    $remain = $payload - $chunks * 10;
554
-                    $size = $chunks * 3;
555
-                    if($remain >= 7) {
556
-                        $size += 2;
557
-                    } else if($remain >= 4) {
558
-                        $size += 1;
559
-                    }
560
-                    break;
561
-                case QR_MODE_AN:
562
-                    $chunks = (int)($payload / 11);
563
-                    $remain = $payload - $chunks * 11;
564
-                    $size = $chunks * 2;
565
-                    if($remain >= 6) 
566
-                        $size++;
567
-                    break;
568
-                case QR_MODE_8:
569
-                    $size = (int)($payload / 8);
570
-                    break;
571
-                case QR_MODE_KANJI:
572
-                    $size = (int)(($payload / 13) * 2);
573
-                    break;
574
-                case QR_MODE_STRUCTURE:
575
-                    $size = (int)($payload / 8);
576
-                    break;
577
-                default:
578
-                    $size = 0;
579
-                    break;
551
+            case QR_MODE_NUM:
552
+                $chunks = (int)($payload / 10);
553
+                $remain = $payload - $chunks * 10;
554
+                $size = $chunks * 3;
555
+                if($remain >= 7) {
556
+                    $size += 2;
557
+                } else if($remain >= 4) {
558
+                    $size += 1;
559
+                }
560
+                break;
561
+            case QR_MODE_AN:
562
+                $chunks = (int)($payload / 11);
563
+                $remain = $payload - $chunks * 11;
564
+                $size = $chunks * 2;
565
+                if($remain >= 6) 
566
+                    $size++;
567
+                break;
568
+            case QR_MODE_8:
569
+                $size = (int)($payload / 8);
570
+                break;
571
+            case QR_MODE_KANJI:
572
+                $size = (int)(($payload / 13) * 2);
573
+                break;
574
+            case QR_MODE_STRUCTURE:
575
+                $size = (int)($payload / 8);
576
+                break;
577
+            default:
578
+                $size = 0;
579
+                break;
580 580
             }
581 581
             
582 582
             $maxsize = QRspec::maximumWords($mode, $version);
Please login to merge, or discard this 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.
Braces   +33 added lines, -20 removed lines patch added patch discarded remove patch
@@ -197,8 +197,9 @@  discard block
 block discarded – undo
197 197
         {
198 198
             $bits = 0;
199 199
 
200
-            if($version == 0) 
201
-                $version = 1;
200
+            if($version == 0) {
201
+                            $version = 1;
202
+            }
202 203
 
203 204
             switch($this->mode) {
204 205
                 case QR_MODE_NUM:        $bits = QRinput::estimateBitsModeNum($this->size);    break;
@@ -257,8 +258,9 @@  discard block
 block discarded – undo
257 258
                             break;
258 259
                     }
259 260
                     
260
-                    if($ret < 0)
261
-                        return -1;
261
+                    if($ret < 0) {
262
+                                            return -1;
263
+                    }
262 264
                 }
263 265
 
264 266
                 return $this->bstream->size();
@@ -475,8 +477,9 @@  discard block
 block discarded – undo
475 477
         //----------------------------------------------------------------------
476 478
         public static function checkModeKanji($size, $data)
477 479
         {
478
-            if($size & 1)
479
-                return false;
480
+            if($size & 1) {
481
+                            return false;
482
+            }
480 483
 
481 484
             for($i=0; $i<$size; $i+=2) {
482 485
                 $val = (ord($data[$i]) << 8) | ord($data[$i+1]);
@@ -496,8 +499,9 @@  discard block
 block discarded – undo
496 499
 
497 500
         public static function check($mode, $size, $data)
498 501
         {
499
-            if($size <= 0) 
500
-                return false;
502
+            if($size <= 0) {
503
+                            return false;
504
+            }
501 505
 
502 506
             switch($mode) {
503 507
                 case QR_MODE_NUM:       return self::checkModeNum($size, $data);   break;
@@ -562,8 +566,9 @@  discard block
 block discarded – undo
562 566
                     $chunks = (int)($payload / 11);
563 567
                     $remain = $payload - $chunks * 11;
564 568
                     $size = $chunks * 2;
565
-                    if($remain >= 6) 
566
-                        $size++;
569
+                    if($remain >= 6) {
570
+                                            $size++;
571
+                    }
567 572
                     break;
568 573
                 case QR_MODE_8:
569 574
                     $size = (int)($payload / 8);
@@ -580,8 +585,12 @@  discard block
 block discarded – undo
580 585
             }
581 586
             
582 587
             $maxsize = QRspec::maximumWords($mode, $version);
583
-            if($size < 0) $size = 0;
584
-            if($size > $maxsize) $size = $maxsize;
588
+            if($size < 0) {
589
+            	$size = 0;
590
+            }
591
+            if($size > $maxsize) {
592
+            	$size = $maxsize;
593
+            }
585 594
 
586 595
             return $size;
587 596
         }
@@ -594,8 +603,9 @@  discard block
 block discarded – undo
594 603
             foreach($this->items as $item) {
595 604
                 $bits = $item->encodeBitStream($this->version);
596 605
                 
597
-                if($bits < 0) 
598
-                    return -1;
606
+                if($bits < 0) {
607
+                                    return -1;
608
+                }
599 609
                     
600 610
                 $total += $bits;
601 611
             }
@@ -614,8 +624,9 @@  discard block
 block discarded – undo
614 624
             for(;;) {
615 625
                 $bits = $this->createBitStream();
616 626
                 
617
-                if($bits < 0) 
618
-                    return -1;
627
+                if($bits < 0) {
628
+                                    return -1;
629
+                }
619 630
                     
620 631
                 $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
621 632
                 if($ver < 0) {
@@ -652,8 +663,9 @@  discard block
 block discarded – undo
652 663
             $padding = new QRbitstream();
653 664
             $ret = $padding->appendNum($words * 8 - $bits + 4, 0);
654 665
             
655
-            if($ret < 0) 
656
-                return $ret;
666
+            if($ret < 0) {
667
+                            return $ret;
668
+            }
657 669
 
658 670
             $padlen = $maxwords - $words;
659 671
             
@@ -666,8 +678,9 @@  discard block
 block discarded – undo
666 678
                 
667 679
                 $ret = $padding->appendBytes($padlen, $padbuf);
668 680
                 
669
-                if($ret < 0)
670
-                    return $ret;
681
+                if($ret < 0) {
682
+                                    return $ret;
683
+                }
671 684
                 
672 685
             }
673 686
 
Please login to merge, or discard this patch.
lib/phpqrcode/bindings/tcpdf/qrcode.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -173,29 +173,29 @@  discard block
 block discarded – undo
173 173
 	/**
174 174
 	 * Maximum matrix size for maximum version (version 40 is 177*177 matrix).
175 175
 	 */
176
-    define('QRSPEC_WIDTH_MAX', 177);
176
+	define('QRSPEC_WIDTH_MAX', 177);
177 177
 
178 178
 	// -----------------------------------------------------
179 179
 
180 180
 	/**
181 181
 	 * Matrix index to get width from $capacity array.
182 182
 	 */
183
-    define('QRCAP_WIDTH',    0);
183
+	define('QRCAP_WIDTH',    0);
184 184
 
185
-    /**
185
+	/**
186 186
 	 * Matrix index to get number of words from $capacity array.
187 187
 	 */
188
-    define('QRCAP_WORDS',    1);
188
+	define('QRCAP_WORDS',    1);
189 189
 
190
-    /**
190
+	/**
191 191
 	 * Matrix index to get remainder from $capacity array.
192 192
 	 */
193
-    define('QRCAP_REMINDER', 2);
193
+	define('QRCAP_REMINDER', 2);
194 194
 
195
-    /**
195
+	/**
196 196
 	 * Matrix index to get error correction level from $capacity array.
197 197
 	 */
198
-    define('QRCAP_EC',       3);
198
+	define('QRCAP_EC',       3);
199 199
 
200 200
 	// -----------------------------------------------------
201 201
 
@@ -204,33 +204,33 @@  discard block
 block discarded – undo
204 204
 	/**
205 205
 	 * Number of header bits for structured mode
206 206
 	 */
207
-    define('STRUCTURE_HEADER_BITS',  20);
207
+	define('STRUCTURE_HEADER_BITS',  20);
208 208
 
209
-    /**
209
+	/**
210 210
 	 * Max number of symbols for structured mode
211 211
 	 */
212
-    define('MAX_STRUCTURED_SYMBOLS', 16);
212
+	define('MAX_STRUCTURED_SYMBOLS', 16);
213 213
 
214 214
 	// -----------------------------------------------------
215 215
 
216
-    // Masks
216
+	// Masks
217 217
 
218
-    /**
218
+	/**
219 219
 	 * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column)
220 220
 	 */
221
-    define('N1',  3);
221
+	define('N1',  3);
222 222
 
223
-    /**
223
+	/**
224 224
 	 * Down point base value for case 2 mask pattern (module block of same color)
225 225
 	 */
226 226
 	define('N2',  3);
227 227
 
228
-    /**
228
+	/**
229 229
 	 * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column)
230 230
 	 */
231 231
 	define('N3', 40);
232 232
 
233
-    /**
233
+	/**
234 234
 	 * Down point base value for case 4 mask pattern (ration of dark modules in whole)
235 235
 	 */
236 236
 	define('N4', 10);
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 
265 265
 	// for compaibility with PHP4
266 266
 	if (!function_exists('str_split')) {
267
-    	/**
268
-    	 * Convert a string to an array (needed for PHP4 compatibility)
269
-    	 * @param string $string The input string.
270
-    	 * @param int $split_length Maximum length of the chunk.
271
-    	 * @return  If the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
272
-    	 */
267
+		/**
268
+		 * Convert a string to an array (needed for PHP4 compatibility)
269
+		 * @param string $string The input string.
270
+		 * @param int $split_length Maximum length of the chunk.
271
+		 * @return  If the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
272
+		 */
273 273
 		function str_split($string, $split_length=1) {
274 274
 			if ((strlen($string) > $split_length) OR (!$split_length)) {
275 275
 				do {
@@ -2622,7 +2622,7 @@  discard block
 block discarded – undo
2622 2622
 		}
2623 2623
 
2624 2624
 		/**
2625
-		* Return block number 1
2625
+		 * Return block number 1
2626 2626
 		 * @param array $spec
2627 2627
 		 * @return int value
2628 2628
 		 */
Please login to merge, or discard this patch.
Switch Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -1461,26 +1461,26 @@  discard block
 block discarded – undo
1461 1461
 				}
1462 1462
 				$mode = $this->identifyMode(0);
1463 1463
 				switch ($mode) {
1464
-					case QR_MODE_NM: {
1465
-						$length = $this->eatNum();
1466
-						break;
1467
-					}
1468
-					case QR_MODE_AN: {
1469
-						$length = $this->eatAn();
1470
-						break;
1471
-					}
1472
-					case QR_MODE_KJ: {
1473
-						if ($this->hint == QR_MODE_KJ) {
1474
-							$length = $this->eatKanji();
1475
-						} else {
1476
-							$length = $this->eat8();
1477
-						}
1478
-						break;
1479
-					}
1480
-					default: {
1464
+				case QR_MODE_NM: {
1465
+					$length = $this->eatNum();
1466
+					break;
1467
+				}
1468
+				case QR_MODE_AN: {
1469
+					$length = $this->eatAn();
1470
+					break;
1471
+				}
1472
+				case QR_MODE_KJ: {
1473
+					if ($this->hint == QR_MODE_KJ) {
1474
+						$length = $this->eatKanji();
1475
+					} else {
1481 1476
 						$length = $this->eat8();
1482
-						break;
1483 1477
 					}
1478
+					break;
1479
+				}
1480
+				default: {
1481
+					$length = $this->eat8();
1482
+					break;
1483
+				}
1484 1484
 				}
1485 1485
 				if ($length == 0) {
1486 1486
 					return 0;
@@ -1665,29 +1665,29 @@  discard block
 block discarded – undo
1665 1665
 				$inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']);
1666 1666
 			} else {
1667 1667
 				switch($inputitem['mode']) {
1668
-					case QR_MODE_NM: {
1669
-						$inputitem = $this->encodeModeNum($inputitem, $version);
1670
-						break;
1671
-					}
1672
-					case QR_MODE_AN: {
1673
-						$inputitem = $this->encodeModeAn($inputitem, $version);
1674
-						break;
1675
-					}
1676
-					case QR_MODE_8B: {
1677
-						$inputitem = $this->encodeMode8($inputitem, $version);
1678
-						break;
1679
-					}
1680
-					case QR_MODE_KJ: {
1681
-						$inputitem = $this->encodeModeKanji($inputitem, $version);
1682
-						break;
1683
-					}
1684
-					case QR_MODE_ST: {
1685
-						$inputitem = $this->encodeModeStructure($inputitem);
1686
-						break;
1687
-					}
1688
-					default: {
1689
-						break;
1690
-					}
1668
+				case QR_MODE_NM: {
1669
+					$inputitem = $this->encodeModeNum($inputitem, $version);
1670
+					break;
1671
+				}
1672
+				case QR_MODE_AN: {
1673
+					$inputitem = $this->encodeModeAn($inputitem, $version);
1674
+					break;
1675
+				}
1676
+				case QR_MODE_8B: {
1677
+					$inputitem = $this->encodeMode8($inputitem, $version);
1678
+					break;
1679
+				}
1680
+				case QR_MODE_KJ: {
1681
+					$inputitem = $this->encodeModeKanji($inputitem, $version);
1682
+					break;
1683
+				}
1684
+				case QR_MODE_ST: {
1685
+					$inputitem = $this->encodeModeStructure($inputitem);
1686
+					break;
1687
+				}
1688
+				default: {
1689
+					break;
1690
+				}
1691 1691
 				}
1692 1692
 			}
1693 1693
 			return $inputitem;
@@ -1774,17 +1774,17 @@  discard block
 block discarded – undo
1774 1774
 			$w = (int)$size / 3;
1775 1775
 			$bits = $w * 10;
1776 1776
 			switch($size - $w * 3) {
1777
-				case 1: {
1778
-					$bits += 4;
1779
-					break;
1780
-				}
1781
-				case 2: {
1782
-					$bits += 7;
1783
-					break;
1784
-				}
1785
-				default: {
1786
-					break;
1787
-				}
1777
+			case 1: {
1778
+				$bits += 4;
1779
+				break;
1780
+			}
1781
+			case 2: {
1782
+				$bits += 7;
1783
+				break;
1784
+			}
1785
+			default: {
1786
+				break;
1787
+			}
1788 1788
 			}
1789 1789
 			return $bits;
1790 1790
 		}
@@ -1876,24 +1876,24 @@  discard block
 block discarded – undo
1876 1876
 				return false;
1877 1877
 			}
1878 1878
 			switch($mode) {
1879
-				case QR_MODE_NM: {
1880
-					return $this->checkModeNum($size, $data);
1881
-				}
1882
-				case QR_MODE_AN: {
1883
-					return $this->checkModeAn($size, $data);
1884
-				}
1885
-				case QR_MODE_KJ: {
1886
-					return $this->checkModeKanji($size, $data);
1887
-				}
1888
-				case QR_MODE_8B: {
1889
-					return true;
1890
-				}
1891
-				case QR_MODE_ST: {
1892
-					return true;
1893
-				}
1894
-				default: {
1895
-					break;
1896
-				}
1879
+			case QR_MODE_NM: {
1880
+				return $this->checkModeNum($size, $data);
1881
+			}
1882
+			case QR_MODE_AN: {
1883
+				return $this->checkModeAn($size, $data);
1884
+			}
1885
+			case QR_MODE_KJ: {
1886
+				return $this->checkModeKanji($size, $data);
1887
+			}
1888
+			case QR_MODE_8B: {
1889
+				return true;
1890
+			}
1891
+			case QR_MODE_ST: {
1892
+				return true;
1893
+			}
1894
+			default: {
1895
+				break;
1896
+			}
1897 1897
 			}
1898 1898
 			return false;
1899 1899
 		}
@@ -1911,28 +1911,28 @@  discard block
 block discarded – undo
1911 1911
 			}
1912 1912
 			foreach ($items as $item) {
1913 1913
 				switch($item['mode']) {
1914
-					case QR_MODE_NM: {
1915
-						$bits = $this->estimateBitsModeNum($item['size']);
1916
-						break;
1917
-					}
1918
-					case QR_MODE_AN: {
1919
-						$bits = $this->estimateBitsModeAn($item['size']);
1920
-						break;
1921
-					}
1922
-					case QR_MODE_8B: {
1923
-						$bits = $this->estimateBitsMode8($item['size']);
1924
-						break;
1925
-					}
1926
-					case QR_MODE_KJ: {
1927
-						$bits = $this->estimateBitsModeKanji($item['size']);
1928
-						break;
1929
-					}
1930
-					case QR_MODE_ST: {
1931
-						return STRUCTURE_HEADER_BITS;
1932
-					}
1933
-					default: {
1934
-						return 0;
1935
-					}
1914
+				case QR_MODE_NM: {
1915
+					$bits = $this->estimateBitsModeNum($item['size']);
1916
+					break;
1917
+				}
1918
+				case QR_MODE_AN: {
1919
+					$bits = $this->estimateBitsModeAn($item['size']);
1920
+					break;
1921
+				}
1922
+				case QR_MODE_8B: {
1923
+					$bits = $this->estimateBitsMode8($item['size']);
1924
+					break;
1925
+				}
1926
+				case QR_MODE_KJ: {
1927
+					$bits = $this->estimateBitsModeKanji($item['size']);
1928
+					break;
1929
+				}
1930
+				case QR_MODE_ST: {
1931
+					return STRUCTURE_HEADER_BITS;
1932
+				}
1933
+				default: {
1934
+					return 0;
1935
+				}
1936 1936
 				}
1937 1937
 				$l = $this->lengthIndicator($item['mode'], $version);
1938 1938
 				$m = 1 << $l;
@@ -1971,42 +1971,42 @@  discard block
 block discarded – undo
1971 1971
 		 protected function lengthOfCode($mode, $version, $bits) {
1972 1972
 			$payload = $bits - 4 - $this->lengthIndicator($mode, $version);
1973 1973
 			switch($mode) {
1974
-				case QR_MODE_NM: {
1975
-					$chunks = (int)($payload / 10);
1976
-					$remain = $payload - $chunks * 10;
1977
-					$size = $chunks * 3;
1978
-					if ($remain >= 7) {
1979
-						$size += 2;
1980
-					} elseif ($remain >= 4) {
1981
-						$size += 1;
1982
-					}
1983
-					break;
1984
-				}
1985
-				case QR_MODE_AN: {
1986
-					$chunks = (int)($payload / 11);
1987
-					$remain = $payload - $chunks * 11;
1988
-					$size = $chunks * 2;
1989
-					if ($remain >= 6) {
1990
-						++$size;
1991
-					}
1992
-					break;
1993
-				}
1994
-				case QR_MODE_8B: {
1995
-					$size = (int)($payload / 8);
1996
-					break;
1997
-				}
1998
-				case QR_MODE_KJ: {
1999
-					$size = (int)(($payload / 13) * 2);
2000
-					break;
2001
-				}
2002
-				case QR_MODE_ST: {
2003
-					$size = (int)($payload / 8);
2004
-					break;
2005
-				}
2006
-				default: {
2007
-					$size = 0;
2008
-					break;
2009
-				}
1974
+			case QR_MODE_NM: {
1975
+				$chunks = (int)($payload / 10);
1976
+				$remain = $payload - $chunks * 10;
1977
+				$size = $chunks * 3;
1978
+				if ($remain >= 7) {
1979
+					$size += 2;
1980
+				} elseif ($remain >= 4) {
1981
+					$size += 1;
1982
+				}
1983
+				break;
1984
+			}
1985
+			case QR_MODE_AN: {
1986
+				$chunks = (int)($payload / 11);
1987
+				$remain = $payload - $chunks * 11;
1988
+				$size = $chunks * 2;
1989
+				if ($remain >= 6) {
1990
+					++$size;
1991
+				}
1992
+				break;
1993
+			}
1994
+			case QR_MODE_8B: {
1995
+				$size = (int)($payload / 8);
1996
+				break;
1997
+			}
1998
+			case QR_MODE_KJ: {
1999
+				$size = (int)(($payload / 13) * 2);
2000
+				break;
2001
+			}
2002
+			case QR_MODE_ST: {
2003
+				$size = (int)($payload / 8);
2004
+				break;
2005
+			}
2006
+			default: {
2007
+				$size = 0;
2008
+				break;
2009
+			}
2010 2010
 			}
2011 2011
 			$maxsize = $this->maximumWords($mode, $version);
2012 2012
 			if ($size < 0) {
Please login to merge, or discard this patch.
Spacing   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 	/**
181 181
 	 * Matrix index to get width from $capacity array.
182 182
 	 */
183
-    define('QRCAP_WIDTH',    0);
183
+    define('QRCAP_WIDTH', 0);
184 184
 
185 185
     /**
186 186
 	 * Matrix index to get number of words from $capacity array.
187 187
 	 */
188
-    define('QRCAP_WORDS',    1);
188
+    define('QRCAP_WORDS', 1);
189 189
 
190 190
     /**
191 191
 	 * Matrix index to get remainder from $capacity array.
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     /**
196 196
 	 * Matrix index to get error correction level from $capacity array.
197 197
 	 */
198
-    define('QRCAP_EC',       3);
198
+    define('QRCAP_EC', 3);
199 199
 
200 200
 	// -----------------------------------------------------
201 201
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	/**
205 205
 	 * Number of header bits for structured mode
206 206
 	 */
207
-    define('STRUCTURE_HEADER_BITS',  20);
207
+    define('STRUCTURE_HEADER_BITS', 20);
208 208
 
209 209
     /**
210 210
 	 * Max number of symbols for structured mode
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
     /**
219 219
 	 * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column)
220 220
 	 */
221
-    define('N1',  3);
221
+    define('N1', 3);
222 222
 
223 223
     /**
224 224
 	 * Down point base value for case 2 mask pattern (module block of same color)
225 225
 	 */
226
-	define('N2',  3);
226
+	define('N2', 3);
227 227
 
228 228
     /**
229 229
 	 * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column)
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     	 * @param int $split_length Maximum length of the chunk.
271 271
     	 * @return  If the optional split_length  parameter is specified, the returned array will be broken down into chunks with each being split_length  in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
272 272
     	 */
273
-		function str_split($string, $split_length=1) {
273
+		function str_split($string, $split_length = 1) {
274 274
 			if ((strlen($string) > $split_length) OR (!$split_length)) {
275 275
 				do {
276 276
 					$c = strlen($string);
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
482 482
 			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
483 483
 			36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, //
484
-			 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 44, -1, -1, -1, -1, -1, //
484
+			 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, //
485 485
 			-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, //
486 486
 			25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, //
487 487
 			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
@@ -494,47 +494,47 @@  discard block
 block discarded – undo
494 494
 		 * @access protected
495 495
 		 */
496 496
 		protected $capacity = array(
497
-			array(  0,    0, 0, array(   0,    0,    0,    0)), //
498
-			array( 21,   26, 0, array(   7,   10,   13,   17)), //  1
499
-			array( 25,   44, 7, array(  10,   16,   22,   28)), //
500
-			array( 29,   70, 7, array(  15,   26,   36,   44)), //
501
-			array( 33,  100, 7, array(  20,   36,   52,   64)), //
502
-			array( 37,  134, 7, array(  26,   48,   72,   88)), //  5
503
-			array( 41,  172, 7, array(  36,   64,   96,  112)), //
504
-			array( 45,  196, 0, array(  40,   72,  108,  130)), //
505
-			array( 49,  242, 0, array(  48,   88,  132,  156)), //
506
-			array( 53,  292, 0, array(  60,  110,  160,  192)), //
507
-			array( 57,  346, 0, array(  72,  130,  192,  224)), // 10
508
-			array( 61,  404, 0, array(  80,  150,  224,  264)), //
509
-			array( 65,  466, 0, array(  96,  176,  260,  308)), //
510
-			array( 69,  532, 0, array( 104,  198,  288,  352)), //
511
-			array( 73,  581, 3, array( 120,  216,  320,  384)), //
512
-			array( 77,  655, 3, array( 132,  240,  360,  432)), // 15
513
-			array( 81,  733, 3, array( 144,  280,  408,  480)), //
514
-			array( 85,  815, 3, array( 168,  308,  448,  532)), //
515
-			array( 89,  901, 3, array( 180,  338,  504,  588)), //
516
-			array( 93,  991, 3, array( 196,  364,  546,  650)), //
517
-			array( 97, 1085, 3, array( 224,  416,  600,  700)), // 20
518
-			array(101, 1156, 4, array( 224,  442,  644,  750)), //
519
-			array(105, 1258, 4, array( 252,  476,  690,  816)), //
520
-			array(109, 1364, 4, array( 270,  504,  750,  900)), //
521
-			array(113, 1474, 4, array( 300,  560,  810,  960)), //
522
-			array(117, 1588, 4, array( 312,  588,  870, 1050)), // 25
523
-			array(121, 1706, 4, array( 336,  644,  952, 1110)), //
524
-			array(125, 1828, 4, array( 360,  700, 1020, 1200)), //
525
-			array(129, 1921, 3, array( 390,  728, 1050, 1260)), //
526
-			array(133, 2051, 3, array( 420,  784, 1140, 1350)), //
527
-			array(137, 2185, 3, array( 450,  812, 1200, 1440)), // 30
528
-			array(141, 2323, 3, array( 480,  868, 1290, 1530)), //
529
-			array(145, 2465, 3, array( 510,  924, 1350, 1620)), //
530
-			array(149, 2611, 3, array( 540,  980, 1440, 1710)), //
531
-			array(153, 2761, 3, array( 570, 1036, 1530, 1800)), //
532
-			array(157, 2876, 0, array( 570, 1064, 1590, 1890)), // 35
533
-			array(161, 3034, 0, array( 600, 1120, 1680, 1980)), //
534
-			array(165, 3196, 0, array( 630, 1204, 1770, 2100)), //
535
-			array(169, 3362, 0, array( 660, 1260, 1860, 2220)), //
536
-			array(173, 3532, 0, array( 720, 1316, 1950, 2310)), //
537
-			array(177, 3706, 0, array( 750, 1372, 2040, 2430))  // 40
497
+			array(0, 0, 0, array(0, 0, 0, 0)), //
498
+			array(21, 26, 0, array(7, 10, 13, 17)), //  1
499
+			array(25, 44, 7, array(10, 16, 22, 28)), //
500
+			array(29, 70, 7, array(15, 26, 36, 44)), //
501
+			array(33, 100, 7, array(20, 36, 52, 64)), //
502
+			array(37, 134, 7, array(26, 48, 72, 88)), //  5
503
+			array(41, 172, 7, array(36, 64, 96, 112)), //
504
+			array(45, 196, 0, array(40, 72, 108, 130)), //
505
+			array(49, 242, 0, array(48, 88, 132, 156)), //
506
+			array(53, 292, 0, array(60, 110, 160, 192)), //
507
+			array(57, 346, 0, array(72, 130, 192, 224)), // 10
508
+			array(61, 404, 0, array(80, 150, 224, 264)), //
509
+			array(65, 466, 0, array(96, 176, 260, 308)), //
510
+			array(69, 532, 0, array(104, 198, 288, 352)), //
511
+			array(73, 581, 3, array(120, 216, 320, 384)), //
512
+			array(77, 655, 3, array(132, 240, 360, 432)), // 15
513
+			array(81, 733, 3, array(144, 280, 408, 480)), //
514
+			array(85, 815, 3, array(168, 308, 448, 532)), //
515
+			array(89, 901, 3, array(180, 338, 504, 588)), //
516
+			array(93, 991, 3, array(196, 364, 546, 650)), //
517
+			array(97, 1085, 3, array(224, 416, 600, 700)), // 20
518
+			array(101, 1156, 4, array(224, 442, 644, 750)), //
519
+			array(105, 1258, 4, array(252, 476, 690, 816)), //
520
+			array(109, 1364, 4, array(270, 504, 750, 900)), //
521
+			array(113, 1474, 4, array(300, 560, 810, 960)), //
522
+			array(117, 1588, 4, array(312, 588, 870, 1050)), // 25
523
+			array(121, 1706, 4, array(336, 644, 952, 1110)), //
524
+			array(125, 1828, 4, array(360, 700, 1020, 1200)), //
525
+			array(129, 1921, 3, array(390, 728, 1050, 1260)), //
526
+			array(133, 2051, 3, array(420, 784, 1140, 1350)), //
527
+			array(137, 2185, 3, array(450, 812, 1200, 1440)), // 30
528
+			array(141, 2323, 3, array(480, 868, 1290, 1530)), //
529
+			array(145, 2465, 3, array(510, 924, 1350, 1620)), //
530
+			array(149, 2611, 3, array(540, 980, 1440, 1710)), //
531
+			array(153, 2761, 3, array(570, 1036, 1530, 1800)), //
532
+			array(157, 2876, 0, array(570, 1064, 1590, 1890)), // 35
533
+			array(161, 3034, 0, array(600, 1120, 1680, 1980)), //
534
+			array(165, 3196, 0, array(630, 1204, 1770, 2100)), //
535
+			array(169, 3362, 0, array(660, 1260, 1860, 2220)), //
536
+			array(173, 3532, 0, array(720, 1316, 1950, 2310)), //
537
+			array(177, 3706, 0, array(750, 1372, 2040, 2430))  // 40
538 538
 		);
539 539
 
540 540
 		/**
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 		 */
544 544
 		protected $lengthTableBits = array(
545 545
 			array(10, 12, 14),
546
-			array( 9, 11, 13),
547
-			array( 8, 16, 16),
548
-			array( 8, 10, 12)
546
+			array(9, 11, 13),
547
+			array(8, 16, 16),
548
+			array(8, 10, 12)
549 549
 		);
550 550
 
551 551
 		/**
@@ -554,47 +554,47 @@  discard block
 block discarded – undo
554 554
 		 * @access protected
555 555
 		 */
556 556
 		protected $eccTable = array(
557
-			array(array( 0,  0), array( 0,  0), array( 0,  0), array( 0,  0)), //
558
-			array(array( 1,  0), array( 1,  0), array( 1,  0), array( 1,  0)), //  1
559
-			array(array( 1,  0), array( 1,  0), array( 1,  0), array( 1,  0)), //
560
-			array(array( 1,  0), array( 1,  0), array( 2,  0), array( 2,  0)), //
561
-			array(array( 1,  0), array( 2,  0), array( 2,  0), array( 4,  0)), //
562
-			array(array( 1,  0), array( 2,  0), array( 2,  2), array( 2,  2)), //  5
563
-			array(array( 2,  0), array( 4,  0), array( 4,  0), array( 4,  0)), //
564
-			array(array( 2,  0), array( 4,  0), array( 2,  4), array( 4,  1)), //
565
-			array(array( 2,  0), array( 2,  2), array( 4,  2), array( 4,  2)), //
566
-			array(array( 2,  0), array( 3,  2), array( 4,  4), array( 4,  4)), //
567
-			array(array( 2,  2), array( 4,  1), array( 6,  2), array( 6,  2)), // 10
568
-			array(array( 4,  0), array( 1,  4), array( 4,  4), array( 3,  8)), //
569
-			array(array( 2,  2), array( 6,  2), array( 4,  6), array( 7,  4)), //
570
-			array(array( 4,  0), array( 8,  1), array( 8,  4), array(12,  4)), //
571
-			array(array( 3,  1), array( 4,  5), array(11,  5), array(11,  5)), //
572
-			array(array( 5,  1), array( 5,  5), array( 5,  7), array(11,  7)), // 15
573
-			array(array( 5,  1), array( 7,  3), array(15,  2), array( 3, 13)), //
574
-			array(array( 1,  5), array(10,  1), array( 1, 15), array( 2, 17)), //
575
-			array(array( 5,  1), array( 9,  4), array(17,  1), array( 2, 19)), //
576
-			array(array( 3,  4), array( 3, 11), array(17,  4), array( 9, 16)), //
577
-			array(array( 3,  5), array( 3, 13), array(15,  5), array(15, 10)), // 20
578
-			array(array( 4,  4), array(17,  0), array(17,  6), array(19,  6)), //
579
-			array(array( 2,  7), array(17,  0), array( 7, 16), array(34,  0)), //
580
-			array(array( 4,  5), array( 4, 14), array(11, 14), array(16, 14)), //
581
-			array(array( 6,  4), array( 6, 14), array(11, 16), array(30,  2)), //
582
-			array(array( 8,  4), array( 8, 13), array( 7, 22), array(22, 13)), // 25
583
-			array(array(10,  2), array(19,  4), array(28,  6), array(33,  4)), //
584
-			array(array( 8,  4), array(22,  3), array( 8, 26), array(12, 28)), //
585
-			array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)), //
586
-			array(array( 7,  7), array(21,  7), array( 1, 37), array(19, 26)), //
587
-			array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30
588
-			array(array(13,  3), array( 2, 29), array(42,  1), array(23, 28)), //
589
-			array(array(17,  0), array(10, 23), array(10, 35), array(19, 35)), //
590
-			array(array(17,  1), array(14, 21), array(29, 19), array(11, 46)), //
591
-			array(array(13,  6), array(14, 23), array(44,  7), array(59,  1)), //
592
-			array(array(12,  7), array(12, 26), array(39, 14), array(22, 41)), // 35
593
-			array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)), //
594
-			array(array(17,  4), array(29, 14), array(49, 10), array(24, 46)), //
595
-			array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)), //
596
-			array(array(20,  4), array(40,  7), array(43, 22), array(10, 67)), //
597
-			array(array(19,  6), array(18, 31), array(34, 34), array(20, 61))  // 40
557
+			array(array(0, 0), array(0, 0), array(0, 0), array(0, 0)), //
558
+			array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), //  1
559
+			array(array(1, 0), array(1, 0), array(1, 0), array(1, 0)), //
560
+			array(array(1, 0), array(1, 0), array(2, 0), array(2, 0)), //
561
+			array(array(1, 0), array(2, 0), array(2, 0), array(4, 0)), //
562
+			array(array(1, 0), array(2, 0), array(2, 2), array(2, 2)), //  5
563
+			array(array(2, 0), array(4, 0), array(4, 0), array(4, 0)), //
564
+			array(array(2, 0), array(4, 0), array(2, 4), array(4, 1)), //
565
+			array(array(2, 0), array(2, 2), array(4, 2), array(4, 2)), //
566
+			array(array(2, 0), array(3, 2), array(4, 4), array(4, 4)), //
567
+			array(array(2, 2), array(4, 1), array(6, 2), array(6, 2)), // 10
568
+			array(array(4, 0), array(1, 4), array(4, 4), array(3, 8)), //
569
+			array(array(2, 2), array(6, 2), array(4, 6), array(7, 4)), //
570
+			array(array(4, 0), array(8, 1), array(8, 4), array(12, 4)), //
571
+			array(array(3, 1), array(4, 5), array(11, 5), array(11, 5)), //
572
+			array(array(5, 1), array(5, 5), array(5, 7), array(11, 7)), // 15
573
+			array(array(5, 1), array(7, 3), array(15, 2), array(3, 13)), //
574
+			array(array(1, 5), array(10, 1), array(1, 15), array(2, 17)), //
575
+			array(array(5, 1), array(9, 4), array(17, 1), array(2, 19)), //
576
+			array(array(3, 4), array(3, 11), array(17, 4), array(9, 16)), //
577
+			array(array(3, 5), array(3, 13), array(15, 5), array(15, 10)), // 20
578
+			array(array(4, 4), array(17, 0), array(17, 6), array(19, 6)), //
579
+			array(array(2, 7), array(17, 0), array(7, 16), array(34, 0)), //
580
+			array(array(4, 5), array(4, 14), array(11, 14), array(16, 14)), //
581
+			array(array(6, 4), array(6, 14), array(11, 16), array(30, 2)), //
582
+			array(array(8, 4), array(8, 13), array(7, 22), array(22, 13)), // 25
583
+			array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), //
584
+			array(array(8, 4), array(22, 3), array(8, 26), array(12, 28)), //
585
+			array(array(3, 10), array(3, 23), array(4, 31), array(11, 31)), //
586
+			array(array(7, 7), array(21, 7), array(1, 37), array(19, 26)), //
587
+			array(array(5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30
588
+			array(array(13, 3), array(2, 29), array(42, 1), array(23, 28)), //
589
+			array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), //
590
+			array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), //
591
+			array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), //
592
+			array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35
593
+			array(array(6, 14), array(6, 34), array(46, 10), array(2, 64)), //
594
+			array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), //
595
+			array(array(4, 18), array(13, 32), array(48, 14), array(42, 32)), //
596
+			array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), //
597
+			array(array(19, 6), array(18, 31), array(34, 34), array(20, 61))  // 40
598 598
 		);
599 599
 
600 600
 		/**
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 		 * @access protected
605 605
 		 */
606 606
 		protected $alignmentPattern = array(
607
-			array( 0,  0),
608
-			array( 0,  0), array(18,  0), array(22,  0), array(26,  0), array(30,  0), //  1- 5
609
-			array(34,  0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), //  6-10
607
+			array(0, 0),
608
+			array(0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), //  1- 5
609
+			array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), //  6-10
610 610
 			array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), // 11-15
611 611
 			array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), // 16-20
612 612
 			array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), // 21-25
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 			foreach ($qrTab as $line) {
680 680
 				$arrAdd = array();
681 681
 				foreach (str_split($line) as $char) {
682
-					$arrAdd[] = ($char=='1')?1:0;
682
+					$arrAdd[] = ($char == '1') ? 1 : 0;
683 683
 				}
684 684
 				$barcode_array['bcode'][] = $arrAdd;
685 685
 			}
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 			$len = count($frame);
705 705
 			// the frame is square (width = height)
706 706
 			foreach ($frame as &$frameLine) {
707
-				for ($i=0; $i<$len; $i++) {
708
-					$frameLine[$i] = (ord($frameLine[$i])&1)?'1':'0';
707
+				for ($i = 0; $i < $len; $i++) {
708
+					$frameLine[$i] = (ord($frameLine[$i]) & 1) ? '1' : '0';
709 709
 				}
710 710
 			}
711 711
 			return $frame;
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
 			$this->dir = -1;
756 756
 			$this->bit = -1;
757 757
 			// inteleaved data and ecc codes
758
-			for ($i=0; $i < ($this->dataLength + $this->eccLength); $i++) {
758
+			for ($i = 0; $i < ($this->dataLength + $this->eccLength); $i++) {
759 759
 				$code = $this->getCode();
760 760
 				$bit = 0x80;
761
-				for ($j=0; $j<8; $j++) {
761
+				for ($j = 0; $j < 8; $j++) {
762 762
 					$addr = $this->getNextPosition();
763 763
 					$this->setFrameAt($addr, 0x02 | (($bit & $code) != 0));
764 764
 					$bit = $bit >> 1;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 			}
767 767
 			// remainder bits
768 768
 			$j = $this->getRemainder($this->version);
769
-			for ($i=0; $i<$j; $i++) {
769
+			for ($i = 0; $i < $j; $i++) {
770 770
 				$addr = $this->getNextPosition();
771 771
 				$this->setFrameAt($addr, 0x02);
772 772
 			}
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 				}
857 857
 				$this->x = $x;
858 858
 				$this->y = $y;
859
-			} while(ord($this->frame[$y][$x]) & 0x80);
859
+			} while (ord($this->frame[$y][$x]) & 0x80);
860 860
 			return array('x'=>$x, 'y'=>$y);
861 861
 		}
862 862
 
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 			$dataPos = 0;
878 878
 			$eccPos = 0;
879 879
 			$endfor = $this->rsBlockNum1($spec);
880
-			for ($i=0; $i < $endfor; ++$i) {
880
+			for ($i = 0; $i < $endfor; ++$i) {
881 881
 				$ecc = array_slice($this->ecccode, $eccPos);
882 882
 				$this->rsblocks[$blockNo] = array();
883 883
 				$this->rsblocks[$blockNo]['dataLength'] = $dl;
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 				$this->rsblocks[$blockNo]['eccLength'] = $el;
886 886
 				$ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc);
887 887
 				$this->rsblocks[$blockNo]['ecc'] = $ecc;
888
-				$this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
888
+				$this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc);
889 889
 				$dataPos += $dl;
890 890
 				$eccPos += $el;
891 891
 				$blockNo++;
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 				return -1;
901 901
 			}
902 902
 			$endfor = $this->rsBlockNum2($spec);
903
-			for ($i=0; $i < $endfor; ++$i) {
903
+			for ($i = 0; $i < $endfor; ++$i) {
904 904
 				$ecc = array_slice($this->ecccode, $eccPos);
905 905
 				$this->rsblocks[$blockNo] = array();
906 906
 				$this->rsblocks[$blockNo]['dataLength'] = $dl;
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 		 */
954 954
 		 protected function writeFormatInformation($width, &$frame, $mask, $level) {
955 955
 			$blacks = 0;
956
-			$format =  $this->getFormatInfo($mask, $level);
957
-			for ($i=0; $i<8; ++$i) {
956
+			$format = $this->getFormatInfo($mask, $level);
957
+			for ($i = 0; $i < 8; ++$i) {
958 958
 				if ($format & 1) {
959 959
 					$blacks += 2;
960 960
 					$v = 0x85;
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 				}
970 970
 				$format = $format >> 1;
971 971
 			}
972
-			for ($i=0; $i<7; ++$i) {
972
+			for ($i = 0; $i < 7; ++$i) {
973 973
 			if ($format & 1) {
974 974
 				$blacks += 2;
975 975
 				$v = 0x85;
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 		 * @return int mask
1035 1035
 		 */
1036 1036
 		 protected function mask4($x, $y) {
1037
-			return (((int)($y / 2)) + ((int)($x / 3))) & 1;
1037
+			return (((int) ($y / 2)) + ((int) ($x / 3))) & 1;
1038 1038
 		}
1039 1039
 
1040 1040
 		/**
@@ -1076,13 +1076,13 @@  discard block
 block discarded – undo
1076 1076
 		 */
1077 1077
 		protected function generateMaskNo($maskNo, $width, $frame) {
1078 1078
 			$bitMask = array_fill(0, $width, array_fill(0, $width, 0));
1079
-			for ($y=0; $y<$width; ++$y) {
1080
-				for ($x=0; $x<$width; ++$x) {
1079
+			for ($y = 0; $y < $width; ++$y) {
1080
+				for ($x = 0; $x < $width; ++$x) {
1081 1081
 					if (ord($frame[$y][$x]) & 0x80) {
1082 1082
 						$bitMask[$y][$x] = 0;
1083 1083
 					} else {
1084 1084
 						$maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y);
1085
-						$bitMask[$y][$x] = ($maskFunc == 0)?1:0;
1085
+						$bitMask[$y][$x] = ($maskFunc == 0) ? 1 : 0;
1086 1086
 					}
1087 1087
 				}
1088 1088
 			}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		 * @param boolean $maskGenOnly
1099 1099
 		 * @return int b
1100 1100
 		 */
1101
-		 protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) {
1101
+		 protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) {
1102 1102
 			$b = 0;
1103 1103
 			$bitMask = array();
1104 1104
 			$bitMask = $this->generateMaskNo($maskNo, $width, $s);
@@ -1106,12 +1106,12 @@  discard block
 block discarded – undo
1106 1106
 				return;
1107 1107
 			}
1108 1108
 			$d = $s;
1109
-			for ($y=0; $y<$width; ++$y) {
1110
-				for ($x=0; $x<$width; ++$x) {
1109
+			for ($y = 0; $y < $width; ++$y) {
1110
+				for ($x = 0; $x < $width; ++$x) {
1111 1111
 					if ($bitMask[$y][$x] == 1) {
1112
-						$d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]);
1112
+						$d[$y][$x] = chr(ord($s[$y][$x]) ^ (int) $bitMask[$y][$x]);
1113 1113
 					}
1114
-					$b += (int)(ord($d[$y][$x]) & 1);
1114
+					$b += (int) (ord($d[$y][$x]) & 1);
1115 1115
 				}
1116 1116
 			}
1117 1117
 			return $b;
@@ -1139,20 +1139,20 @@  discard block
 block discarded – undo
1139 1139
 		 */
1140 1140
 		 protected function calcN1N3($length) {
1141 1141
 			$demerit = 0;
1142
-			for ($i=0; $i<$length; ++$i) {
1142
+			for ($i = 0; $i < $length; ++$i) {
1143 1143
 				if ($this->runLength[$i] >= 5) {
1144 1144
 					$demerit += (N1 + ($this->runLength[$i] - 5));
1145 1145
 				}
1146 1146
 				if ($i & 1) {
1147
-					if (($i >= 3) AND ($i < ($length-2)) AND ($this->runLength[$i] % 3 == 0)) {
1148
-						$fact = (int)($this->runLength[$i] / 3);
1149
-						if (($this->runLength[$i-2] == $fact)
1150
-							AND ($this->runLength[$i-1] == $fact)
1151
-							AND ($this->runLength[$i+1] == $fact)
1152
-							AND ($this->runLength[$i+2] == $fact)) {
1153
-							if (($this->runLength[$i-3] < 0) OR ($this->runLength[$i-3] >= (4 * $fact))) {
1147
+					if (($i >= 3) AND ($i < ($length - 2)) AND ($this->runLength[$i] % 3 == 0)) {
1148
+						$fact = (int) ($this->runLength[$i] / 3);
1149
+						if (($this->runLength[$i - 2] == $fact)
1150
+							AND ($this->runLength[$i - 1] == $fact)
1151
+							AND ($this->runLength[$i + 1] == $fact)
1152
+							AND ($this->runLength[$i + 2] == $fact)) {
1153
+							if (($this->runLength[$i - 3] < 0) OR ($this->runLength[$i - 3] >= (4 * $fact))) {
1154 1154
 								$demerit += N3;
1155
-							} elseif ((($i+3) >= $length) OR ($this->runLength[$i+3] >= (4 * $fact))) {
1155
+							} elseif ((($i + 3) >= $length) OR ($this->runLength[$i + 3] >= (4 * $fact))) {
1156 1156
 								$demerit += N3;
1157 1157
 							}
1158 1158
 						}
@@ -1171,17 +1171,17 @@  discard block
 block discarded – undo
1171 1171
 		 protected function evaluateSymbol($width, $frame) {
1172 1172
 			$head = 0;
1173 1173
 			$demerit = 0;
1174
-			for ($y=0; $y<$width; ++$y) {
1174
+			for ($y = 0; $y < $width; ++$y) {
1175 1175
 				$head = 0;
1176 1176
 				$this->runLength[0] = 1;
1177 1177
 				$frameY = $frame[$y];
1178 1178
 				if ($y > 0) {
1179
-					$frameYM = $frame[$y-1];
1179
+					$frameYM = $frame[$y - 1];
1180 1180
 				}
1181
-				for ($x=0; $x<$width; ++$x) {
1181
+				for ($x = 0; $x < $width; ++$x) {
1182 1182
 					if (($x > 0) AND ($y > 0)) {
1183
-						$b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]);
1184
-						$w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]);
1183
+						$b22 = ord($frameY[$x]) & ord($frameY[$x - 1]) & ord($frameYM[$x]) & ord($frameYM[$x - 1]);
1184
+						$w22 = ord($frameY[$x]) | ord($frameY[$x - 1]) | ord($frameYM[$x]) | ord($frameYM[$x - 1]);
1185 1185
 						if (($b22 | ($w22 ^ 1)) & 1) {
1186 1186
 							$demerit += N2;
1187 1187
 						}
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 						$head = 1;
1192 1192
 						$this->runLength[$head] = 1;
1193 1193
 					} elseif ($x > 0) {
1194
-						if ((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) {
1194
+						if ((ord($frameY[$x]) ^ ord($frameY[$x - 1])) & 1) {
1195 1195
 							$head++;
1196 1196
 							$this->runLength[$head] = 1;
1197 1197
 						} else {
@@ -1199,18 +1199,18 @@  discard block
 block discarded – undo
1199 1199
 						}
1200 1200
 					}
1201 1201
 				}
1202
-				$demerit += $this->calcN1N3($head+1);
1202
+				$demerit += $this->calcN1N3($head + 1);
1203 1203
 			}
1204
-			for ($x=0; $x<$width; ++$x) {
1204
+			for ($x = 0; $x < $width; ++$x) {
1205 1205
 				$head = 0;
1206 1206
 				$this->runLength[0] = 1;
1207
-				for ($y=0; $y<$width; ++$y) {
1207
+				for ($y = 0; $y < $width; ++$y) {
1208 1208
 					if (($y == 0) AND (ord($frame[$y][$x]) & 1)) {
1209 1209
 						$this->runLength[0] = -1;
1210 1210
 						$head = 1;
1211 1211
 						$this->runLength[$head] = 1;
1212 1212
 					} elseif ($y > 0) {
1213
-						if ((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) {
1213
+						if ((ord($frame[$y][$x]) ^ ord($frame[$y - 1][$x])) & 1) {
1214 1214
 							$head++;
1215 1215
 							$this->runLength[$head] = 1;
1216 1216
 						} else {
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 						}
1219 1219
 					}
1220 1220
 				}
1221
-				$demerit += $this->calcN1N3($head+1);
1221
+				$demerit += $this->calcN1N3($head + 1);
1222 1222
 			}
1223 1223
 			return $demerit;
1224 1224
 		}
@@ -1237,8 +1237,8 @@  discard block
 block discarded – undo
1237 1237
 			$checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7);
1238 1238
 			if (QR_FIND_FROM_RANDOM !== false) {
1239 1239
 				$howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9);
1240
-				for ($i = 0; $i <  $howManuOut; ++$i) {
1241
-					$remPos = rand (0, count($checked_masks)-1);
1240
+				for ($i = 0; $i < $howManuOut; ++$i) {
1241
+					$remPos = rand(0, count($checked_masks) - 1);
1242 1242
 					unset($checked_masks[$remPos]);
1243 1243
 					$checked_masks = array_values($checked_masks);
1244 1244
 				}
@@ -1250,8 +1250,8 @@  discard block
 block discarded – undo
1250 1250
 				$blacks = 0;
1251 1251
 				$blacks  = $this->makeMaskNo($i, $width, $frame, $mask);
1252 1252
 				$blacks += $this->writeFormatInformation($width, $mask, $i, $level);
1253
-				$blacks  = (int)(100 * $blacks / ($width * $width));
1254
-				$demerit = (int)((int)(abs($blacks - 50) / 5) * N4);
1253
+				$blacks  = (int) (100 * $blacks / ($width * $width));
1254
+				$demerit = (int) ((int) (abs($blacks - 50) / 5) * N4);
1255 1255
 				$demerit += $this->evaluateSymbol($width, $mask);
1256 1256
 				if ($demerit < $minDemerit) {
1257 1257
 					$minDemerit = $demerit;
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 			if ($pos >= strlen($str)) {
1277 1277
 				return false;
1278 1278
 			}
1279
-			return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
1279
+			return ((ord($str[$pos]) >= ord('0')) && (ord($str[$pos]) <= ord('9')));
1280 1280
 		}
1281 1281
 
1282 1282
 		/**
@@ -1307,8 +1307,8 @@  discard block
 block discarded – undo
1307 1307
 			} elseif ($this->isalnumat($this->dataStr, $pos)) {
1308 1308
 				return QR_MODE_AN;
1309 1309
 			} elseif ($this->hint == QR_MODE_KJ) {
1310
-				if ($pos+1 < strlen($this->dataStr)) {
1311
-					$d = $this->dataStr[$pos+1];
1310
+				if ($pos + 1 < strlen($this->dataStr)) {
1311
+					$d = $this->dataStr[$pos + 1];
1312 1312
 					$word = (ord($c) << 8) | ord($d);
1313 1313
 					if (($word >= 0x8140 && $word <= 0x9ffc) OR ($word >= 0xe040 && $word <= 0xebbf)) {
1314 1314
 						return QR_MODE_KJ;
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 		 protected function eatNum() {
1326 1326
 			$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
1327 1327
 			$p = 0;
1328
-			while($this->isdigitat($this->dataStr, $p)) {
1328
+			while ($this->isdigitat($this->dataStr, $p)) {
1329 1329
 				$p++;
1330 1330
 			}
1331 1331
 			$run = $p;
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 			if ($mode == QR_MODE_AN) {
1342 1342
 				$dif = $this->estimateBitsModeNum($run) + 4 + $ln
1343 1343
 				+ $this->estimateBitsModeAn(1)        // + 4 + la
1344
-				- $this->estimateBitsModeAn($run + 1);// - 4 - la
1344
+				- $this->estimateBitsModeAn($run + 1); // - 4 - la
1345 1345
 				if ($dif > 0) {
1346 1346
 					return $this->eatAn();
1347 1347
 				}
@@ -1355,13 +1355,13 @@  discard block
 block discarded – undo
1355 1355
 		 * @return int run
1356 1356
 		 */
1357 1357
 		 protected function eatAn() {
1358
-			$la = $this->lengthIndicator(QR_MODE_AN,  $this->version);
1358
+			$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
1359 1359
 			$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
1360 1360
 			$p = 0;
1361
-			while($this->isalnumat($this->dataStr, $p)) {
1361
+			while ($this->isalnumat($this->dataStr, $p)) {
1362 1362
 				if ($this->isdigitat($this->dataStr, $p)) {
1363 1363
 					$q = $p;
1364
-					while($this->isdigitat($this->dataStr, $q)) {
1364
+					while ($this->isdigitat($this->dataStr, $q)) {
1365 1365
 						$q++;
1366 1366
 					}
1367 1367
 					$dif = $this->estimateBitsModeAn($p) // + 4 + la
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 		 */
1396 1396
 		 protected function eatKanji() {
1397 1397
 			$p = 0;
1398
-			while($this->identifyMode($p) == QR_MODE_KJ) {
1398
+			while ($this->identifyMode($p) == QR_MODE_KJ) {
1399 1399
 				$p += 2;
1400 1400
 			}
1401 1401
 			$this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr));
@@ -1411,14 +1411,14 @@  discard block
 block discarded – undo
1411 1411
 			$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
1412 1412
 			$p = 1;
1413 1413
 			$dataStrLen = strlen($this->dataStr);
1414
-			while($p < $dataStrLen) {
1414
+			while ($p < $dataStrLen) {
1415 1415
 				$mode = $this->identifyMode($p);
1416 1416
 				if ($mode == QR_MODE_KJ) {
1417 1417
 					break;
1418 1418
 				}
1419 1419
 				if ($mode == QR_MODE_NM) {
1420 1420
 					$q = $p;
1421
-					while($this->isdigitat($this->dataStr, $q)) {
1421
+					while ($this->isdigitat($this->dataStr, $q)) {
1422 1422
 						$q++;
1423 1423
 					}
1424 1424
 					$dif = $this->estimateBitsMode8($p) // + 4 + l8
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 					}
1432 1432
 				} elseif ($mode == QR_MODE_AN) {
1433 1433
 					$q = $p;
1434
-					while($this->isalnumat($this->dataStr, $q)) {
1434
+					while ($this->isalnumat($this->dataStr, $q)) {
1435 1435
 						$q++;
1436 1436
 					}
1437 1437
 					$dif = $this->estimateBitsMode8($p)  // + 4 + l8
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
 		 * @param array $bstream
1525 1525
 		 * @return array input item
1526 1526
 		 */
1527
-		 protected function newInputItem($mode, $size, $data, $bstream=null) {
1527
+		 protected function newInputItem($mode, $size, $data, $bstream = null) {
1528 1528
 			$setData = array_slice($data, 0, $size);
1529 1529
 			if (count($setData) < $size) {
1530 1530
 				$setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0));
@@ -1547,23 +1547,23 @@  discard block
 block discarded – undo
1547 1547
 		 * @return array input item
1548 1548
 		 */
1549 1549
 		 protected function encodeModeNum($inputitem, $version) {
1550
-			$words = (int)($inputitem['size'] / 3);
1550
+			$words = (int) ($inputitem['size'] / 3);
1551 1551
 			$inputitem['bstream'] = array();
1552 1552
 			$val = 0x1;
1553 1553
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val);
1554 1554
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_NM, $version), $inputitem['size']);
1555
-			for ($i=0; $i < $words; ++$i) {
1556
-				$val  = (ord($inputitem['data'][$i*3  ]) - ord('0')) * 100;
1557
-				$val += (ord($inputitem['data'][$i*3+1]) - ord('0')) * 10;
1558
-				$val += (ord($inputitem['data'][$i*3+2]) - ord('0'));
1555
+			for ($i = 0; $i < $words; ++$i) {
1556
+				$val  = (ord($inputitem['data'][$i * 3]) - ord('0')) * 100;
1557
+				$val += (ord($inputitem['data'][$i * 3 + 1]) - ord('0')) * 10;
1558
+				$val += (ord($inputitem['data'][$i * 3 + 2]) - ord('0'));
1559 1559
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val);
1560 1560
 			}
1561 1561
 			if ($inputitem['size'] - $words * 3 == 1) {
1562
-				$val = ord($inputitem['data'][$words*3]) - ord('0');
1562
+				$val = ord($inputitem['data'][$words * 3]) - ord('0');
1563 1563
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val);
1564 1564
 			} elseif (($inputitem['size'] - ($words * 3)) == 2) {
1565
-				$val  = (ord($inputitem['data'][$words*3  ]) - ord('0')) * 10;
1566
-				$val += (ord($inputitem['data'][$words*3+1]) - ord('0'));
1565
+				$val  = (ord($inputitem['data'][$words * 3]) - ord('0')) * 10;
1566
+				$val += (ord($inputitem['data'][$words * 3 + 1]) - ord('0'));
1567 1567
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val);
1568 1568
 			}
1569 1569
 			return $inputitem;
@@ -1576,13 +1576,13 @@  discard block
 block discarded – undo
1576 1576
 		 * @return array input item
1577 1577
 		 */
1578 1578
 		 protected function encodeModeAn($inputitem, $version) {
1579
-			$words = (int)($inputitem['size'] / 2);
1579
+			$words = (int) ($inputitem['size'] / 2);
1580 1580
 			$inputitem['bstream'] = array();
1581 1581
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02);
1582 1582
 			$inputitem['bstream'] = $this->appendNum(v, $this->lengthIndicator(QR_MODE_AN, $version), $inputitem['size']);
1583
-			for ($i=0; $i < $words; ++$i) {
1584
-				$val  = (int)$this->lookAnTable(ord($inputitem['data'][$i*2  ])) * 45;
1585
-				$val += (int)$this->lookAnTable(ord($inputitem['data'][$i*2+1]));
1583
+			for ($i = 0; $i < $words; ++$i) {
1584
+				$val  = (int) $this->lookAnTable(ord($inputitem['data'][$i * 2])) * 45;
1585
+				$val += (int) $this->lookAnTable(ord($inputitem['data'][$i * 2 + 1]));
1586 1586
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val);
1587 1587
 			}
1588 1588
 			if ($inputitem['size'] & 1) {
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 			$inputitem['bstream'] = array();
1603 1603
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4);
1604 1604
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_8B, $version), $inputitem['size']);
1605
-			for ($i=0; $i < $inputitem['size']; ++$i) {
1605
+			for ($i = 0; $i < $inputitem['size']; ++$i) {
1606 1606
 				$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][$i]));
1607 1607
 			}
1608 1608
 			return $inputitem;
@@ -1617,9 +1617,9 @@  discard block
 block discarded – undo
1617 1617
 		 protected function encodeModeKanji($inputitem, $version) {
1618 1618
 			$inputitem['bstream'] = array();
1619 1619
 			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8);
1620
-			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int)($inputitem['size'] / 2));
1621
-			for ($i=0; $i<$inputitem['size']; $i+=2) {
1622
-				$val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i+1]);
1620
+			$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int) ($inputitem['size'] / 2));
1621
+			for ($i = 0; $i < $inputitem['size']; $i += 2) {
1622
+				$val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i + 1]);
1623 1623
 				if ($val <= 0x9ffc) {
1624 1624
 					$val -= 0x8140;
1625 1625
 				} else {
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
 				$inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st1['bstream']);
1665 1665
 				$inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']);
1666 1666
 			} else {
1667
-				switch($inputitem['mode']) {
1667
+				switch ($inputitem['mode']) {
1668 1668
 					case QR_MODE_NM: {
1669 1669
 						$inputitem = $this->encodeModeNum($inputitem, $version);
1670 1670
 						break;
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
 			$parity = 0;
1743 1743
 			foreach ($items as $item) {
1744 1744
 				if ($item['mode'] != QR_MODE_ST) {
1745
-					for ($i=$item['size']-1; $i>=0; --$i) {
1745
+					for ($i = $item['size'] - 1; $i >= 0; --$i) {
1746 1746
 						$parity ^= $item['data'][$i];
1747 1747
 					}
1748 1748
 				}
@@ -1757,8 +1757,8 @@  discard block
 block discarded – undo
1757 1757
 		 * @return boolean true or false
1758 1758
 		 */
1759 1759
 		 protected function checkModeNum($size, $data) {
1760
-			for ($i=0; $i<$size; ++$i) {
1761
-				if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))){
1760
+			for ($i = 0; $i < $size; ++$i) {
1761
+				if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))) {
1762 1762
 					return false;
1763 1763
 				}
1764 1764
 			}
@@ -1771,9 +1771,9 @@  discard block
 block discarded – undo
1771 1771
 		 * @return int number of bits
1772 1772
 		 */
1773 1773
 		 protected function estimateBitsModeNum($size) {
1774
-			$w = (int)$size / 3;
1774
+			$w = (int) $size / 3;
1775 1775
 			$bits = $w * 10;
1776
-			switch($size - $w * 3) {
1776
+			switch ($size - $w * 3) {
1777 1777
 				case 1: {
1778 1778
 					$bits += 4;
1779 1779
 					break;
@@ -1795,7 +1795,7 @@  discard block
 block discarded – undo
1795 1795
 		 * @return value
1796 1796
 		 */
1797 1797
 		protected function lookAnTable($c) {
1798
-			return (($c > 127)?-1:$this->anTable[$c]);
1798
+			return (($c > 127) ?-1 : $this->anTable[$c]);
1799 1799
 		}
1800 1800
 
1801 1801
 		/**
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
 		 * @return boolean true or false
1806 1806
 		 */
1807 1807
 		 protected function checkModeAn($size, $data) {
1808
-			for ($i=0; $i<$size; ++$i) {
1808
+			for ($i = 0; $i < $size; ++$i) {
1809 1809
 				if ($this->lookAnTable(ord($data[$i])) == -1) {
1810 1810
 					return false;
1811 1811
 				}
@@ -1819,7 +1819,7 @@  discard block
 block discarded – undo
1819 1819
 		 * @return int number of bits
1820 1820
 		 */
1821 1821
 		 protected function estimateBitsModeAn($size) {
1822
-			$w = (int)($size / 2);
1822
+			$w = (int) ($size / 2);
1823 1823
 			$bits = $w * 11;
1824 1824
 			if ($size & 1) {
1825 1825
 				$bits += 6;
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
 		 * @return int number of bits
1843 1843
 		 */
1844 1844
 		 protected function estimateBitsModeKanji($size) {
1845
-			return (int)(($size / 2) * 13);
1845
+			return (int) (($size / 2) * 13);
1846 1846
 		}
1847 1847
 
1848 1848
 		/**
@@ -1855,8 +1855,8 @@  discard block
 block discarded – undo
1855 1855
 			if ($size & 1) {
1856 1856
 				return false;
1857 1857
 			}
1858
-			for ($i=0; $i<$size; $i+=2) {
1859
-				$val = (ord($data[$i]) << 8) | ord($data[$i+1]);
1858
+			for ($i = 0; $i < $size; $i += 2) {
1859
+				$val = (ord($data[$i]) << 8) | ord($data[$i + 1]);
1860 1860
 				if (($val < 0x8140) OR (($val > 0x9ffc) AND ($val < 0xe040)) OR ($val > 0xebbf)) {
1861 1861
 					return false;
1862 1862
 				}
@@ -1875,7 +1875,7 @@  discard block
 block discarded – undo
1875 1875
 			if ($size <= 0) {
1876 1876
 				return false;
1877 1877
 			}
1878
-			switch($mode) {
1878
+			switch ($mode) {
1879 1879
 				case QR_MODE_NM: {
1880 1880
 					return $this->checkModeNum($size, $data);
1881 1881
 				}
@@ -1910,7 +1910,7 @@  discard block
 block discarded – undo
1910 1910
 				$version = 1;
1911 1911
 			}
1912 1912
 			foreach ($items as $item) {
1913
-				switch($item['mode']) {
1913
+				switch ($item['mode']) {
1914 1914
 					case QR_MODE_NM: {
1915 1915
 						$bits = $this->estimateBitsModeNum($item['size']);
1916 1916
 						break;
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
 				}
1937 1937
 				$l = $this->lengthIndicator($item['mode'], $version);
1938 1938
 				$m = 1 << $l;
1939
-				$num = (int)(($item['size'] + $m - 1) / $m);
1939
+				$num = (int) (($item['size'] + $m - 1) / $m);
1940 1940
 				$bits += $num * (4 + $l);
1941 1941
 			}
1942 1942
 			return $bits;
@@ -1953,7 +1953,7 @@  discard block
 block discarded – undo
1953 1953
 			do {
1954 1954
 				$prev = $version;
1955 1955
 				$bits = $this->estimateBitStreamSize($items, $prev);
1956
-				$version = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level);
1956
+				$version = $this->getMinimumVersion((int) (($bits + 7) / 8), $this->level);
1957 1957
 				if ($version < 0) {
1958 1958
 					return -1;
1959 1959
 				}
@@ -1970,9 +1970,9 @@  discard block
 block discarded – undo
1970 1970
 		 */
1971 1971
 		 protected function lengthOfCode($mode, $version, $bits) {
1972 1972
 			$payload = $bits - 4 - $this->lengthIndicator($mode, $version);
1973
-			switch($mode) {
1973
+			switch ($mode) {
1974 1974
 				case QR_MODE_NM: {
1975
-					$chunks = (int)($payload / 10);
1975
+					$chunks = (int) ($payload / 10);
1976 1976
 					$remain = $payload - $chunks * 10;
1977 1977
 					$size = $chunks * 3;
1978 1978
 					if ($remain >= 7) {
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 					break;
1984 1984
 				}
1985 1985
 				case QR_MODE_AN: {
1986
-					$chunks = (int)($payload / 11);
1986
+					$chunks = (int) ($payload / 11);
1987 1987
 					$remain = $payload - $chunks * 11;
1988 1988
 					$size = $chunks * 2;
1989 1989
 					if ($remain >= 6) {
@@ -1992,15 +1992,15 @@  discard block
 block discarded – undo
1992 1992
 					break;
1993 1993
 				}
1994 1994
 				case QR_MODE_8B: {
1995
-					$size = (int)($payload / 8);
1995
+					$size = (int) ($payload / 8);
1996 1996
 					break;
1997 1997
 				}
1998 1998
 				case QR_MODE_KJ: {
1999
-					$size = (int)(($payload / 13) * 2);
1999
+					$size = (int) (($payload / 13) * 2);
2000 2000
 					break;
2001 2001
 				}
2002 2002
 				case QR_MODE_ST: {
2003
-					$size = (int)($payload / 8);
2003
+					$size = (int) ($payload / 8);
2004 2004
 					break;
2005 2005
 				}
2006 2006
 				default: {
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 				if ($bits < 0) {
2051 2051
 					return -1;
2052 2052
 				}
2053
-				$ver = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level);
2053
+				$ver = $this->getMinimumVersion((int) (($bits + 7) / 8), $this->level);
2054 2054
 				if ($ver < 0) {
2055 2055
 					return -1;
2056 2056
 				} elseif ($ver > $this->version) {
@@ -2078,14 +2078,14 @@  discard block
 block discarded – undo
2078 2078
 				return $this->appendNum($bstream, $maxbits - $bits, 0);
2079 2079
 			}
2080 2080
 			$bits += 4;
2081
-			$words = (int)(($bits + 7) / 8);
2081
+			$words = (int) (($bits + 7) / 8);
2082 2082
 			$padding = array();
2083 2083
 			$padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0);
2084 2084
 			$padlen = $maxwords - $words;
2085 2085
 			if ($padlen > 0) {
2086 2086
 				$padbuf = array();
2087
-				for ($i=0; $i<$padlen; ++$i) {
2088
-					$padbuf[$i] = ($i&1)?0x11:0xec;
2087
+				for ($i = 0; $i < $padlen; ++$i) {
2088
+					$padbuf[$i] = ($i & 1) ? 0x11 : 0xec;
2089 2089
 				}
2090 2090
 				$padding = $this->appendBytes($padding, $padlen, $padbuf);
2091 2091
 			}
@@ -2148,7 +2148,7 @@  discard block
 block discarded – undo
2148 2148
 		 protected function newFromNum($bits, $num) {
2149 2149
 			$bstream = $this->allocate($bits);
2150 2150
 			$mask = 1 << ($bits - 1);
2151
-			for ($i=0; $i<$bits; ++$i) {
2151
+			for ($i = 0; $i < $bits; ++$i) {
2152 2152
 				if ($num & $mask) {
2153 2153
 					$bstream[$i] = 1;
2154 2154
 				} else {
@@ -2167,10 +2167,10 @@  discard block
 block discarded – undo
2167 2167
 		 */
2168 2168
 		 protected function newFromBytes($size, $data) {
2169 2169
 			$bstream = $this->allocate($size * 8);
2170
-			$p=0;
2171
-			for ($i=0; $i<$size; ++$i) {
2170
+			$p = 0;
2171
+			for ($i = 0; $i < $size; ++$i) {
2172 2172
 				$mask = 0x80;
2173
-				for ($j=0; $j<8; ++$j) {
2173
+				for ($j = 0; $j < 8; ++$j) {
2174 2174
 					if ($data[$i] & $mask) {
2175 2175
 						$bstream[$p] = 1;
2176 2176
 					} else {
@@ -2239,12 +2239,12 @@  discard block
 block discarded – undo
2239 2239
 			if ($size == 0) {
2240 2240
 				return array();
2241 2241
 			}
2242
-			$data = array_fill(0, (int)(($size + 7) / 8), 0);
2243
-			$bytes = (int)($size / 8);
2242
+			$data = array_fill(0, (int) (($size + 7) / 8), 0);
2243
+			$bytes = (int) ($size / 8);
2244 2244
 			$p = 0;
2245
-			for ($i=0; $i<$bytes; $i++) {
2245
+			for ($i = 0; $i < $bytes; $i++) {
2246 2246
 				$v = 0;
2247
-				for ($j=0; $j<8; $j++) {
2247
+				for ($j = 0; $j < 8; $j++) {
2248 2248
 					$v = $v << 1;
2249 2249
 					$v |= $bstream[$p];
2250 2250
 					$p++;
@@ -2253,7 +2253,7 @@  discard block
 block discarded – undo
2253 2253
 			}
2254 2254
 			if ($size & 7) {
2255 2255
 				$v = 0;
2256
-				for ($j=0; $j<($size & 7); $j++) {
2256
+				for ($j = 0; $j < ($size & 7); $j++) {
2257 2257
 					$v = $v << 1;
2258 2258
 					$v |= $bstream[$p];
2259 2259
 					$p++;
@@ -2276,8 +2276,8 @@  discard block
 block discarded – undo
2276 2276
 		 * @param int $replLen length of the repl string
2277 2277
 		 * @return array srctab
2278 2278
 		 */
2279
-		 protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) {
2280
-			$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
2279
+		 protected function qrstrset($srctab, $x, $y, $repl, $replLen = false) {
2280
+			$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false) ?substr($repl, 0, $replLen) : $repl, $x, ($replLen !== false) ? $replLen : strlen($repl));
2281 2281
 			return $srctab;
2282 2282
 		}
2283 2283
 
@@ -2297,7 +2297,7 @@  discard block
 block discarded – undo
2297 2297
 		 * @param int $level error correction level
2298 2298
 		 * @return int ECC size (bytes)
2299 2299
 		 */
2300
-		protected function getECCLength($version, $level){
2300
+		protected function getECCLength($version, $level) {
2301 2301
 			return $this->capacity[$version][QRCAP_EC][$level];
2302 2302
 		}
2303 2303
 
@@ -2326,8 +2326,8 @@  discard block
 block discarded – undo
2326 2326
 		 * @return int version number
2327 2327
 		 */
2328 2328
 		protected function getMinimumVersion($size, $level) {
2329
-			for ($i=1; $i <= QRSPEC_VERSION_MAX; ++$i) {
2330
-				$words  = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level];
2329
+			for ($i = 1; $i <= QRSPEC_VERSION_MAX; ++$i) {
2330
+				$words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level];
2331 2331
 				if ($words >= $size) {
2332 2332
 					return $i;
2333 2333
 				}
@@ -2397,14 +2397,14 @@  discard block
 block discarded – undo
2397 2397
 			$ecc = $this->getECCLength($version, $level);
2398 2398
 			if ($b2 == 0) {
2399 2399
 				$spec[0] = $b1;
2400
-				$spec[1] = (int)($data / $b1);
2401
-				$spec[2] = (int)($ecc / $b1);
2400
+				$spec[1] = (int) ($data / $b1);
2401
+				$spec[2] = (int) ($ecc / $b1);
2402 2402
 				$spec[3] = 0;
2403 2403
 				$spec[4] = 0;
2404 2404
 			} else {
2405 2405
 				$spec[0] = $b1;
2406
-				$spec[1] = (int)($data / ($b1 + $b2));
2407
-				$spec[2] = (int)($ecc  / ($b1 + $b2));
2406
+				$spec[1] = (int) ($data / ($b1 + $b2));
2407
+				$spec[2] = (int) ($ecc / ($b1 + $b2));
2408 2408
 				$spec[3] = $b2;
2409 2409
 				$spec[4] = $spec[1] + 1;
2410 2410
 			}
@@ -2429,8 +2429,8 @@  discard block
 block discarded – undo
2429 2429
 				);
2430 2430
 			$yStart = $oy - 2;
2431 2431
 			$xStart = $ox - 2;
2432
-			for ($y=0; $y < 5; $y++) {
2433
-				$frame = $this->qrstrset($frame, $xStart, $yStart+$y, $finder[$y]);
2432
+			for ($y = 0; $y < 5; $y++) {
2433
+				$frame = $this->qrstrset($frame, $xStart, $yStart + $y, $finder[$y]);
2434 2434
 			}
2435 2435
 			return $frame;
2436 2436
 		}
@@ -2450,7 +2450,7 @@  discard block
 block discarded – undo
2450 2450
 			if ($d < 0) {
2451 2451
 				$w = 2;
2452 2452
 			} else {
2453
-				$w = (int)(($width - $this->alignmentPattern[$version][0]) / $d + 2);
2453
+				$w = (int) (($width - $this->alignmentPattern[$version][0]) / $d + 2);
2454 2454
 			}
2455 2455
 			if ($w * $w - 3 == 1) {
2456 2456
 				$x = $this->alignmentPattern[$version][0];
@@ -2460,15 +2460,15 @@  discard block
 block discarded – undo
2460 2460
 			}
2461 2461
 			$cx = $this->alignmentPattern[$version][0];
2462 2462
 			$wo = $w - 1;
2463
-			for ($x=1; $x < $wo; ++$x) {
2463
+			for ($x = 1; $x < $wo; ++$x) {
2464 2464
 				$frame = $this->putAlignmentMarker($frame, 6, $cx);
2465
-				$frame = $this->putAlignmentMarker($frame, $cx,  6);
2465
+				$frame = $this->putAlignmentMarker($frame, $cx, 6);
2466 2466
 				$cx += $d;
2467 2467
 			}
2468 2468
 			$cy = $this->alignmentPattern[$version][0];
2469
-			for ($y=0; $y < $wo; ++$y) {
2469
+			for ($y = 0; $y < $wo; ++$y) {
2470 2470
 				$cx = $this->alignmentPattern[$version][0];
2471
-				for ($x=0; $x < $wo; ++$x) {
2471
+				for ($x = 0; $x < $wo; ++$x) {
2472 2472
 					$frame = $this->putAlignmentMarker($frame, $cx, $cy);
2473 2473
 					$cx += $d;
2474 2474
 				}
@@ -2523,7 +2523,7 @@  discard block
 block discarded – undo
2523 2523
 			"\xc1\xc0\xc0\xc0\xc0\xc0\xc1",
2524 2524
 			"\xc1\xc1\xc1\xc1\xc1\xc1\xc1"
2525 2525
 			);
2526
-			for ($y=0; $y < 7; $y++) {
2526
+			for ($y = 0; $y < 7; $y++) {
2527 2527
 				$frame = $this->qrstrset($frame, $ox, ($oy + $y), $finder[$y]);
2528 2528
 			}
2529 2529
 			return $frame;
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
 		 */
2537 2537
 		protected function createFrame($version) {
2538 2538
 			$width = $this->capacity[$version][QRCAP_WIDTH];
2539
-			$frameLine = str_repeat ("\0", $width);
2539
+			$frameLine = str_repeat("\0", $width);
2540 2540
 			$frame = array_fill(0, $width, $frameLine);
2541 2541
 			// Finder pattern
2542 2542
 			$frame = $this->putFinderPattern($frame, 0, 0);
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 			$frame = $this->putFinderPattern($frame, 0, $width - 7);
2545 2545
 			// Separator
2546 2546
 			$yOffset = $width - 7;
2547
-			for ($y=0; $y < 7; ++$y) {
2547
+			for ($y = 0; $y < 7; ++$y) {
2548 2548
 				$frame[$y][7] = "\xc0";
2549 2549
 				$frame[$y][$width - 8] = "\xc0";
2550 2550
 				$frame[$yOffset][7] = "\xc0";
@@ -2552,22 +2552,22 @@  discard block
 block discarded – undo
2552 2552
 			}
2553 2553
 			$setPattern = str_repeat("\xc0", 8);
2554 2554
 			$frame = $this->qrstrset($frame, 0, 7, $setPattern);
2555
-			$frame = $this->qrstrset($frame, $width-8, 7, $setPattern);
2555
+			$frame = $this->qrstrset($frame, $width - 8, 7, $setPattern);
2556 2556
 			$frame = $this->qrstrset($frame, 0, $width - 8, $setPattern);
2557 2557
 			// Format info
2558 2558
 			$setPattern = str_repeat("\x84", 9);
2559 2559
 			$frame = $this->qrstrset($frame, 0, 8, $setPattern);
2560 2560
 			$frame = $this->qrstrset($frame, $width - 8, 8, $setPattern, 8);
2561 2561
 			$yOffset = $width - 8;
2562
-			for ($y=0; $y < 8; ++$y,++$yOffset) {
2562
+			for ($y = 0; $y < 8; ++$y, ++$yOffset) {
2563 2563
 				$frame[$y][8] = "\x84";
2564 2564
 				$frame[$yOffset][8] = "\x84";
2565 2565
 			}
2566 2566
 			// Timing pattern
2567 2567
 			$wo = $width - 15;
2568
-			for ($i=1; $i < $wo; ++$i) {
2569
-				$frame[6][7+$i] = chr(0x90 | ($i & 1));
2570
-				$frame[7+$i][6] = chr(0x90 | ($i & 1));
2568
+			for ($i = 1; $i < $wo; ++$i) {
2569
+				$frame[6][7 + $i] = chr(0x90 | ($i & 1));
2570
+				$frame[7 + $i][6] = chr(0x90 | ($i & 1));
2571 2571
 			}
2572 2572
 			// Alignment pattern
2573 2573
 			$frame = $this->putAlignmentPattern($version, $frame, $width);
@@ -2575,16 +2575,16 @@  discard block
 block discarded – undo
2575 2575
 			if ($version >= 7) {
2576 2576
 				$vinf = $this->getVersionPattern($version);
2577 2577
 				$v = $vinf;
2578
-				for ($x=0; $x<6; ++$x) {
2579
-					for ($y=0; $y<3; ++$y) {
2580
-						$frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));
2578
+				for ($x = 0; $x < 6; ++$x) {
2579
+					for ($y = 0; $y < 3; ++$y) {
2580
+						$frame[($width - 11) + $y][$x] = chr(0x88 | ($v & 1));
2581 2581
 						$v = $v >> 1;
2582 2582
 					}
2583 2583
 				}
2584 2584
 				$v = $vinf;
2585
-				for ($y=0; $y<6; ++$y) {
2586
-					for ($x=0; $x<3; ++$x) {
2587
-						$frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1));
2585
+				for ($y = 0; $y < 6; ++$y) {
2586
+					for ($x = 0; $x < 3; ++$x) {
2587
+						$frame[$y][$x + ($width - 11)] = chr(0x88 | ($v & 1));
2588 2588
 						$v = $v >> 1;
2589 2589
 					}
2590 2590
 				}
@@ -2755,16 +2755,16 @@  discard block
 block discarded – undo
2755 2755
 			if (($symsize < 0) OR ($symsize > 8)) {
2756 2756
 				return $rs;
2757 2757
 			}
2758
-			if (($fcr < 0) OR ($fcr >= (1<<$symsize))) {
2758
+			if (($fcr < 0) OR ($fcr >= (1 << $symsize))) {
2759 2759
 				return $rs;
2760 2760
 			}
2761
-			if (($prim <= 0) OR ($prim >= (1<<$symsize))) {
2761
+			if (($prim <= 0) OR ($prim >= (1 << $symsize))) {
2762 2762
 				return $rs;
2763 2763
 			}
2764
-			if (($nroots < 0) OR ($nroots >= (1<<$symsize))) {
2764
+			if (($nroots < 0) OR ($nroots >= (1 << $symsize))) {
2765 2765
 				return $rs;
2766 2766
 			}
2767
-			if (($pad < 0) OR ($pad >= ((1<<$symsize) -1 - $nroots))) {
2767
+			if (($pad < 0) OR ($pad >= ((1 << $symsize) - 1 - $nroots))) {
2768 2768
 				return $rs;
2769 2769
 			}
2770 2770
 			$rs = array();
@@ -2774,13 +2774,13 @@  discard block
 block discarded – undo
2774 2774
 			$rs['alpha_to'] = array_fill(0, ($rs['nn'] + 1), 0);
2775 2775
 			$rs['index_of'] = array_fill(0, ($rs['nn'] + 1), 0);
2776 2776
 			// PHP style macro replacement ;)
2777
-			$NN =& $rs['nn'];
2778
-			$A0 =& $NN;
2777
+			$NN = & $rs['nn'];
2778
+			$A0 = & $NN;
2779 2779
 			// Generate Galois field lookup tables
2780 2780
 			$rs['index_of'][0] = $A0; // log(zero) = -inf
2781 2781
 			$rs['alpha_to'][$A0] = 0; // alpha**-inf = 0
2782 2782
 			$sr = 1;
2783
-			for ($i=0; $i<$rs['nn']; ++$i) {
2783
+			for ($i = 0; $i < $rs['nn']; ++$i) {
2784 2784
 				$rs['index_of'][$sr] = $i;
2785 2785
 				$rs['alpha_to'][$i] = $sr;
2786 2786
 				$sr <<= 1;
@@ -2800,21 +2800,21 @@  discard block
 block discarded – undo
2800 2800
 			$rs['nroots'] = $nroots;
2801 2801
 			$rs['gfpoly'] = $gfpoly;
2802 2802
 			// Find prim-th root of 1, used in decoding
2803
-			for ($iprim=1; ($iprim % $prim) != 0; $iprim += $rs['nn']) {
2803
+			for ($iprim = 1; ($iprim % $prim) != 0; $iprim += $rs['nn']) {
2804 2804
 				; // intentional empty-body loop!
2805 2805
 			}
2806
-			$rs['iprim'] = (int)($iprim / $prim);
2806
+			$rs['iprim'] = (int) ($iprim / $prim);
2807 2807
 			$rs['genpoly'][0] = 1;
2808 2808
 
2809 2809
 
2810
-			for ($i = 0,$root=$fcr*$prim; $i < $nroots; $i++, $root += $prim) {
2811
-				$rs['genpoly'][$i+1] = 1;
2810
+			for ($i = 0, $root = $fcr * $prim; $i < $nroots; $i++, $root += $prim) {
2811
+				$rs['genpoly'][$i + 1] = 1;
2812 2812
 				// Multiply rs->genpoly[] by  @**(root + x)
2813 2813
 				for ($j = $i; $j > 0; --$j) {
2814 2814
 					if ($rs['genpoly'][$j] != 0) {
2815
-						$rs['genpoly'][$j] = $rs['genpoly'][$j-1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)];
2815
+						$rs['genpoly'][$j] = $rs['genpoly'][$j - 1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)];
2816 2816
 					} else {
2817
-						$rs['genpoly'][$j] = $rs['genpoly'][$j-1];
2817
+						$rs['genpoly'][$j] = $rs['genpoly'][$j - 1];
2818 2818
 					}
2819 2819
 				}
2820 2820
 				// rs->genpoly[0] can never be zero
@@ -2835,26 +2835,26 @@  discard block
 block discarded – undo
2835 2835
 		 * @return parity array
2836 2836
 		 */
2837 2837
 		 protected function encode_rs_char($rs, $data, $parity) {
2838
-			$MM       =& $rs['mm']; // bits per symbol
2839
-			$NN       =& $rs['nn']; // the total number of symbols in a RS block
2840
-			$ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form
2841
-			$INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form
2842
-			$GENPOLY  =& $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form
2843
-			$NROOTS   =& $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block
2844
-			$FCR      =& $rs['fcr']; // first consecutive root, index form
2845
-			$PRIM     =& $rs['prim']; // primitive element, index form
2846
-			$IPRIM    =& $rs['iprim']; // prim-th root of 1, index form
2847
-			$PAD      =& $rs['pad']; // the number of pad symbols in a block
2848
-			$A0       =& $NN;
2838
+			$MM       = & $rs['mm']; // bits per symbol
2839
+			$NN       = & $rs['nn']; // the total number of symbols in a RS block
2840
+			$ALPHA_TO = & $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form
2841
+			$INDEX_OF = & $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form
2842
+			$GENPOLY  = & $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form
2843
+			$NROOTS   = & $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block
2844
+			$FCR      = & $rs['fcr']; // first consecutive root, index form
2845
+			$PRIM     = & $rs['prim']; // primitive element, index form
2846
+			$IPRIM    = & $rs['iprim']; // prim-th root of 1, index form
2847
+			$PAD      = & $rs['pad']; // the number of pad symbols in a block
2848
+			$A0       = & $NN;
2849 2849
 			$parity = array_fill(0, $NROOTS, 0);
2850
-			for ($i=0; $i < ($NN - $NROOTS - $PAD); $i++) {
2850
+			for ($i = 0; $i < ($NN - $NROOTS - $PAD); $i++) {
2851 2851
 				$feedback = $INDEX_OF[$data[$i] ^ $parity[0]];
2852 2852
 				if ($feedback != $A0) {
2853 2853
 					// feedback term is non-zero
2854 2854
 					// This line is unnecessary when GENPOLY[NROOTS] is unity, as it must
2855 2855
 					// always be for the polynomials constructed by init_rs()
2856 2856
 					$feedback = $this->modnn($rs, $NN - $GENPOLY[$NROOTS] + $feedback);
2857
-					for ($j=1; $j < $NROOTS; ++$j) {
2857
+					for ($j = 1; $j < $NROOTS; ++$j) {
2858 2858
 					$parity[$j] ^= $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[($NROOTS - $j)])];
2859 2859
 					}
2860 2860
 				}
Please login to merge, or discard this patch.
lib/phpqrcode/qrencode.php 4 patches
Indentation   +381 added lines, -381 removed lines patch added patch discarded remove patch
@@ -25,478 +25,478 @@
 block discarded – undo
25 25
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 26
  */
27 27
  
28
-    class QRrsblock {
29
-        public $dataLength;
30
-        public $data = array();
31
-        public $eccLength;
32
-        public $ecc = array();
28
+	class QRrsblock {
29
+		public $dataLength;
30
+		public $data = array();
31
+		public $eccLength;
32
+		public $ecc = array();
33 33
         
34
-        public function __construct($dl, $data, $el, &$ecc, QRrsItem $rs)
35
-        {
36
-            $rs->encode_rs_char($data, $ecc);
34
+		public function __construct($dl, $data, $el, &$ecc, QRrsItem $rs)
35
+		{
36
+			$rs->encode_rs_char($data, $ecc);
37 37
         
38
-            $this->dataLength = $dl;
39
-            $this->data = $data;
40
-            $this->eccLength = $el;
41
-            $this->ecc = $ecc;
42
-        }
43
-    };
38
+			$this->dataLength = $dl;
39
+			$this->data = $data;
40
+			$this->eccLength = $el;
41
+			$this->ecc = $ecc;
42
+		}
43
+	};
44 44
     
45
-    //##########################################################################
45
+	//##########################################################################
46 46
 
47
-    class QRrawcode {
48
-        public $version;
49
-        public $datacode = array();
50
-        public $ecccode = array();
51
-        public $blocks;
52
-        public $rsblocks = array(); //of RSblock
53
-        public $count;
54
-        public $dataLength;
55
-        public $eccLength;
56
-        public $b1;
47
+	class QRrawcode {
48
+		public $version;
49
+		public $datacode = array();
50
+		public $ecccode = array();
51
+		public $blocks;
52
+		public $rsblocks = array(); //of RSblock
53
+		public $count;
54
+		public $dataLength;
55
+		public $eccLength;
56
+		public $b1;
57 57
         
58
-        //----------------------------------------------------------------------
59
-        public function __construct(QRinput $input)
60
-        {
61
-            $spec = array(0,0,0,0,0);
58
+		//----------------------------------------------------------------------
59
+		public function __construct(QRinput $input)
60
+		{
61
+			$spec = array(0,0,0,0,0);
62 62
             
63
-            $this->datacode = $input->getByteStream();
64
-            if(is_null($this->datacode)) {
65
-                throw new Exception('null imput string');
66
-            }
63
+			$this->datacode = $input->getByteStream();
64
+			if(is_null($this->datacode)) {
65
+				throw new Exception('null imput string');
66
+			}
67 67
 
68
-            QRspec::getEccSpec($input->getVersion(), $input->getErrorCorrectionLevel(), $spec);
68
+			QRspec::getEccSpec($input->getVersion(), $input->getErrorCorrectionLevel(), $spec);
69 69
 
70
-            $this->version = $input->getVersion();
71
-            $this->b1 = QRspec::rsBlockNum1($spec);
72
-            $this->dataLength = QRspec::rsDataLength($spec);
73
-            $this->eccLength = QRspec::rsEccLength($spec);
74
-            $this->ecccode = array_fill(0, $this->eccLength, 0);
75
-            $this->blocks = QRspec::rsBlockNum($spec);
70
+			$this->version = $input->getVersion();
71
+			$this->b1 = QRspec::rsBlockNum1($spec);
72
+			$this->dataLength = QRspec::rsDataLength($spec);
73
+			$this->eccLength = QRspec::rsEccLength($spec);
74
+			$this->ecccode = array_fill(0, $this->eccLength, 0);
75
+			$this->blocks = QRspec::rsBlockNum($spec);
76 76
             
77
-            $ret = $this->init($spec);
78
-            if($ret < 0) {
79
-                throw new Exception('block alloc error');
80
-                return null;
81
-            }
77
+			$ret = $this->init($spec);
78
+			if($ret < 0) {
79
+				throw new Exception('block alloc error');
80
+				return null;
81
+			}
82 82
 
83
-            $this->count = 0;
84
-        }
83
+			$this->count = 0;
84
+		}
85 85
         
86
-        //----------------------------------------------------------------------
87
-        public function init(array $spec)
88
-        {
89
-            $dl = QRspec::rsDataCodes1($spec);
90
-            $el = QRspec::rsEccCodes1($spec);
91
-            $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
86
+		//----------------------------------------------------------------------
87
+		public function init(array $spec)
88
+		{
89
+			$dl = QRspec::rsDataCodes1($spec);
90
+			$el = QRspec::rsEccCodes1($spec);
91
+			$rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
92 92
             
93 93
 
94
-            $blockNo = 0;
95
-            $dataPos = 0;
96
-            $eccPos = 0;
97
-            for($i=0; $i<QRspec::rsBlockNum1($spec); $i++) {
98
-                $ecc = array_slice($this->ecccode,$eccPos);
99
-                $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el,  $ecc, $rs);
100
-                $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
94
+			$blockNo = 0;
95
+			$dataPos = 0;
96
+			$eccPos = 0;
97
+			for($i=0; $i<QRspec::rsBlockNum1($spec); $i++) {
98
+				$ecc = array_slice($this->ecccode,$eccPos);
99
+				$this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el,  $ecc, $rs);
100
+				$this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
101 101
                 
102
-                $dataPos += $dl;
103
-                $eccPos += $el;
104
-                $blockNo++;
105
-            }
102
+				$dataPos += $dl;
103
+				$eccPos += $el;
104
+				$blockNo++;
105
+			}
106 106
 
107
-            if(QRspec::rsBlockNum2($spec) == 0)
108
-                return 0;
107
+			if(QRspec::rsBlockNum2($spec) == 0)
108
+				return 0;
109 109
 
110
-            $dl = QRspec::rsDataCodes2($spec);
111
-            $el = QRspec::rsEccCodes2($spec);
112
-            $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
110
+			$dl = QRspec::rsDataCodes2($spec);
111
+			$el = QRspec::rsEccCodes2($spec);
112
+			$rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
113 113
             
114
-            if($rs == NULL) return -1;
114
+			if($rs == NULL) return -1;
115 115
             
116
-            for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) {
117
-                $ecc = array_slice($this->ecccode,$eccPos);
118
-                $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
119
-                $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
116
+			for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) {
117
+				$ecc = array_slice($this->ecccode,$eccPos);
118
+				$this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
119
+				$this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
120 120
                 
121
-                $dataPos += $dl;
122
-                $eccPos += $el;
123
-                $blockNo++;
124
-            }
121
+				$dataPos += $dl;
122
+				$eccPos += $el;
123
+				$blockNo++;
124
+			}
125 125
 
126
-            return 0;
127
-        }
126
+			return 0;
127
+		}
128 128
         
129
-        //----------------------------------------------------------------------
130
-        public function getCode()
131
-        {
132
-            $ret = 0;
129
+		//----------------------------------------------------------------------
130
+		public function getCode()
131
+		{
132
+			$ret = 0;
133 133
 
134
-            if($this->count < $this->dataLength) {
135
-                $row = $this->count % $this->blocks;
136
-                $col = $this->count / $this->blocks;
137
-                if($col >= $this->rsblocks[0]->dataLength) {
138
-                    $row += $this->b1;
139
-                }
140
-                $ret = $this->rsblocks[$row]->data[$col];
141
-            } else if($this->count < $this->dataLength + $this->eccLength) {
142
-                $row = ($this->count - $this->dataLength) % $this->blocks;
143
-                $col = ($this->count - $this->dataLength) / $this->blocks;
144
-                $ret = $this->rsblocks[$row]->ecc[$col];
145
-            } else {
146
-                return 0;
147
-            }
148
-            $this->count++;
134
+			if($this->count < $this->dataLength) {
135
+				$row = $this->count % $this->blocks;
136
+				$col = $this->count / $this->blocks;
137
+				if($col >= $this->rsblocks[0]->dataLength) {
138
+					$row += $this->b1;
139
+				}
140
+				$ret = $this->rsblocks[$row]->data[$col];
141
+			} else if($this->count < $this->dataLength + $this->eccLength) {
142
+				$row = ($this->count - $this->dataLength) % $this->blocks;
143
+				$col = ($this->count - $this->dataLength) / $this->blocks;
144
+				$ret = $this->rsblocks[$row]->ecc[$col];
145
+			} else {
146
+				return 0;
147
+			}
148
+			$this->count++;
149 149
             
150
-            return $ret;
151
-        }
152
-    }
150
+			return $ret;
151
+		}
152
+	}
153 153
 
154
-    //##########################################################################
154
+	//##########################################################################
155 155
     
156
-    class QRcode {
156
+	class QRcode {
157 157
     
158
-        public $version;
159
-        public $width;
160
-        public $data; 
158
+		public $version;
159
+		public $width;
160
+		public $data; 
161 161
         
162
-        //----------------------------------------------------------------------
163
-        public function encodeMask(QRinput $input, $mask)
164
-        {
165
-            if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
166
-                throw new Exception('wrong version');
167
-            }
168
-            if($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) {
169
-                throw new Exception('wrong level');
170
-            }
162
+		//----------------------------------------------------------------------
163
+		public function encodeMask(QRinput $input, $mask)
164
+		{
165
+			if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
166
+				throw new Exception('wrong version');
167
+			}
168
+			if($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) {
169
+				throw new Exception('wrong level');
170
+			}
171 171
 
172
-            $raw = new QRrawcode($input);
172
+			$raw = new QRrawcode($input);
173 173
             
174
-            QRtools::markTime('after_raw');
174
+			QRtools::markTime('after_raw');
175 175
             
176
-            $version = $raw->version;
177
-            $width = QRspec::getWidth($version);
178
-            $frame = QRspec::newFrame($version);
176
+			$version = $raw->version;
177
+			$width = QRspec::getWidth($version);
178
+			$frame = QRspec::newFrame($version);
179 179
             
180
-            $filler = new FrameFiller($width, $frame);
181
-            if(is_null($filler)) {
182
-                return NULL;
183
-            }
180
+			$filler = new FrameFiller($width, $frame);
181
+			if(is_null($filler)) {
182
+				return NULL;
183
+			}
184 184
 
185
-            // inteleaved data and ecc codes
186
-            for($i=0; $i<$raw->dataLength + $raw->eccLength; $i++) {
187
-                $code = $raw->getCode();
188
-                $bit = 0x80;
189
-                for($j=0; $j<8; $j++) {
190
-                    $addr = $filler->next();
191
-                    $filler->setFrameAt($addr, 0x02 | (($bit & $code) != 0));
192
-                    $bit = $bit >> 1;
193
-                }
194
-            }
185
+			// inteleaved data and ecc codes
186
+			for($i=0; $i<$raw->dataLength + $raw->eccLength; $i++) {
187
+				$code = $raw->getCode();
188
+				$bit = 0x80;
189
+				for($j=0; $j<8; $j++) {
190
+					$addr = $filler->next();
191
+					$filler->setFrameAt($addr, 0x02 | (($bit & $code) != 0));
192
+					$bit = $bit >> 1;
193
+				}
194
+			}
195 195
             
196
-            QRtools::markTime('after_filler');
196
+			QRtools::markTime('after_filler');
197 197
             
198
-            unset($raw);
198
+			unset($raw);
199 199
             
200
-            // remainder bits
201
-            $j = QRspec::getRemainder($version);
202
-            for($i=0; $i<$j; $i++) {
203
-                $addr = $filler->next();
204
-                $filler->setFrameAt($addr, 0x02);
205
-            }
200
+			// remainder bits
201
+			$j = QRspec::getRemainder($version);
202
+			for($i=0; $i<$j; $i++) {
203
+				$addr = $filler->next();
204
+				$filler->setFrameAt($addr, 0x02);
205
+			}
206 206
             
207
-            $frame = $filler->frame;
208
-            unset($filler);
207
+			$frame = $filler->frame;
208
+			unset($filler);
209 209
             
210 210
             
211
-            // masking
212
-            $maskObj = new QRmask();
213
-            if($mask < 0) {
211
+			// masking
212
+			$maskObj = new QRmask();
213
+			if($mask < 0) {
214 214
             
215
-                if (QR_FIND_BEST_MASK) {
216
-                    $masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel());
217
-                } else {
218
-                    $masked = $maskObj->makeMask($width, $frame, (intval(QR_DEFAULT_MASK) % 8), $input->getErrorCorrectionLevel());
219
-                }
220
-            } else {
221
-                $masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
222
-            }
215
+				if (QR_FIND_BEST_MASK) {
216
+					$masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel());
217
+				} else {
218
+					$masked = $maskObj->makeMask($width, $frame, (intval(QR_DEFAULT_MASK) % 8), $input->getErrorCorrectionLevel());
219
+				}
220
+			} else {
221
+				$masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
222
+			}
223 223
             
224
-            if($masked == NULL) {
225
-                return NULL;
226
-            }
224
+			if($masked == NULL) {
225
+				return NULL;
226
+			}
227 227
             
228
-            QRtools::markTime('after_mask');
228
+			QRtools::markTime('after_mask');
229 229
             
230
-            $this->version = $version;
231
-            $this->width = $width;
232
-            $this->data = $masked;
230
+			$this->version = $version;
231
+			$this->width = $width;
232
+			$this->data = $masked;
233 233
             
234
-            return $this;
235
-        }
234
+			return $this;
235
+		}
236 236
     
237
-        //----------------------------------------------------------------------
238
-        public function encodeInput(QRinput $input)
239
-        {
240
-            return $this->encodeMask($input, -1);
241
-        }
237
+		//----------------------------------------------------------------------
238
+		public function encodeInput(QRinput $input)
239
+		{
240
+			return $this->encodeMask($input, -1);
241
+		}
242 242
         
243
-        //----------------------------------------------------------------------
244
-        public function encodeString8bit($string, $version, $level)
245
-        {
246
-            if(string == NULL) {
247
-                throw new Exception('empty string!');
248
-                return NULL;
249
-            }
243
+		//----------------------------------------------------------------------
244
+		public function encodeString8bit($string, $version, $level)
245
+		{
246
+			if(string == NULL) {
247
+				throw new Exception('empty string!');
248
+				return NULL;
249
+			}
250 250
 
251
-            $input = new QRinput($version, $level);
252
-            if($input == NULL) return NULL;
251
+			$input = new QRinput($version, $level);
252
+			if($input == NULL) return NULL;
253 253
 
254
-            $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string));
255
-            if($ret < 0) {
256
-                unset($input);
257
-                return NULL;
258
-            }
259
-            return $this->encodeInput($input);
260
-        }
254
+			$ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string));
255
+			if($ret < 0) {
256
+				unset($input);
257
+				return NULL;
258
+			}
259
+			return $this->encodeInput($input);
260
+		}
261 261
 
262
-        //----------------------------------------------------------------------
263
-        public function encodeString($string, $version, $level, $hint, $casesensitive)
264
-        {
262
+		//----------------------------------------------------------------------
263
+		public function encodeString($string, $version, $level, $hint, $casesensitive)
264
+		{
265 265
 
266
-            if($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) {
267
-                throw new Exception('bad hint');
268
-                return NULL;
269
-            }
266
+			if($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) {
267
+				throw new Exception('bad hint');
268
+				return NULL;
269
+			}
270 270
 
271
-            $input = new QRinput($version, $level);
272
-            if($input == NULL) return NULL;
271
+			$input = new QRinput($version, $level);
272
+			if($input == NULL) return NULL;
273 273
 
274
-            $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive);
275
-            if($ret < 0) {
276
-                return NULL;
277
-            }
274
+			$ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive);
275
+			if($ret < 0) {
276
+				return NULL;
277
+			}
278 278
 
279
-            return $this->encodeInput($input);
280
-        }
279
+			return $this->encodeInput($input);
280
+		}
281 281
         
282
-        //----------------------------------------------------------------------
283
-        public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false) 
284
-        {
285
-            $enc = QRencode::factory($level, $size, $margin);
286
-            return $enc->encodePNG($text, $outfile, $saveandprint=false);
287
-        }
282
+		//----------------------------------------------------------------------
283
+		public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false) 
284
+		{
285
+			$enc = QRencode::factory($level, $size, $margin);
286
+			return $enc->encodePNG($text, $outfile, $saveandprint=false);
287
+		}
288 288
 
289
-        //----------------------------------------------------------------------
290
-        public static function text($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) 
291
-        {
292
-            $enc = QRencode::factory($level, $size, $margin);
293
-            return $enc->encode($text, $outfile);
294
-        }
289
+		//----------------------------------------------------------------------
290
+		public static function text($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) 
291
+		{
292
+			$enc = QRencode::factory($level, $size, $margin);
293
+			return $enc->encode($text, $outfile);
294
+		}
295 295
 
296
-        //----------------------------------------------------------------------
297
-        public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) 
298
-        {
299
-            $enc = QRencode::factory($level, $size, $margin);
300
-            return $enc->encodeRAW($text, $outfile);
301
-        }
302
-    }
296
+		//----------------------------------------------------------------------
297
+		public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) 
298
+		{
299
+			$enc = QRencode::factory($level, $size, $margin);
300
+			return $enc->encodeRAW($text, $outfile);
301
+		}
302
+	}
303 303
     
304
-    //##########################################################################
304
+	//##########################################################################
305 305
     
306
-    class FrameFiller {
306
+	class FrameFiller {
307 307
     
308
-        public $width;
309
-        public $frame;
310
-        public $x;
311
-        public $y;
312
-        public $dir;
313
-        public $bit;
308
+		public $width;
309
+		public $frame;
310
+		public $x;
311
+		public $y;
312
+		public $dir;
313
+		public $bit;
314 314
         
315
-        //----------------------------------------------------------------------
316
-        public function __construct($width, &$frame)
317
-        {
318
-            $this->width = $width;
319
-            $this->frame = $frame;
320
-            $this->x = $width - 1;
321
-            $this->y = $width - 1;
322
-            $this->dir = -1;
323
-            $this->bit = -1;
324
-        }
315
+		//----------------------------------------------------------------------
316
+		public function __construct($width, &$frame)
317
+		{
318
+			$this->width = $width;
319
+			$this->frame = $frame;
320
+			$this->x = $width - 1;
321
+			$this->y = $width - 1;
322
+			$this->dir = -1;
323
+			$this->bit = -1;
324
+		}
325 325
         
326
-        //----------------------------------------------------------------------
327
-        public function setFrameAt($at, $val)
328
-        {
329
-            $this->frame[$at['y']][$at['x']] = chr($val);
330
-        }
326
+		//----------------------------------------------------------------------
327
+		public function setFrameAt($at, $val)
328
+		{
329
+			$this->frame[$at['y']][$at['x']] = chr($val);
330
+		}
331 331
         
332
-        //----------------------------------------------------------------------
333
-        public function getFrameAt($at)
334
-        {
335
-            return ord($this->frame[$at['y']][$at['x']]);
336
-        }
332
+		//----------------------------------------------------------------------
333
+		public function getFrameAt($at)
334
+		{
335
+			return ord($this->frame[$at['y']][$at['x']]);
336
+		}
337 337
         
338
-        //----------------------------------------------------------------------
339
-        public function next()
340
-        {
341
-            do {
338
+		//----------------------------------------------------------------------
339
+		public function next()
340
+		{
341
+			do {
342 342
             
343
-                if($this->bit == -1) {
344
-                    $this->bit = 0;
345
-                    return array('x'=>$this->x, 'y'=>$this->y);
346
-                }
343
+				if($this->bit == -1) {
344
+					$this->bit = 0;
345
+					return array('x'=>$this->x, 'y'=>$this->y);
346
+				}
347 347
 
348
-                $x = $this->x;
349
-                $y = $this->y;
350
-                $w = $this->width;
348
+				$x = $this->x;
349
+				$y = $this->y;
350
+				$w = $this->width;
351 351
 
352
-                if($this->bit == 0) {
353
-                    $x--;
354
-                    $this->bit++;
355
-                } else {
356
-                    $x++;
357
-                    $y += $this->dir;
358
-                    $this->bit--;
359
-                }
352
+				if($this->bit == 0) {
353
+					$x--;
354
+					$this->bit++;
355
+				} else {
356
+					$x++;
357
+					$y += $this->dir;
358
+					$this->bit--;
359
+				}
360 360
 
361
-                if($this->dir < 0) {
362
-                    if($y < 0) {
363
-                        $y = 0;
364
-                        $x -= 2;
365
-                        $this->dir = 1;
366
-                        if($x == 6) {
367
-                            $x--;
368
-                            $y = 9;
369
-                        }
370
-                    }
371
-                } else {
372
-                    if($y == $w) {
373
-                        $y = $w - 1;
374
-                        $x -= 2;
375
-                        $this->dir = -1;
376
-                        if($x == 6) {
377
-                            $x--;
378
-                            $y -= 8;
379
-                        }
380
-                    }
381
-                }
382
-                if($x < 0 || $y < 0) return null;
361
+				if($this->dir < 0) {
362
+					if($y < 0) {
363
+						$y = 0;
364
+						$x -= 2;
365
+						$this->dir = 1;
366
+						if($x == 6) {
367
+							$x--;
368
+							$y = 9;
369
+						}
370
+					}
371
+				} else {
372
+					if($y == $w) {
373
+						$y = $w - 1;
374
+						$x -= 2;
375
+						$this->dir = -1;
376
+						if($x == 6) {
377
+							$x--;
378
+							$y -= 8;
379
+						}
380
+					}
381
+				}
382
+				if($x < 0 || $y < 0) return null;
383 383
 
384
-                $this->x = $x;
385
-                $this->y = $y;
384
+				$this->x = $x;
385
+				$this->y = $y;
386 386
 
387
-            } while(ord($this->frame[$y][$x]) & 0x80);
387
+			} while(ord($this->frame[$y][$x]) & 0x80);
388 388
                         
389
-            return array('x'=>$x, 'y'=>$y);
390
-        }
389
+			return array('x'=>$x, 'y'=>$y);
390
+		}
391 391
         
392
-    } ;
392
+	} ;
393 393
     
394
-    //##########################################################################    
394
+	//##########################################################################    
395 395
     
396
-    class QRencode {
396
+	class QRencode {
397 397
     
398
-        public $casesensitive = true;
399
-        public $eightbit = false;
398
+		public $casesensitive = true;
399
+		public $eightbit = false;
400 400
         
401
-        public $version = 0;
402
-        public $size = 3;
403
-        public $margin = 4;
401
+		public $version = 0;
402
+		public $size = 3;
403
+		public $margin = 4;
404 404
         
405
-        public $structured = 0; // not supported yet
405
+		public $structured = 0; // not supported yet
406 406
         
407
-        public $level = QR_ECLEVEL_L;
408
-        public $hint = QR_MODE_8;
407
+		public $level = QR_ECLEVEL_L;
408
+		public $hint = QR_MODE_8;
409 409
         
410
-        //----------------------------------------------------------------------
411
-        public static function factory($level = QR_ECLEVEL_L, $size = 3, $margin = 4)
412
-        {
413
-            $enc = new QRencode();
414
-            $enc->size = $size;
415
-            $enc->margin = $margin;
410
+		//----------------------------------------------------------------------
411
+		public static function factory($level = QR_ECLEVEL_L, $size = 3, $margin = 4)
412
+		{
413
+			$enc = new QRencode();
414
+			$enc->size = $size;
415
+			$enc->margin = $margin;
416 416
             
417
-            switch ($level.'') {
418
-                case '0':
419
-                case '1':
420
-                case '2':
421
-                case '3':
422
-                        $enc->level = $level;
423
-                    break;
424
-                case 'l':
425
-                case 'L':
426
-                        $enc->level = QR_ECLEVEL_L;
427
-                    break;
428
-                case 'm':
429
-                case 'M':
430
-                        $enc->level = QR_ECLEVEL_M;
431
-                    break;
432
-                case 'q':
433
-                case 'Q':
434
-                        $enc->level = QR_ECLEVEL_Q;
435
-                    break;
436
-                case 'h':
437
-                case 'H':
438
-                        $enc->level = QR_ECLEVEL_H;
439
-                    break;
440
-            }
417
+			switch ($level.'') {
418
+				case '0':
419
+				case '1':
420
+				case '2':
421
+				case '3':
422
+						$enc->level = $level;
423
+					break;
424
+				case 'l':
425
+				case 'L':
426
+						$enc->level = QR_ECLEVEL_L;
427
+					break;
428
+				case 'm':
429
+				case 'M':
430
+						$enc->level = QR_ECLEVEL_M;
431
+					break;
432
+				case 'q':
433
+				case 'Q':
434
+						$enc->level = QR_ECLEVEL_Q;
435
+					break;
436
+				case 'h':
437
+				case 'H':
438
+						$enc->level = QR_ECLEVEL_H;
439
+					break;
440
+			}
441 441
             
442
-            return $enc;
443
-        }
442
+			return $enc;
443
+		}
444 444
         
445
-        //----------------------------------------------------------------------
446
-        public function encodeRAW($intext, $outfile = false) 
447
-        {
448
-            $code = new QRcode();
445
+		//----------------------------------------------------------------------
446
+		public function encodeRAW($intext, $outfile = false) 
447
+		{
448
+			$code = new QRcode();
449 449
 
450
-            if($this->eightbit) {
451
-                $code->encodeString8bit($intext, $this->version, $this->level);
452
-            } else {
453
-                $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
454
-            }
450
+			if($this->eightbit) {
451
+				$code->encodeString8bit($intext, $this->version, $this->level);
452
+			} else {
453
+				$code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
454
+			}
455 455
             
456
-            return $code->data;
457
-        }
456
+			return $code->data;
457
+		}
458 458
 
459
-        //----------------------------------------------------------------------
460
-        public function encode($intext, $outfile = false) 
461
-        {
462
-            $code = new QRcode();
459
+		//----------------------------------------------------------------------
460
+		public function encode($intext, $outfile = false) 
461
+		{
462
+			$code = new QRcode();
463 463
 
464
-            if($this->eightbit) {
465
-                $code->encodeString8bit($intext, $this->version, $this->level);
466
-            } else {
467
-                $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
468
-            }
464
+			if($this->eightbit) {
465
+				$code->encodeString8bit($intext, $this->version, $this->level);
466
+			} else {
467
+				$code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
468
+			}
469 469
             
470
-            QRtools::markTime('after_encode');
470
+			QRtools::markTime('after_encode');
471 471
             
472
-            if ($outfile!== false) {
473
-                file_put_contents($outfile, join("\n", QRtools::binarize($code->data)));
474
-            } else {
475
-                return QRtools::binarize($code->data);
476
-            }
477
-        }
472
+			if ($outfile!== false) {
473
+				file_put_contents($outfile, join("\n", QRtools::binarize($code->data)));
474
+			} else {
475
+				return QRtools::binarize($code->data);
476
+			}
477
+		}
478 478
         
479
-        //----------------------------------------------------------------------
480
-        public function encodePNG($intext, $outfile = false,$saveandprint=false) 
481
-        {
482
-            try {
479
+		//----------------------------------------------------------------------
480
+		public function encodePNG($intext, $outfile = false,$saveandprint=false) 
481
+		{
482
+			try {
483 483
             
484
-                ob_start();
485
-                $tab = $this->encode($intext);
486
-                $err = ob_get_contents();
487
-                ob_end_clean();
484
+				ob_start();
485
+				$tab = $this->encode($intext);
486
+				$err = ob_get_contents();
487
+				ob_end_clean();
488 488
                 
489
-                if ($err != '')
490
-                    QRtools::log($outfile, $err);
489
+				if ($err != '')
490
+					QRtools::log($outfile, $err);
491 491
                 
492
-                $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
492
+				$maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
493 493
                 
494
-                QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint);
494
+				QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint);
495 495
             
496
-            } catch (Exception $e) {
496
+			} catch (Exception $e) {
497 497
             
498
-                QRtools::log($outfile, $e->getMessage());
498
+				QRtools::log($outfile, $e->getMessage());
499 499
             
500
-            }
501
-        }
502
-    }
500
+			}
501
+		}
502
+	}
Please login to merge, or discard this patch.
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -415,28 +415,28 @@
 block discarded – undo
415 415
             $enc->margin = $margin;
416 416
             
417 417
             switch ($level.'') {
418
-                case '0':
419
-                case '1':
420
-                case '2':
421
-                case '3':
422
-                        $enc->level = $level;
423
-                    break;
424
-                case 'l':
425
-                case 'L':
426
-                        $enc->level = QR_ECLEVEL_L;
427
-                    break;
428
-                case 'm':
429
-                case 'M':
430
-                        $enc->level = QR_ECLEVEL_M;
431
-                    break;
432
-                case 'q':
433
-                case 'Q':
434
-                        $enc->level = QR_ECLEVEL_Q;
435
-                    break;
436
-                case 'h':
437
-                case 'H':
438
-                        $enc->level = QR_ECLEVEL_H;
439
-                    break;
418
+            case '0':
419
+            case '1':
420
+            case '2':
421
+            case '3':
422
+                    $enc->level = $level;
423
+                break;
424
+            case 'l':
425
+            case 'L':
426
+                    $enc->level = QR_ECLEVEL_L;
427
+                break;
428
+            case 'm':
429
+            case 'M':
430
+                    $enc->level = QR_ECLEVEL_M;
431
+                break;
432
+            case 'q':
433
+            case 'Q':
434
+                    $enc->level = QR_ECLEVEL_Q;
435
+                break;
436
+            case 'h':
437
+            case 'H':
438
+                    $enc->level = QR_ECLEVEL_H;
439
+                break;
440 440
             }
441 441
             
442 442
             return $enc;
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
         //----------------------------------------------------------------------
59 59
         public function __construct(QRinput $input)
60 60
         {
61
-            $spec = array(0,0,0,0,0);
61
+            $spec = array(0, 0, 0, 0, 0);
62 62
             
63 63
             $this->datacode = $input->getByteStream();
64
-            if(is_null($this->datacode)) {
64
+            if (is_null($this->datacode)) {
65 65
                 throw new Exception('null imput string');
66 66
             }
67 67
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             $this->blocks = QRspec::rsBlockNum($spec);
76 76
             
77 77
             $ret = $this->init($spec);
78
-            if($ret < 0) {
78
+            if ($ret < 0) {
79 79
                 throw new Exception('block alloc error');
80 80
                 return null;
81 81
             }
@@ -94,29 +94,29 @@  discard block
 block discarded – undo
94 94
             $blockNo = 0;
95 95
             $dataPos = 0;
96 96
             $eccPos = 0;
97
-            for($i=0; $i<QRspec::rsBlockNum1($spec); $i++) {
98
-                $ecc = array_slice($this->ecccode,$eccPos);
99
-                $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el,  $ecc, $rs);
100
-                $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
97
+            for ($i = 0; $i < QRspec::rsBlockNum1($spec); $i++) {
98
+                $ecc = array_slice($this->ecccode, $eccPos);
99
+                $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
100
+                $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc);
101 101
                 
102 102
                 $dataPos += $dl;
103 103
                 $eccPos += $el;
104 104
                 $blockNo++;
105 105
             }
106 106
 
107
-            if(QRspec::rsBlockNum2($spec) == 0)
107
+            if (QRspec::rsBlockNum2($spec) == 0)
108 108
                 return 0;
109 109
 
110 110
             $dl = QRspec::rsDataCodes2($spec);
111 111
             $el = QRspec::rsEccCodes2($spec);
112 112
             $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
113 113
             
114
-            if($rs == NULL) return -1;
114
+            if ($rs == NULL) return -1;
115 115
             
116
-            for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) {
117
-                $ecc = array_slice($this->ecccode,$eccPos);
116
+            for ($i = 0; $i < QRspec::rsBlockNum2($spec); $i++) {
117
+                $ecc = array_slice($this->ecccode, $eccPos);
118 118
                 $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs);
119
-                $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
119
+                $this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc);
120 120
                 
121 121
                 $dataPos += $dl;
122 122
                 $eccPos += $el;
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
         {
132 132
             $ret = 0;
133 133
 
134
-            if($this->count < $this->dataLength) {
134
+            if ($this->count < $this->dataLength) {
135 135
                 $row = $this->count % $this->blocks;
136 136
                 $col = $this->count / $this->blocks;
137
-                if($col >= $this->rsblocks[0]->dataLength) {
137
+                if ($col >= $this->rsblocks[0]->dataLength) {
138 138
                     $row += $this->b1;
139 139
                 }
140 140
                 $ret = $this->rsblocks[$row]->data[$col];
141
-            } else if($this->count < $this->dataLength + $this->eccLength) {
141
+            } else if ($this->count < $this->dataLength + $this->eccLength) {
142 142
                 $row = ($this->count - $this->dataLength) % $this->blocks;
143 143
                 $col = ($this->count - $this->dataLength) / $this->blocks;
144 144
                 $ret = $this->rsblocks[$row]->ecc[$col];
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
         //----------------------------------------------------------------------
163 163
         public function encodeMask(QRinput $input, $mask)
164 164
         {
165
-            if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
165
+            if ($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) {
166 166
                 throw new Exception('wrong version');
167 167
             }
168
-            if($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) {
168
+            if ($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) {
169 169
                 throw new Exception('wrong level');
170 170
             }
171 171
 
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
             $frame = QRspec::newFrame($version);
179 179
             
180 180
             $filler = new FrameFiller($width, $frame);
181
-            if(is_null($filler)) {
181
+            if (is_null($filler)) {
182 182
                 return NULL;
183 183
             }
184 184
 
185 185
             // inteleaved data and ecc codes
186
-            for($i=0; $i<$raw->dataLength + $raw->eccLength; $i++) {
186
+            for ($i = 0; $i < $raw->dataLength + $raw->eccLength; $i++) {
187 187
                 $code = $raw->getCode();
188 188
                 $bit = 0x80;
189
-                for($j=0; $j<8; $j++) {
189
+                for ($j = 0; $j < 8; $j++) {
190 190
                     $addr = $filler->next();
191 191
                     $filler->setFrameAt($addr, 0x02 | (($bit & $code) != 0));
192 192
                     $bit = $bit >> 1;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             
200 200
             // remainder bits
201 201
             $j = QRspec::getRemainder($version);
202
-            for($i=0; $i<$j; $i++) {
202
+            for ($i = 0; $i < $j; $i++) {
203 203
                 $addr = $filler->next();
204 204
                 $filler->setFrameAt($addr, 0x02);
205 205
             }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             
211 211
             // masking
212 212
             $maskObj = new QRmask();
213
-            if($mask < 0) {
213
+            if ($mask < 0) {
214 214
             
215 215
                 if (QR_FIND_BEST_MASK) {
216 216
                     $masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel());
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
                 $masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
222 222
             }
223 223
             
224
-            if($masked == NULL) {
224
+            if ($masked == NULL) {
225 225
                 return NULL;
226 226
             }
227 227
             
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
         //----------------------------------------------------------------------
244 244
         public function encodeString8bit($string, $version, $level)
245 245
         {
246
-            if(string == NULL) {
246
+            if (string == NULL) {
247 247
                 throw new Exception('empty string!');
248 248
                 return NULL;
249 249
             }
250 250
 
251 251
             $input = new QRinput($version, $level);
252
-            if($input == NULL) return NULL;
252
+            if ($input == NULL) return NULL;
253 253
 
254 254
             $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string));
255
-            if($ret < 0) {
255
+            if ($ret < 0) {
256 256
                 unset($input);
257 257
                 return NULL;
258 258
             }
@@ -263,16 +263,16 @@  discard block
 block discarded – undo
263 263
         public function encodeString($string, $version, $level, $hint, $casesensitive)
264 264
         {
265 265
 
266
-            if($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) {
266
+            if ($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) {
267 267
                 throw new Exception('bad hint');
268 268
                 return NULL;
269 269
             }
270 270
 
271 271
             $input = new QRinput($version, $level);
272
-            if($input == NULL) return NULL;
272
+            if ($input == NULL) return NULL;
273 273
 
274 274
             $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive);
275
-            if($ret < 0) {
275
+            if ($ret < 0) {
276 276
                 return NULL;
277 277
             }
278 278
 
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
         }
281 281
         
282 282
         //----------------------------------------------------------------------
283
-        public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false) 
283
+        public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint = false) 
284 284
         {
285 285
             $enc = QRencode::factory($level, $size, $margin);
286
-            return $enc->encodePNG($text, $outfile, $saveandprint=false);
286
+            return $enc->encodePNG($text, $outfile, $saveandprint = false);
287 287
         }
288 288
 
289 289
         //----------------------------------------------------------------------
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         {
341 341
             do {
342 342
             
343
-                if($this->bit == -1) {
343
+                if ($this->bit == -1) {
344 344
                     $this->bit = 0;
345 345
                     return array('x'=>$this->x, 'y'=>$this->y);
346 346
                 }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                 $y = $this->y;
350 350
                 $w = $this->width;
351 351
 
352
-                if($this->bit == 0) {
352
+                if ($this->bit == 0) {
353 353
                     $x--;
354 354
                     $this->bit++;
355 355
                 } else {
@@ -358,33 +358,33 @@  discard block
 block discarded – undo
358 358
                     $this->bit--;
359 359
                 }
360 360
 
361
-                if($this->dir < 0) {
362
-                    if($y < 0) {
361
+                if ($this->dir < 0) {
362
+                    if ($y < 0) {
363 363
                         $y = 0;
364 364
                         $x -= 2;
365 365
                         $this->dir = 1;
366
-                        if($x == 6) {
366
+                        if ($x == 6) {
367 367
                             $x--;
368 368
                             $y = 9;
369 369
                         }
370 370
                     }
371 371
                 } else {
372
-                    if($y == $w) {
372
+                    if ($y == $w) {
373 373
                         $y = $w - 1;
374 374
                         $x -= 2;
375 375
                         $this->dir = -1;
376
-                        if($x == 6) {
376
+                        if ($x == 6) {
377 377
                             $x--;
378 378
                             $y -= 8;
379 379
                         }
380 380
                     }
381 381
                 }
382
-                if($x < 0 || $y < 0) return null;
382
+                if ($x < 0 || $y < 0) return null;
383 383
 
384 384
                 $this->x = $x;
385 385
                 $this->y = $y;
386 386
 
387
-            } while(ord($this->frame[$y][$x]) & 0x80);
387
+            } while (ord($this->frame[$y][$x]) & 0x80);
388 388
                         
389 389
             return array('x'=>$x, 'y'=>$y);
390 390
         }
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
         {
448 448
             $code = new QRcode();
449 449
 
450
-            if($this->eightbit) {
450
+            if ($this->eightbit) {
451 451
                 $code->encodeString8bit($intext, $this->version, $this->level);
452 452
             } else {
453 453
                 $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
         {
462 462
             $code = new QRcode();
463 463
 
464
-            if($this->eightbit) {
464
+            if ($this->eightbit) {
465 465
                 $code->encodeString8bit($intext, $this->version, $this->level);
466 466
             } else {
467 467
                 $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
             
470 470
             QRtools::markTime('after_encode');
471 471
             
472
-            if ($outfile!== false) {
472
+            if ($outfile !== false) {
473 473
                 file_put_contents($outfile, join("\n", QRtools::binarize($code->data)));
474 474
             } else {
475 475
                 return QRtools::binarize($code->data);
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         }
478 478
         
479 479
         //----------------------------------------------------------------------
480
-        public function encodePNG($intext, $outfile = false,$saveandprint=false) 
480
+        public function encodePNG($intext, $outfile = false, $saveandprint = false) 
481 481
         {
482 482
             try {
483 483
             
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
                 if ($err != '')
490 490
                     QRtools::log($outfile, $err);
491 491
                 
492
-                $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
492
+                $maxSize = (int) (QR_PNG_MAXIMUM_SIZE / (count($tab) + 2 * $this->margin));
493 493
                 
494
-                QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint);
494
+                QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin, $saveandprint);
495 495
             
496 496
             } catch (Exception $e) {
497 497
             
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -104,14 +104,17 @@  discard block
 block discarded – undo
104 104
                 $blockNo++;
105 105
             }
106 106
 
107
-            if(QRspec::rsBlockNum2($spec) == 0)
108
-                return 0;
107
+            if(QRspec::rsBlockNum2($spec) == 0) {
108
+                            return 0;
109
+            }
109 110
 
110 111
             $dl = QRspec::rsDataCodes2($spec);
111 112
             $el = QRspec::rsEccCodes2($spec);
112 113
             $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
113 114
             
114
-            if($rs == NULL) return -1;
115
+            if($rs == NULL) {
116
+            	return -1;
117
+            }
115 118
             
116 119
             for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) {
117 120
                 $ecc = array_slice($this->ecccode,$eccPos);
@@ -249,7 +252,9 @@  discard block
 block discarded – undo
249 252
             }
250 253
 
251 254
             $input = new QRinput($version, $level);
252
-            if($input == NULL) return NULL;
255
+            if($input == NULL) {
256
+            	return NULL;
257
+            }
253 258
 
254 259
             $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string));
255 260
             if($ret < 0) {
@@ -269,7 +274,9 @@  discard block
 block discarded – undo
269 274
             }
270 275
 
271 276
             $input = new QRinput($version, $level);
272
-            if($input == NULL) return NULL;
277
+            if($input == NULL) {
278
+            	return NULL;
279
+            }
273 280
 
274 281
             $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive);
275 282
             if($ret < 0) {
@@ -379,7 +386,9 @@  discard block
 block discarded – undo
379 386
                         }
380 387
                     }
381 388
                 }
382
-                if($x < 0 || $y < 0) return null;
389
+                if($x < 0 || $y < 0) {
390
+                	return null;
391
+                }
383 392
 
384 393
                 $this->x = $x;
385 394
                 $this->y = $y;
@@ -486,8 +495,9 @@  discard block
 block discarded – undo
486 495
                 $err = ob_get_contents();
487 496
                 ob_end_clean();
488 497
                 
489
-                if ($err != '')
490
-                    QRtools::log($outfile, $err);
498
+                if ($err != '') {
499
+                                    QRtools::log($outfile, $err);
500
+                }
491 501
                 
492 502
                 $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
493 503
                 
Please login to merge, or discard this patch.