| @@ -12,7 +12,7 @@ discard block | ||
| 12 | 12 | use tinymeng\code\Gateways\qrcode\QRrawcode; | 
| 13 | 13 | use tinymeng\code\Connector\Gateway; | 
| 14 | 14 | |
| 15 | -class Qr extends Gateway{ | |
| 15 | +class Qr extends Gateway { | |
| 16 | 16 | |
| 17 | 17 | public $version; | 
| 18 | 18 | public $width; | 
| @@ -28,23 +28,23 @@ discard block | ||
| 28 | 28 | * @author Tinymeng <[email protected]> | 
| 29 | 29 | * @date: 2019/9/27 11:28 | 
| 30 | 30 | */ | 
| 31 | -    public function create($data,$filePath=false,$matrixPointSize=10,$errorCorrectionLevel='L'){ | |
| 32 | -        if (trim($data) == ''){ | |
| 31 | +    public function create($data, $filePath = false, $matrixPointSize = 10, $errorCorrectionLevel = 'L') { | |
| 32 | +        if (trim($data) == '') { | |
| 33 | 33 |              throw new Exception('data 不能为空!'); | 
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | -        if (!in_array($errorCorrectionLevel, array('L','M','Q','H'))){ | |
| 36 | +        if (!in_array($errorCorrectionLevel, array('L', 'M', 'Q', 'H'))) { | |
| 37 | 37 | $errorCorrectionLevel = 'L'; | 
| 38 | 38 | } | 
| 39 | -        if (!empty($matrixPointSize)){ | |
| 40 | - $matrixPointSize = min(max((int)$matrixPointSize, 1), 10); | |
| 39 | +        if (!empty($matrixPointSize)) { | |
| 40 | + $matrixPointSize = min(max((int) $matrixPointSize, 1), 10); | |
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | -        if($filePath){ | |
| 44 | -            if($filePath === true){ | |
| 43 | +        if ($filePath) { | |
| 44 | +            if ($filePath === true) { | |
| 45 | 45 | $filePath = saveFilePath; | 
| 46 | -            }else{ | |
| 47 | -                if(substr($filePath,-1) != DIRECTORY_SEPARATOR){ | |
| 46 | +            } else { | |
| 47 | +                if (substr($filePath, -1) != DIRECTORY_SEPARATOR) { | |
| 48 | 48 | $filePath .= DIRECTORY_SEPARATOR; | 
| 49 | 49 | } | 
| 50 | 50 | } | 
| @@ -53,15 +53,15 @@ discard block | ||
| 53 | 53 | mkdir($filePath, 0777, true); | 
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | -            if(is_int($data)){ | |
| 56 | +            if (is_int($data)) { | |
| 57 | 57 | $file_name = 'qr'.$data.'.png'; | 
| 58 | -            }else{ | |
| 59 | -                $file_name = 'qr'.date('YmdHis').rand(1111,9999).'.png'; | |
| 58 | +            } else { | |
| 59 | +                $file_name = 'qr'.date('YmdHis').rand(1111, 9999).'.png'; | |
| 60 | 60 | } | 
| 61 | 61 | $filename = $filePath.$file_name; | 
| 62 | 62 | QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2); | 
| 63 | 63 | return $filename; | 
| 64 | -        }else{ | |
| 64 | +        } else { | |
| 65 | 65 | QRcode::png($data, false, $errorCorrectionLevel, $matrixPointSize, 2); | 
| 66 | 66 | } | 
| 67 | 67 | } | 
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 |          if($filePath){ | 
| 44 | 44 |              if($filePath === true){ | 
| 45 | 45 | $filePath = saveFilePath; | 
| 46 | -            }else{ | |
| 46 | +            } else{ | |
| 47 | 47 |                  if(substr($filePath,-1) != DIRECTORY_SEPARATOR){ | 
| 48 | 48 | $filePath .= DIRECTORY_SEPARATOR; | 
| 49 | 49 | } | 
| @@ -55,13 +55,13 @@ discard block | ||
| 55 | 55 | |
| 56 | 56 |              if(is_int($data)){ | 
| 57 | 57 | $file_name = 'qr'.$data.'.png'; | 
| 58 | -            }else{ | |
| 58 | +            } else{ | |
| 59 | 59 |                  $file_name = 'qr'.date('YmdHis').rand(1111,9999).'.png'; | 
| 60 | 60 | } | 
| 61 | 61 | $filename = $filePath.$file_name; | 
| 62 | 62 | QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2); | 
| 63 | 63 | return $filename; | 
| 64 | -        }else{ | |
| 64 | +        } else{ | |
| 65 | 65 | QRcode::png($data, false, $errorCorrectionLevel, $matrixPointSize, 2); | 
| 66 | 66 | } | 
| 67 | 67 | } | 
| @@ -19,13 +19,13 @@ discard block | ||
| 19 | 19 | const IMG_FORMAT_GIF = 3; | 
| 20 | 20 | const IMG_FORMAT_WBMP = 4; | 
| 21 | 21 | |
| 22 | - private $w, $h; // int | |
| 23 | - private $color; // BCGColor | |
| 24 | - private $filename; // char * | |
| 25 | -    private $im;            // {object} | |
| 26 | - private $barcode; // BCGBarcode | |
| 27 | - private $dpi; // float | |
| 28 | - private $rotateDegree; // float | |
| 22 | + private $w, $h; // int | |
| 23 | + private $color; // BCGColor | |
| 24 | + private $filename; // char * | |
| 25 | +    private $im; // {object} | |
| 26 | + private $barcode; // BCGBarcode | |
| 27 | + private $dpi; // float | |
| 28 | + private $rotateDegree; // float | |
| 29 | 29 | |
| 30 | 30 | /** | 
| 31 | 31 | * Constructor. | 
| @@ -135,7 +135,7 @@ discard block | ||
| 135 | 135 | * @param float $degree | 
| 136 | 136 | */ | 
| 137 | 137 |      public function setRotationAngle($degree) { | 
| 138 | - $this->rotateDegree = (float)$degree; | |
| 138 | + $this->rotateDegree = (float) $degree; | |
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | 141 | /** | 
| @@ -206,7 +206,7 @@ discard block | ||
| 206 | 206 | $w = imagesx($this->im); | 
| 207 | 207 | $h = imagesy($this->im); | 
| 208 | 208 | |
| 209 | - $text = 'Error: ' . $exception->getMessage(); | |
| 209 | + $text = 'Error: '.$exception->getMessage(); | |
| 210 | 210 | |
| 211 | 211 | $width = imagefontwidth(2) * strlen($text); | 
| 212 | 212 | $height = imagefontheight(2); | 
| @@ -290,7 +290,7 @@ discard block | ||
| 290 | 290 | |
| 291 | 291 |              if ($this->alignment === self::ALIGN_CENTER) { | 
| 292 | 292 | $x = ($x2 - $x1) / 2 + $x1 - $fontDimension[0] / 2 + $this->offset; | 
| 293 | -            } elseif ($this->alignment === self::ALIGN_LEFT)  { | |
| 293 | +            } elseif ($this->alignment === self::ALIGN_LEFT) { | |
| 294 | 294 | $x = $x1 + $this->offset; | 
| 295 | 295 |              } else { | 
| 296 | 296 | $x = $x2 + $this->offset - $fontDimension[0]; | 
| @@ -304,7 +304,7 @@ discard block | ||
| 304 | 304 | |
| 305 | 305 |              if ($this->alignment === self::ALIGN_CENTER) { | 
| 306 | 306 | $y = ($y2 - $y1) / 2 + $y1 - $fontDimension[1] / 2 + $this->offset; | 
| 307 | -            } elseif ($this->alignment === self::ALIGN_TOP)  { | |
| 307 | +            } elseif ($this->alignment === self::ALIGN_TOP) { | |
| 308 | 308 | $y = $y1 + $this->offset; | 
| 309 | 309 |              } else { | 
| 310 | 310 | $y = $y2 + $this->offset - $fontDimension[1]; | 
| @@ -15,15 +15,15 @@ discard block | ||
| 15 | 15 | |
| 16 | 16 | const AUTO_LABEL = '##!!AUTO_LABEL!!##'; | 
| 17 | 17 | |
| 18 | - protected $thickness; // int | |
| 19 | - protected $keys, $code; // string[] | |
| 20 | - protected $positionX; // int | |
| 21 | - protected $font; // BCGFont | |
| 22 | - protected $text; // string | |
| 23 | - protected $checksumValue; // int or int[] | |
| 18 | + protected $thickness; // int | |
| 19 | + protected $keys, $code; // string[] | |
| 20 | + protected $positionX; // int | |
| 21 | + protected $font; // BCGFont | |
| 22 | + protected $text; // string | |
| 23 | + protected $checksumValue; // int or int[] | |
| 24 | 24 | protected $displayChecksum; // bool | 
| 25 | - protected $label; // string | |
| 26 | - protected $defaultLabel; // BCGLabel | |
| 25 | + protected $label; // string | |
| 26 | + protected $defaultLabel; // BCGLabel | |
| 27 | 27 | |
| 28 | 28 | /** | 
| 29 | 29 | * Constructor. | 
| @@ -152,7 +152,7 @@ discard block | ||
| 152 | 152 | * @param boolean $displayChecksum | 
| 153 | 153 | */ | 
| 154 | 154 |      public function setDisplayChecksum($displayChecksum) { | 
| 155 | - $this->displayChecksum = (bool)$displayChecksum; | |
| 155 | + $this->displayChecksum = (bool) $displayChecksum; | |
| 156 | 156 | } | 
| 157 | 157 | |
| 158 | 158 | /** | 
| @@ -98,30 +98,30 @@ discard block | ||
| 98 | 98 | |
| 99 | 99 |      private function internalSetDPI(&$bin, &$chunks) { | 
| 100 | 100 |          if ($this->dpi !== null) { | 
| 101 | - $meters = (int)($this->dpi * 39.37007874); | |
| 101 | + $meters = (int) ($this->dpi * 39.37007874); | |
| 102 | 102 | |
| 103 | 103 | $found = -1; | 
| 104 | 104 | $c = count($chunks); | 
| 105 | -            for($i = 0; $i < $c; $i++) { | |
| 105 | +            for ($i = 0; $i < $c; $i++) { | |
| 106 | 106 | // We already have a pHYs | 
| 107 | -                if($chunks[$i]['chunk'] === 'pHYs') { | |
| 107 | +                if ($chunks[$i]['chunk'] === 'pHYs') { | |
| 108 | 108 | $found = $i; | 
| 109 | 109 | break; | 
| 110 | 110 | } | 
| 111 | 111 | } | 
| 112 | 112 | |
| 113 | -            $data = 'pHYs' . pack('NNC', $meters, $meters, 0x01); | |
| 113 | +            $data = 'pHYs'.pack('NNC', $meters, $meters, 0x01); | |
| 114 | 114 | $crc = self::crc($data, 13); | 
| 115 | 115 |              $cr = pack('Na13N', 9, $data, $crc); | 
| 116 | 116 | |
| 117 | 117 | // We didn't have a pHYs | 
| 118 | -            if($found == -1) { | |
| 118 | +            if ($found == -1) { | |
| 119 | 119 | // Don't do anything if we have a bad PNG | 
| 120 | -                if($c >= 2 && $chunks[0]['chunk'] === 'IHDR') { | |
| 120 | +                if ($c >= 2 && $chunks[0]['chunk'] === 'IHDR') { | |
| 121 | 121 |                      array_splice($chunks, 1, 0, array(array('offset' => 33, 'size' => 9, 'chunk' => 'pHYs'))); | 
| 122 | 122 | |
| 123 | 123 | // Push the data | 
| 124 | -                    for($i = 2; $i < $c; $i++) { | |
| 124 | +                    for ($i = 2; $i < $c; $i++) { | |
| 125 | 125 | $chunks[$i]['offset'] += 21; | 
| 126 | 126 | } | 
| 127 | 127 | |
| @@ -178,7 +178,7 @@ discard block | ||
| 178 | 178 | return ($x >> $n) | $mask; | 
| 179 | 179 | } | 
| 180 | 180 | |
| 181 | - return (int)$x >> (int)$n; | |
| 181 | + return (int) $x >> (int) $n; | |
| 182 | 182 | } | 
| 183 | 183 | |
| 184 | 184 |      private static function update_crc($crc, $buf, $len) { | 
| @@ -42,7 +42,7 @@ discard block | ||
| 42 | 42 | * @param int $dpi | 
| 43 | 43 | */ | 
| 44 | 44 |      public function setDPI($dpi) { | 
| 45 | -        if(is_int($dpi)) { | |
| 45 | +        if (is_int($dpi)) { | |
| 46 | 46 | $this->dpi = max(1, $dpi); | 
| 47 | 47 |          } else { | 
| 48 | 48 | $this->dpi = null; | 
| @@ -88,7 +88,7 @@ discard block | ||
| 88 | 88 | } | 
| 89 | 89 | |
| 90 | 90 |      private function internalSetC(&$bin) { | 
| 91 | -        if(strcmp(substr($bin, 0, 4), pack('H*', 'FFD8FFE0')) === 0) { | |
| 91 | +        if (strcmp(substr($bin, 0, 4), pack('H*', 'FFD8FFE0')) === 0) { | |
| 92 | 92 | $offset = 4 + (ord($bin[4]) << 8 | ord($bin[5])); | 
| 93 | 93 | $firstPart = substr($bin, 0, $offset); | 
| 94 | 94 | $secondPart = substr($bin, $offset); | 
| @@ -18,9 +18,9 @@ discard block | ||
| 18 | 18 | * http://www.barcodephp.com | 
| 19 | 19 | */ | 
| 20 | 20 | |
| 21 | -define('CODE128_A',    1);            // Table A | |
| 22 | -define('CODE128_B',    2);            // Table B | |
| 23 | -define('CODE128_C',    3);            // Table C | |
| 21 | +define('CODE128_A', 1); // Table A | |
| 22 | +define('CODE128_B', 2); // Table B | |
| 23 | +define('CODE128_C', 3); // Table C | |
| 24 | 24 |  class BCGcode128 extends BCGBarcode1D { | 
| 25 | 25 | const KEYA_FNC3 = 96; | 
| 26 | 26 | const KEYA_FNC2 = 97; | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 | private $latch; | 
| 58 | 58 | private $fnc; | 
| 59 | 59 | |
| 60 | - private $METHOD = null; // Array of method available to create Code128 (CODE128_A, CODE128_B, CODE128_C) | |
| 60 | + private $METHOD = null; // Array of method available to create Code128 (CODE128_A, CODE128_B, CODE128_C) | |
| 61 | 61 | |
| 62 | 62 | /** | 
| 63 | 63 | * Constructor. | 
| @@ -74,118 +74,118 @@ discard block | ||
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | 76 | /* CODE 128 B */ | 
| 77 | -        $this->keysB = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' . chr(127); | |
| 77 | +        $this->keysB = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'.chr(127); | |
| 78 | 78 | |
| 79 | 79 | /* CODE 128 C */ | 
| 80 | 80 | $this->keysC = '0123456789'; | 
| 81 | 81 | |
| 82 | 82 | $this->code = array( | 
| 83 | - '101111', /* 00 */ | |
| 84 | - '111011', /* 01 */ | |
| 85 | - '111110', /* 02 */ | |
| 86 | - '010112', /* 03 */ | |
| 87 | - '010211', /* 04 */ | |
| 88 | - '020111', /* 05 */ | |
| 89 | - '011102', /* 06 */ | |
| 90 | - '011201', /* 07 */ | |
| 91 | - '021101', /* 08 */ | |
| 92 | - '110102', /* 09 */ | |
| 93 | - '110201', /* 10 */ | |
| 94 | - '120101', /* 11 */ | |
| 95 | - '001121', /* 12 */ | |
| 96 | - '011021', /* 13 */ | |
| 97 | - '011120', /* 14 */ | |
| 98 | - '002111', /* 15 */ | |
| 99 | - '012011', /* 16 */ | |
| 100 | - '012110', /* 17 */ | |
| 101 | - '112100', /* 18 */ | |
| 102 | - '110021', /* 19 */ | |
| 103 | - '110120', /* 20 */ | |
| 104 | - '102101', /* 21 */ | |
| 105 | - '112001', /* 22 */ | |
| 106 | - '201020', /* 23 */ | |
| 107 | - '200111', /* 24 */ | |
| 108 | - '210011', /* 25 */ | |
| 109 | - '210110', /* 26 */ | |
| 110 | - '201101', /* 27 */ | |
| 111 | - '211001', /* 28 */ | |
| 112 | - '211100', /* 29 */ | |
| 113 | - '101012', /* 30 */ | |
| 114 | - '101210', /* 31 */ | |
| 115 | - '121010', /* 32 */ | |
| 116 | - '000212', /* 33 */ | |
| 117 | - '020012', /* 34 */ | |
| 118 | - '020210', /* 35 */ | |
| 119 | - '001202', /* 36 */ | |
| 120 | - '021002', /* 37 */ | |
| 121 | - '021200', /* 38 */ | |
| 122 | - '100202', /* 39 */ | |
| 123 | - '120002', /* 40 */ | |
| 124 | - '120200', /* 41 */ | |
| 125 | - '001022', /* 42 */ | |
| 126 | - '001220', /* 43 */ | |
| 127 | - '021020', /* 44 */ | |
| 128 | - '002012', /* 45 */ | |
| 129 | - '002210', /* 46 */ | |
| 130 | - '022010', /* 47 */ | |
| 131 | - '202010', /* 48 */ | |
| 132 | - '100220', /* 49 */ | |
| 133 | - '120020', /* 50 */ | |
| 134 | - '102002', /* 51 */ | |
| 135 | - '102200', /* 52 */ | |
| 136 | - '102020', /* 53 */ | |
| 137 | - '200012', /* 54 */ | |
| 138 | - '200210', /* 55 */ | |
| 139 | - '220010', /* 56 */ | |
| 140 | - '201002', /* 57 */ | |
| 141 | - '201200', /* 58 */ | |
| 142 | - '221000', /* 59 */ | |
| 143 | - '203000', /* 60 */ | |
| 144 | - '110300', /* 61 */ | |
| 145 | - '320000', /* 62 */ | |
| 146 | - '000113', /* 63 */ | |
| 147 | - '000311', /* 64 */ | |
| 148 | - '010013', /* 65 */ | |
| 149 | - '010310', /* 66 */ | |
| 150 | - '030011', /* 67 */ | |
| 151 | - '030110', /* 68 */ | |
| 152 | - '001103', /* 69 */ | |
| 153 | - '001301', /* 70 */ | |
| 154 | - '011003', /* 71 */ | |
| 155 | - '011300', /* 72 */ | |
| 156 | - '031001', /* 73 */ | |
| 157 | - '031100', /* 74 */ | |
| 158 | - '130100', /* 75 */ | |
| 159 | - '110003', /* 76 */ | |
| 160 | - '302000', /* 77 */ | |
| 161 | - '130001', /* 78 */ | |
| 162 | - '023000', /* 79 */ | |
| 163 | - '000131', /* 80 */ | |
| 164 | - '010031', /* 81 */ | |
| 165 | - '010130', /* 82 */ | |
| 166 | - '003101', /* 83 */ | |
| 167 | - '013001', /* 84 */ | |
| 168 | - '013100', /* 85 */ | |
| 169 | - '300101', /* 86 */ | |
| 170 | - '310001', /* 87 */ | |
| 171 | - '310100', /* 88 */ | |
| 172 | - '101030', /* 89 */ | |
| 173 | - '103010', /* 90 */ | |
| 174 | - '301010', /* 91 */ | |
| 175 | - '000032', /* 92 */ | |
| 176 | - '000230', /* 93 */ | |
| 177 | - '020030', /* 94 */ | |
| 178 | - '003002', /* 95 */ | |
| 179 | - '003200', /* 96 */ | |
| 180 | - '300002', /* 97 */ | |
| 181 | - '300200', /* 98 */ | |
| 182 | - '002030', /* 99 */ | |
| 183 | - '003020', /* 100*/ | |
| 184 | - '200030', /* 101*/ | |
| 185 | - '300020', /* 102*/ | |
| 186 | - '100301', /* 103*/ | |
| 187 | - '100103', /* 104*/ | |
| 188 | - '100121', /* 105*/ | |
| 83 | + '101111', /* 00 */ | |
| 84 | + '111011', /* 01 */ | |
| 85 | + '111110', /* 02 */ | |
| 86 | + '010112', /* 03 */ | |
| 87 | + '010211', /* 04 */ | |
| 88 | + '020111', /* 05 */ | |
| 89 | + '011102', /* 06 */ | |
| 90 | + '011201', /* 07 */ | |
| 91 | + '021101', /* 08 */ | |
| 92 | + '110102', /* 09 */ | |
| 93 | + '110201', /* 10 */ | |
| 94 | + '120101', /* 11 */ | |
| 95 | + '001121', /* 12 */ | |
| 96 | + '011021', /* 13 */ | |
| 97 | + '011120', /* 14 */ | |
| 98 | + '002111', /* 15 */ | |
| 99 | + '012011', /* 16 */ | |
| 100 | + '012110', /* 17 */ | |
| 101 | + '112100', /* 18 */ | |
| 102 | + '110021', /* 19 */ | |
| 103 | + '110120', /* 20 */ | |
| 104 | + '102101', /* 21 */ | |
| 105 | + '112001', /* 22 */ | |
| 106 | + '201020', /* 23 */ | |
| 107 | + '200111', /* 24 */ | |
| 108 | + '210011', /* 25 */ | |
| 109 | + '210110', /* 26 */ | |
| 110 | + '201101', /* 27 */ | |
| 111 | + '211001', /* 28 */ | |
| 112 | + '211100', /* 29 */ | |
| 113 | + '101012', /* 30 */ | |
| 114 | + '101210', /* 31 */ | |
| 115 | + '121010', /* 32 */ | |
| 116 | + '000212', /* 33 */ | |
| 117 | + '020012', /* 34 */ | |
| 118 | + '020210', /* 35 */ | |
| 119 | + '001202', /* 36 */ | |
| 120 | + '021002', /* 37 */ | |
| 121 | + '021200', /* 38 */ | |
| 122 | + '100202', /* 39 */ | |
| 123 | + '120002', /* 40 */ | |
| 124 | + '120200', /* 41 */ | |
| 125 | + '001022', /* 42 */ | |
| 126 | + '001220', /* 43 */ | |
| 127 | + '021020', /* 44 */ | |
| 128 | + '002012', /* 45 */ | |
| 129 | + '002210', /* 46 */ | |
| 130 | + '022010', /* 47 */ | |
| 131 | + '202010', /* 48 */ | |
| 132 | + '100220', /* 49 */ | |
| 133 | + '120020', /* 50 */ | |
| 134 | + '102002', /* 51 */ | |
| 135 | + '102200', /* 52 */ | |
| 136 | + '102020', /* 53 */ | |
| 137 | + '200012', /* 54 */ | |
| 138 | + '200210', /* 55 */ | |
| 139 | + '220010', /* 56 */ | |
| 140 | + '201002', /* 57 */ | |
| 141 | + '201200', /* 58 */ | |
| 142 | + '221000', /* 59 */ | |
| 143 | + '203000', /* 60 */ | |
| 144 | + '110300', /* 61 */ | |
| 145 | + '320000', /* 62 */ | |
| 146 | + '000113', /* 63 */ | |
| 147 | + '000311', /* 64 */ | |
| 148 | + '010013', /* 65 */ | |
| 149 | + '010310', /* 66 */ | |
| 150 | + '030011', /* 67 */ | |
| 151 | + '030110', /* 68 */ | |
| 152 | + '001103', /* 69 */ | |
| 153 | + '001301', /* 70 */ | |
| 154 | + '011003', /* 71 */ | |
| 155 | + '011300', /* 72 */ | |
| 156 | + '031001', /* 73 */ | |
| 157 | + '031100', /* 74 */ | |
| 158 | + '130100', /* 75 */ | |
| 159 | + '110003', /* 76 */ | |
| 160 | + '302000', /* 77 */ | |
| 161 | + '130001', /* 78 */ | |
| 162 | + '023000', /* 79 */ | |
| 163 | + '000131', /* 80 */ | |
| 164 | + '010031', /* 81 */ | |
| 165 | + '010130', /* 82 */ | |
| 166 | + '003101', /* 83 */ | |
| 167 | + '013001', /* 84 */ | |
| 168 | + '013100', /* 85 */ | |
| 169 | + '300101', /* 86 */ | |
| 170 | + '310001', /* 87 */ | |
| 171 | + '310100', /* 88 */ | |
| 172 | + '101030', /* 89 */ | |
| 173 | + '103010', /* 90 */ | |
| 174 | + '301010', /* 91 */ | |
| 175 | + '000032', /* 92 */ | |
| 176 | + '000230', /* 93 */ | |
| 177 | + '020030', /* 94 */ | |
| 178 | + '003002', /* 95 */ | |
| 179 | + '003200', /* 96 */ | |
| 180 | + '300002', /* 97 */ | |
| 181 | + '300200', /* 98 */ | |
| 182 | + '002030', /* 99 */ | |
| 183 | + '003020', /* 100*/ | |
| 184 | + '200030', /* 101*/ | |
| 185 | + '300020', /* 102*/ | |
| 186 | + '100301', /* 103*/ | |
| 187 | + '100103', /* 104*/ | |
| 188 | + '100121', /* 105*/ | |
| 189 | 189 | '122000' /*STOP*/ | 
| 190 | 190 | ); | 
| 191 | 191 | $this->setStart($start); | 
| @@ -193,22 +193,22 @@ discard block | ||
| 193 | 193 | |
| 194 | 194 | // Latches and Shifts | 
| 195 | 195 | $this->latch = array( | 
| 196 | - array(null, self::KEYA_CODEB, self::KEYA_CODEC), | |
| 197 | - array(self::KEYB_CODEA, null, self::KEYB_CODEC), | |
| 198 | - array(self::KEYC_CODEA, self::KEYC_CODEB, null) | |
| 196 | + array(null, self::KEYA_CODEB, self::KEYA_CODEC), | |
| 197 | + array(self::KEYB_CODEA, null, self::KEYB_CODEC), | |
| 198 | + array(self::KEYC_CODEA, self::KEYC_CODEB, null) | |
| 199 | 199 | ); | 
| 200 | 200 | $this->shift = array( | 
| 201 | - array(null, self::KEYA_SHIFT), | |
| 201 | + array(null, self::KEYA_SHIFT), | |
| 202 | 202 | array(self::KEYB_SHIFT, null) | 
| 203 | 203 | ); | 
| 204 | 204 | $this->fnc = array( | 
| 205 | - array(self::KEYA_FNC1, self::KEYA_FNC2, self::KEYA_FNC3, self::KEYA_FNC4), | |
| 206 | - array(self::KEYB_FNC1, self::KEYB_FNC2, self::KEYB_FNC3, self::KEYB_FNC4), | |
| 207 | - array(self::KEYC_FNC1, null, null, null) | |
| 205 | + array(self::KEYA_FNC1, self::KEYA_FNC2, self::KEYA_FNC3, self::KEYA_FNC4), | |
| 206 | + array(self::KEYB_FNC1, self::KEYB_FNC2, self::KEYB_FNC3, self::KEYB_FNC4), | |
| 207 | + array(self::KEYC_FNC1, null, null, null) | |
| 208 | 208 | ); | 
| 209 | 209 | |
| 210 | 210 | // Method available | 
| 211 | - $this->METHOD = array(CODE128_A => 'A', CODE128_B => 'B', CODE128_C => 'C'); | |
| 211 | + $this->METHOD = array(CODE128_A => 'A', CODE128_B => 'B', CODE128_C => 'C'); | |
| 212 | 212 | } | 
| 213 | 213 | |
| 214 | 214 | /** | 
| @@ -248,7 +248,7 @@ discard block | ||
| 248 | 248 | * @param boolean $accept | 
| 249 | 249 | */ | 
| 250 | 250 |      public function setTilde($accept) { | 
| 251 | - $this->tilde = (bool)$accept; | |
| 251 | + $this->tilde = (bool) $accept; | |
| 252 | 252 | } | 
| 253 | 253 | |
| 254 | 254 | /** | 
| @@ -280,14 +280,14 @@ discard block | ||
| 280 | 280 | // it's the case of "array(ENCODING, 'text')" | 
| 281 | 281 | // We got ENCODING in $val1, calling 'each' again will get 'text' in $val2 | 
| 282 | 282 | list($key2, $val2) = each($text); | 
| 283 | -                        $seq .= $this->{'setParse' . $this->METHOD[$val1]}($val2, $currentMode); | |
| 283 | +                        $seq .= $this->{'setParse'.$this->METHOD[$val1]}($val2, $currentMode); | |
| 284 | 284 | $this->text .= $val2; | 
| 285 | 285 | } | 
| 286 | 286 |                  } else {                        // The method is specified | 
| 287 | 287 | // $val1[0] = ENCODING | 
| 288 | 288 | // $val1[1] = 'text' | 
| 289 | - $value = isset($val1[1]) ? $val1[1] : ''; // If data available | |
| 290 | -                    $seq .= $this->{'setParse' . $this->METHOD[$val1[0]]}($value, $currentMode); | |
| 289 | + $value = isset($val1[1]) ? $val1[1] : ''; // If data available | |
| 290 | +                    $seq .= $this->{'setParse'.$this->METHOD[$val1[0]]}($value, $currentMode); | |
| 291 | 291 | $this->text .= $value; | 
| 292 | 292 | } | 
| 293 | 293 | } | 
| @@ -374,10 +374,10 @@ discard block | ||
| 374 | 374 | |
| 375 | 375 |          if ($this->checksumValue !== false) { | 
| 376 | 376 |              if ($this->lastTable === 'C') { | 
| 377 | - return (string)$this->checksumValue; | |
| 377 | + return (string) $this->checksumValue; | |
| 378 | 378 | } | 
| 379 | 379 | |
| 380 | -            return $this->{'keys' . $this->lastTable}[$this->checksumValue]; | |
| 380 | +            return $this->{'keys'.$this->lastTable}[$this->checksumValue]; | |
| 381 | 381 | } | 
| 382 | 382 | |
| 383 | 383 | return false; | 
| @@ -412,7 +412,7 @@ discard block | ||
| 412 | 412 | // If we can get at least 4 numbers, go in C; otherwise go in B. | 
| 413 | 413 | $tmp = preg_quote($this->keysC, '/'); | 
| 414 | 414 | $length = strlen($text); | 
| 415 | -            if ($length >= 4 && preg_match('/[' . $tmp . ']/', substr($text, 0, 4))) { | |
| 415 | +            if ($length >= 4 && preg_match('/['.$tmp.']/', substr($text, 0, 4))) { | |
| 416 | 416 | $this->starting_text = 'C'; | 
| 417 | 417 |              } else { | 
| 418 | 418 |                  if ($length > 0 && strpos($this->keysB, $text[0]) !== false) { | 
| @@ -443,7 +443,7 @@ discard block | ||
| 443 | 443 |                      if (isset($text[$pos + 2])) { | 
| 444 | 444 | $v = intval($text[$pos + 2]); | 
| 445 | 445 |                          if ($v >= 1 && $v <= 4) { | 
| 446 | - return '~F' . $v; | |
| 446 | + return '~F'.$v; | |
| 447 | 447 |                          } else { | 
| 448 | 448 |                              throw new BCGParseException('code128', 'Bad ~F. You must provide a number from 1 to 4.'); | 
| 449 | 449 | } | 
| @@ -478,19 +478,19 @@ discard block | ||
| 478 | 478 | |
| 479 | 479 | $simpleTilde = ($tildeData === '~~'); | 
| 480 | 480 |                  if ($simpleTilde && $currentMode !== 'B') { | 
| 481 | -                    throw new BCGParseException('code128', 'The Table ' . $currentMode . ' doesn\'t contain the character ~.'); | |
| 481 | +                    throw new BCGParseException('code128', 'The Table '.$currentMode.' doesn\'t contain the character ~.'); | |
| 482 | 482 | } | 
| 483 | 483 | |
| 484 | 484 | // At this point, we know we have ~Fx | 
| 485 | 485 |                  if ($tildeData !== '~F1' && $currentMode === 'C') { | 
| 486 | 486 | // The mode C doesn't support ~F2, ~F3, ~F4 | 
| 487 | -                    throw new BCGParseException('code128', 'The Table C doesn\'t contain the function ' . $tildeData . '.'); | |
| 487 | +                    throw new BCGParseException('code128', 'The Table C doesn\'t contain the function '.$tildeData.'.'); | |
| 488 | 488 | } | 
| 489 | 489 | |
| 490 | 490 | $length = $pos - $previousPos; | 
| 491 | 491 |                  if ($currentMode === 'C') { | 
| 492 | 492 |                      if ($length % 2 === 1) { | 
| 493 | -                        throw new BCGParseException('code128', 'The text "' . $text . '" must have an even number of character to be encoded in Table C.'); | |
| 493 | +                        throw new BCGParseException('code128', 'The text "'.$text.'" must have an even number of character to be encoded in Table C.'); | |
| 494 | 494 | } | 
| 495 | 495 | } | 
| 496 | 496 | |
| @@ -504,7 +504,7 @@ discard block | ||
| 504 | 504 | $length = strlen($text) - $previousPos; | 
| 505 | 505 |              if ($currentMode === 'C') { | 
| 506 | 506 |                  if ($length % 2 === 1) { | 
| 507 | -                    throw new BCGParseException('code128', 'The text "' . $text . '" must have an even number of character to be encoded in Table C.'); | |
| 507 | +                    throw new BCGParseException('code128', 'The text "'.$text.'" must have an even number of character to be encoded in Table C.'); | |
| 508 | 508 | } | 
| 509 | 509 | } | 
| 510 | 510 | |
| @@ -532,14 +532,14 @@ discard block | ||
| 532 | 532 | } | 
| 533 | 533 | |
| 534 | 534 | $match = array(); | 
| 535 | -        if (preg_match('/[^' . $tmp . ']/', $text, $match) === 1) { | |
| 535 | +        if (preg_match('/[^'.$tmp.']/', $text, $match) === 1) { | |
| 536 | 536 | // We found something not allowed | 
| 537 | -            throw new BCGParseException('code128', 'The text "' . $text . '" can\'t be parsed with the Table A. The character "' . $match[0] . '" is not allowed.'); | |
| 537 | +            throw new BCGParseException('code128', 'The text "'.$text.'" can\'t be parsed with the Table A. The character "'.$match[0].'" is not allowed.'); | |
| 538 | 538 |          } else { | 
| 539 | 539 | $latch = ($currentMode === 'A') ? '' : '0'; | 
| 540 | 540 | $currentMode = 'A'; | 
| 541 | 541 | |
| 542 | - return $latch . $this->getSequenceParsed($text, $currentMode); | |
| 542 | + return $latch.$this->getSequenceParsed($text, $currentMode); | |
| 543 | 543 | } | 
| 544 | 544 | } | 
| 545 | 545 | |
| @@ -554,14 +554,14 @@ discard block | ||
| 554 | 554 | $tmp = preg_quote($this->keysB, '/'); | 
| 555 | 555 | |
| 556 | 556 | $match = array(); | 
| 557 | -        if (preg_match('/[^' . $tmp . ']/', $text, $match) === 1) { | |
| 557 | +        if (preg_match('/[^'.$tmp.']/', $text, $match) === 1) { | |
| 558 | 558 | // We found something not allowed | 
| 559 | -            throw new BCGParseException('code128', 'The text "' . $text . '" can\'t be parsed with the Table B. The character "' . $match[0] . '" is not allowed.'); | |
| 559 | +            throw new BCGParseException('code128', 'The text "'.$text.'" can\'t be parsed with the Table B. The character "'.$match[0].'" is not allowed.'); | |
| 560 | 560 |          } else { | 
| 561 | 561 | $latch = ($currentMode === 'B') ? '' : '1'; | 
| 562 | 562 | $currentMode = 'B'; | 
| 563 | 563 | |
| 564 | - return $latch . $this->getSequenceParsed($text, $currentMode); | |
| 564 | + return $latch.$this->getSequenceParsed($text, $currentMode); | |
| 565 | 565 | } | 
| 566 | 566 | } | 
| 567 | 567 | |
| @@ -581,14 +581,14 @@ discard block | ||
| 581 | 581 | } | 
| 582 | 582 | |
| 583 | 583 | $match = array(); | 
| 584 | -        if (preg_match('/[^' . $tmp . ']/', $text, $match) === 1) { | |
| 584 | +        if (preg_match('/[^'.$tmp.']/', $text, $match) === 1) { | |
| 585 | 585 | // We found something not allowed | 
| 586 | -            throw new BCGParseException('code128', 'The text "' . $text . '" can\'t be parsed with the Table C. The character "' . $match[0] . '" is not allowed.'); | |
| 586 | +            throw new BCGParseException('code128', 'The text "'.$text.'" can\'t be parsed with the Table C. The character "'.$match[0].'" is not allowed.'); | |
| 587 | 587 |          } else { | 
| 588 | 588 | $latch = ($currentMode === 'C') ? '' : '2'; | 
| 589 | 589 | $currentMode = 'C'; | 
| 590 | 590 | |
| 591 | - return $latch . $this->getSequenceParsed($text, $currentMode); | |
| 591 | + return $latch.$this->getSequenceParsed($text, $currentMode); | |
| 592 | 592 | } | 
| 593 | 593 | } | 
| 594 | 594 | |
| @@ -636,7 +636,7 @@ discard block | ||
| 636 | 636 |                  for ($j = 0; $j < 3; $j++) { | 
| 637 | 637 |                      if (($curLen[$i] + $latLen[$i][$j]) < $curLen[$j]) { | 
| 638 | 638 | $curLen[$j] = $curLen[$i] + $latLen[$i][$j]; | 
| 639 | - $curSeq[$j] = $curSeq[$i] . $j; | |
| 639 | + $curSeq[$j] = $curSeq[$i].$j; | |
| 640 | 640 | } | 
| 641 | 641 | } | 
| 642 | 642 | } | 
| @@ -691,21 +691,21 @@ discard block | ||
| 691 | 691 |              for ($i = 0; $i < $c; $i++) { | 
| 692 | 692 |                  if (($curLen[$posArray[$i]] + $charSiz[$posArray[$i]]) < $nxtLen[$posArray[$i]]) { | 
| 693 | 693 | $nxtLen[$posArray[$i]] = $curLen[$posArray[$i]] + $charSiz[$posArray[$i]]; | 
| 694 | - $nxtSeq[$posArray[$i]] = $curSeq[$posArray[$i]] . '.'; | |
| 694 | + $nxtSeq[$posArray[$i]] = $curSeq[$posArray[$i]].'.'; | |
| 695 | 695 | } | 
| 696 | 696 | |
| 697 | 697 |                  for ($j = 0; $j < 2; $j++) { | 
| 698 | 698 |                      if ($j === $posArray[$i]) { continue; } | 
| 699 | 699 |                      if (($curLen[$j] + $shftLen[$j][$posArray[$i]] + $charSiz[$posArray[$i]]) < $nxtLen[$j]) { | 
| 700 | 700 | $nxtLen[$j] = $curLen[$j] + $shftLen[$j][$posArray[$i]] + $charSiz[$posArray[$i]]; | 
| 701 | - $nxtSeq[$j] = $curSeq[$j] . chr($posArray[$i] + 65) . '.'; | |
| 701 | + $nxtSeq[$j] = $curSeq[$j].chr($posArray[$i] + 65).'.'; | |
| 702 | 702 | } | 
| 703 | 703 | } | 
| 704 | 704 | } | 
| 705 | 705 | |
| 706 | 706 |              if ($c === 0) { | 
| 707 | 707 | // We found an unsuported character | 
| 708 | -                throw new BCGParseException('code128', 'Character ' .  $input . ' not supported.'); | |
| 708 | +                throw new BCGParseException('code128', 'Character '.$input.' not supported.'); | |
| 709 | 709 | } | 
| 710 | 710 | |
| 711 | 711 |              if ($flag) { | 
| @@ -848,7 +848,7 @@ discard block | ||
| 848 | 848 |          } else { | 
| 849 | 849 |              if ($encoding === 2) { | 
| 850 | 850 | // We take 2 numbers in the same time | 
| 851 | - $code = (int)substr($text, $counter, 2); | |
| 851 | + $code = (int) substr($text, $counter, 2); | |
| 852 | 852 | $indcheck[] = $code; | 
| 853 | 853 | $data[] = $this->code[$code]; | 
| 854 | 854 | $counter++; | 
| @@ -13,10 +13,10 @@ | ||
| 13 | 13 | const COLOR_BG = 0; | 
| 14 | 14 | const COLOR_FG = 1; | 
| 15 | 15 | |
| 16 | - protected $colorFg, $colorBg; // Color Foreground, Barckground | |
| 17 | - protected $scale; // Scale of the graphic, default: 1 | |
| 18 | - protected $offsetX, $offsetY; // Position where to start the drawing | |
| 19 | - protected $labels = array(); // Array of BCGLabel | |
| 16 | + protected $colorFg, $colorBg; // Color Foreground, Barckground | |
| 17 | + protected $scale; // Scale of the graphic, default: 1 | |
| 18 | + protected $offsetX, $offsetY; // Position where to start the drawing | |
| 19 | + protected $labels = array(); // Array of BCGLabel | |
| 20 | 20 | protected $pushLabel = array(0, 0); // Push for the label, left and top | 
| 21 | 21 | |
| 22 | 22 | /** | 
| @@ -62,7 +62,7 @@ | ||
| 62 | 62 | * @param int | 
| 63 | 63 | */ | 
| 64 | 64 |      public function setRotationAngle($rotationAngle) { | 
| 65 | - $this->rotationAngle = (int)$rotationAngle; | |
| 65 | + $this->rotationAngle = (int) $rotationAngle; | |
| 66 | 66 |          if ($this->rotationAngle !== 90 && $this->rotationAngle !== 180 && $this->rotationAngle !== 270) { | 
| 67 | 67 | $this->rotationAngle = 0; | 
| 68 | 68 | } |