Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixing up the code a bit to match phpcs standards

  • Loading branch information...
commit 2d305a36334f249818ecc2c41de2d270d2e7f414 1 parent 863c68a
ryanmc2033 ryanmc2033 authored

Showing 1 changed file with 60 additions and 61 deletions. Show diff stats Hide diff stats

  1. +60 61 Image/Barcode2/Driver/Upce.php
121 Image/Barcode2/Driver/Upce.php
@@ -63,8 +63,8 @@ class Image_Barcode2_Driver_Upce extends Image_Barcode2_Common implements Image_
63 63 '8' => array(1,0,1,0,0,1),
64 64 '9' => array(1,0,0,1,0,1)
65 65 );
66   -
67   - var $_codingmap = array(
  66 +
  67 + var $_codingmap = array(
68 68 '0' => array(
69 69 'O' => array(0,0,0,1,1,0,1),
70 70 'E' => array(0,1,0,0,1,1,1)
@@ -147,36 +147,36 @@ public function draw()
147 147 $text = $this->getBarcode();
148 148 $writer = $this->getWriter();
149 149 $fontsize = $this->getFontSize();
150   -
  150 +
151 151 // Calculate the barcode width
152 152 $barcodewidth = (strlen($text)) * (7 * $this->getBarcodeWidth())
153   - + $writer->imagefontwidth($fontsize)
154   - + $writer->imagefontwidth($fontsize) // check digit padding
  153 + + $writer->imagefontwidth($fontsize)
  154 + + $writer->imagefontwidth($fontsize) // check digit padding
155 155 ;
156   -
157   -
  156 +
  157 +
158 158 $barcodelongheight = (int)($writer->imagefontheight($fontsize) / 2)
159 159 + $this->getBarcodeHeight();
160   -
  160 +
161 161 // Create the image
162 162 $img = $writer->imagecreate(
163 163 $barcodewidth,
164 164 $barcodelongheight + $writer->imagefontheight($fontsize) + 1
165 165 );
166   -
  166 +
167 167 // Alocate the black and white colors
168 168 $black = $writer->imagecolorallocate($img, 0, 0, 0);
169 169 $white = $writer->imagecolorallocate($img, 255, 255, 255);
170   -
  170 +
171 171 // Fill image with white color
172 172 $writer->imagefill($img, 0, 0, $white);
173   -
  173 +
174 174 // get the first digit which is the key for creating the first 6 bars
175 175 $key = substr($text, 0, 1);
176   -
  176 +
177 177 // Initiate x position
178 178 $xpos = 0;
179   -
  179 +
180 180 // print first digit
181 181 $writer->imagestring(
182 182 $img,
@@ -187,8 +187,8 @@ public function draw()
187 187 $black
188 188 );
189 189 $xpos = $writer->imagefontwidth($fontsize) + 1;
190   -
191   -
  190 +
  191 +
192 192 // Draws the left guard pattern (bar-space-bar)
193 193 // bar
194 194 $writer->imagefilledrectangle(
@@ -199,7 +199,7 @@ public function draw()
199 199 $barcodelongheight,
200 200 $black
201 201 );
202   -
  202 +
203 203 $xpos += $this->getBarcodeWidth();
204 204 // space
205 205 $xpos += $this->getBarcodeWidth();
@@ -212,12 +212,12 @@ public function draw()
212 212 $barcodelongheight,
213 213 $black
214 214 );
215   -
  215 +
216 216 $xpos += $this->getBarcodeWidth();
217   -
218   -
  217 +
  218 +
219 219 // Draw middle $text contents
220   - $checkdigit = substr($text, 7, 1);
  220 + $checkdigit = substr($text, 7, 1);
221 221 for ($idx = 1; $idx < 7; $idx ++) {
222 222 $value = substr($text, $idx, 1);
223 223 $writer->imagestring(
@@ -228,42 +228,41 @@ public function draw()
228 228 $value,
229 229 $black
230 230 );
231   -
232   - if ($this->_paritypattern[$checkdigit][$idx-1] == 1) {
233   - foreach ($this->_codingmap[$value]['E'] as $bar) {
234   - if ($bar) {
235   - $writer->imagefilledrectangle(
236   - $img,
237   - $xpos,
238   - 0,
239   - $xpos + $this->getBarcodeWidth() - 1,
240   - $this->getBarcodeHeight(),
241   - $black
242   - );
243   - }
244   - $xpos += $this->getBarcodeWidth();
245   - }
246   - }
247   - else {
248   - foreach ($this->_codingmap[$value]['O'] as $bar) {
249   - if ($bar) {
250   - $writer->imagefilledrectangle(
251   - $img,
252   - $xpos,
253   - 0,
254   - $xpos + $this->getBarcodeWidth() - 1,
255   - $this->getBarcodeHeight(),
256   - $black
257   - );
258   - }
259   - $xpos += $this->getBarcodeWidth();
260   - }
261   - }
  231 +
  232 + if ($this->_paritypattern[$checkdigit][$idx-1] == 1) {
  233 + foreach ($this->_codingmap[$value]['E'] as $bar) {
  234 + if ($bar) {
  235 + $writer->imagefilledrectangle(
  236 + $img,
  237 + $xpos,
  238 + 0,
  239 + $xpos + $this->getBarcodeWidth() - 1,
  240 + $this->getBarcodeHeight(),
  241 + $black
  242 + );
  243 + }
  244 + $xpos += $this->getBarcodeWidth();
  245 + }
  246 + } else {
  247 + foreach ($this->_codingmap[$value]['O'] as $bar) {
  248 + if ($bar) {
  249 + $writer->imagefilledrectangle(
  250 + $img,
  251 + $xpos,
  252 + 0,
  253 + $xpos + $this->getBarcodeWidth() - 1,
  254 + $this->getBarcodeHeight(),
  255 + $black
  256 + );
  257 + }
  258 + $xpos += $this->getBarcodeWidth();
  259 + }
  260 + }
262 261 }
263   -
264   - // space
  262 +
  263 + // space
265 264 $xpos += $this->getBarcodeWidth();
266   -
  265 +
267 266 // Draws the right guard pattern (bar-space-bar-space-bar)
268 267 // bar
269 268 $writer->imagefilledrectangle(
@@ -274,7 +273,7 @@ public function draw()
274 273 $barcodelongheight,
275 274 $black
276 275 );
277   -
  276 +
278 277 $xpos += $this->getBarcodeWidth();
279 278 // space
280 279 $xpos += $this->getBarcodeWidth();
@@ -287,8 +286,8 @@ public function draw()
287 286 $barcodelongheight,
288 287 $black
289 288 );
290   -
291   - $xpos += $this->getBarcodeWidth();
  289 +
  290 + $xpos += $this->getBarcodeWidth();
292 291 // space
293 292 $xpos += $this->getBarcodeWidth();
294 293 // bar
@@ -300,10 +299,10 @@ public function draw()
300 299 $barcodelongheight,
301 300 $black
302 301 );
303   -
  302 +
304 303 $xpos += $this->getBarcodeWidth();
305   -
306   -
  304 +
  305 +
307 306 // Print Check Digit
308 307 $writer->imagestring(
309 308 $img,
@@ -313,7 +312,7 @@ public function draw()
313 312 $checkdigit,
314 313 $black
315 314 );
316   -
  315 +
317 316 return $img;
318 317 }
319 318

0 comments on commit 2d305a3

Please sign in to comment.
Something went wrong with that request. Please try again.