Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

phpcs

  • Loading branch information...
commit 13a57d67048f7883a8714dde24a91ec79a87fa13 1 parent a8bc690
Gemorroj authored
1  Image/Barcode2.php
View
@@ -19,7 +19,6 @@
* @author Marcelo Subtil Marcal <msmarcal@php.net>
* @copyright 2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id$
* @link http://pear.php.net/package/Image_Barcode2
*/
39 Image/Barcode2/Common.php
View
@@ -1,4 +1,39 @@
<?php
+/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
+
+/**
+ * Image_Barcode2_Common class
+ *
+ * Common code
+ *
+ * PHP versions 5
+ *
+ * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
+/**
+ * Image_Barcode2_Common class
+ *
+ * Common code
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
class Image_Barcode2_Common
{
protected $barcodeheight;
@@ -32,6 +67,8 @@ public function __construct(Image_Barcode2_Writer $writer)
* Set the image rendering library.
*
* @param Image_Barcode2_Writer $writer Library to use.
+ *
+ * @return void
*/
public function setWriter(Image_Barcode2_Writer $writer)
{
@@ -52,6 +89,8 @@ public function getWriter()
* Set the barcode
*
* @param string $barcode barcode
+ *
+ * @return void
*/
public function setBarcode($barcode)
{
42 Image/Barcode2/Driver.php
View
@@ -1,4 +1,39 @@
<?php
+/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
+
+/**
+ * Image_Barcode2_Driver interface
+ *
+ * Driver code
+ *
+ * PHP versions 5
+ *
+ * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
+/**
+ * Image_Barcode2_Driver interface
+ *
+ * Driver code
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
interface Image_Barcode2_Driver
{
/**
@@ -12,6 +47,8 @@ public function draw();
* Set the image rendering library.
*
* @param Image_Barcode2_Writer $writer Library to use.
+ *
+ * @return void
*/
public function setWriter(Image_Barcode2_Writer $writer);
@@ -19,12 +56,15 @@ public function setWriter(Image_Barcode2_Writer $writer);
* Set barcode
*
* @param string $barcode barcode
+ *
+ * @return void
*/
public function setBarcode($barcode);
/**
* Validate barcode
- *
+ *
+ * @return void
* @throws Image_Barcode2_Exception
*/
public function validate();
246 Image/Barcode2/Driver/Code128.php
View
@@ -38,7 +38,6 @@
* @author Jeffrey K. Brown <jkb@darkfantastic.net>
* @copyright 2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id$
* @link http://pear.php.net/package/Image_Barcode2
*/
@@ -59,7 +58,115 @@
class Image_Barcode2_Driver_Code128 extends Image_Barcode2_Common implements Image_Barcode2_Driver
{
- var $_code = array();
+ /**
+ * Coding map
+ * @var array
+ */
+ private $_codingmap = array(
+ 0 => '212222', // " "
+ 1 => '222122', // "!"
+ 2 => '222221', // "{QUOTE}"
+ 3 => '121223', // "#"
+ 4 => '121322', // "$"
+ 5 => '131222', // "%"
+ 6 => '122213', // "&"
+ 7 => '122312', // "'"
+ 8 => '132212', // "("
+ 9 => '221213', // ")"
+ 10 => '221312', // "*"
+ 11 => '231212', // "+"
+ 12 => '112232', // ","
+ 13 => '122132', // "-"
+ 14 => '122231', // "."
+ 15 => '113222', // "/"
+ 16 => '123122', // "0"
+ 17 => '123221', // "1"
+ 18 => '223211', // "2"
+ 19 => '221132', // "3"
+ 20 => '221231', // "4"
+ 21 => '213212', // "5"
+ 22 => '223112', // "6"
+ 23 => '312131', // "7"
+ 24 => '311222', // "8"
+ 25 => '321122', // "9"
+ 26 => '321221', // ":"
+ 27 => '312212', // ";"
+ 28 => '322112', // "<"
+ 29 => '322211', // "="
+ 30 => '212123', // ">"
+ 31 => '212321', // "?"
+ 32 => '232121', // "@"
+ 33 => '111323', // "A"
+ 34 => '131123', // "B"
+ 35 => '131321', // "C"
+ 36 => '112313', // "D"
+ 37 => '132113', // "E"
+ 38 => '132311', // "F"
+ 39 => '211313', // "G"
+ 40 => '231113', // "H"
+ 41 => '231311', // "I"
+ 42 => '112133', // "J"
+ 43 => '112331', // "K"
+ 44 => '132131', // "L"
+ 45 => '113123', // "M"
+ 46 => '113321', // "N"
+ 47 => '133121', // "O"
+ 48 => '313121', // "P"
+ 49 => '211331', // "Q"
+ 50 => '231131', // "R"
+ 51 => '213113', // "S"
+ 52 => '213311', // "T"
+ 53 => '213131', // "U"
+ 54 => '311123', // "V"
+ 55 => '311321', // "W"
+ 56 => '331121', // "X"
+ 57 => '312113', // "Y"
+ 58 => '312311', // "Z"
+ 59 => '332111', // "["
+ 60 => '314111', // "\"
+ 61 => '221411', // "]"
+ 62 => '431111', // "^"
+ 63 => '111224', // "_"
+ 64 => '111422', // "`"
+ 65 => '121124', // "a"
+ 66 => '121421', // "b"
+ 67 => '141122', // "c"
+ 68 => '141221', // "d"
+ 69 => '112214', // "e"
+ 70 => '112412', // "f"
+ 71 => '122114', // "g"
+ 72 => '122411', // "h"
+ 73 => '142112', // "i"
+ 74 => '142211', // "j"
+ 75 => '241211', // "k"
+ 76 => '221114', // "l"
+ 77 => '413111', // "m"
+ 78 => '241112', // "n"
+ 79 => '134111', // "o"
+ 80 => '111242', // "p"
+ 81 => '121142', // "q"
+ 82 => '121241', // "r"
+ 83 => '114212', // "s"
+ 84 => '124112', // "t"
+ 85 => '124211', // "u"
+ 86 => '411212', // "v"
+ 87 => '421112', // "w"
+ 88 => '421211', // "x"
+ 89 => '212141', // "y"
+ 90 => '214121', // "z"
+ 91 => '412121', // "{"
+ 92 => '111143', // "|"
+ 93 => '111341', // "}"
+ 94 => '131141', // "~"
+ 95 => '114113', // 95
+ 96 => '114311', // 96
+ 97 => '411113', // 97
+ 98 => '411311', // 98
+ 99 => '113141', // 99
+ 100 => '114131', // 100
+ 101 => '311141', // 101
+ 102 => '411131', // 102
+ );
/**
* Class constructor
@@ -71,116 +178,13 @@ public function __construct(Image_Barcode2_Writer $writer)
parent::__construct($writer);
$this->setBarcodeHeight(60);
$this->setBarcodeWidth(1);
-
- $this->_code[0] = "212222"; // " "
- $this->_code[1] = "222122"; // "!"
- $this->_code[2] = "222221"; // "{QUOTE}"
- $this->_code[3] = "121223"; // "#"
- $this->_code[4] = "121322"; // "$"
- $this->_code[5] = "131222"; // "%"
- $this->_code[6] = "122213"; // "&"
- $this->_code[7] = "122312"; // "'"
- $this->_code[8] = "132212"; // "("
- $this->_code[9] = "221213"; // ")"
- $this->_code[10] = "221312"; // "*"
- $this->_code[11] = "231212"; // "+"
- $this->_code[12] = "112232"; // ","
- $this->_code[13] = "122132"; // "-"
- $this->_code[14] = "122231"; // "."
- $this->_code[15] = "113222"; // "/"
- $this->_code[16] = "123122"; // "0"
- $this->_code[17] = "123221"; // "1"
- $this->_code[18] = "223211"; // "2"
- $this->_code[19] = "221132"; // "3"
- $this->_code[20] = "221231"; // "4"
- $this->_code[21] = "213212"; // "5"
- $this->_code[22] = "223112"; // "6"
- $this->_code[23] = "312131"; // "7"
- $this->_code[24] = "311222"; // "8"
- $this->_code[25] = "321122"; // "9"
- $this->_code[26] = "321221"; // ":"
- $this->_code[27] = "312212"; // ";"
- $this->_code[28] = "322112"; // "<"
- $this->_code[29] = "322211"; // "="
- $this->_code[30] = "212123"; // ">"
- $this->_code[31] = "212321"; // "?"
- $this->_code[32] = "232121"; // "@"
- $this->_code[33] = "111323"; // "A"
- $this->_code[34] = "131123"; // "B"
- $this->_code[35] = "131321"; // "C"
- $this->_code[36] = "112313"; // "D"
- $this->_code[37] = "132113"; // "E"
- $this->_code[38] = "132311"; // "F"
- $this->_code[39] = "211313"; // "G"
- $this->_code[40] = "231113"; // "H"
- $this->_code[41] = "231311"; // "I"
- $this->_code[42] = "112133"; // "J"
- $this->_code[43] = "112331"; // "K"
- $this->_code[44] = "132131"; // "L"
- $this->_code[45] = "113123"; // "M"
- $this->_code[46] = "113321"; // "N"
- $this->_code[47] = "133121"; // "O"
- $this->_code[48] = "313121"; // "P"
- $this->_code[49] = "211331"; // "Q"
- $this->_code[50] = "231131"; // "R"
- $this->_code[51] = "213113"; // "S"
- $this->_code[52] = "213311"; // "T"
- $this->_code[53] = "213131"; // "U"
- $this->_code[54] = "311123"; // "V"
- $this->_code[55] = "311321"; // "W"
- $this->_code[56] = "331121"; // "X"
- $this->_code[57] = "312113"; // "Y"
- $this->_code[58] = "312311"; // "Z"
- $this->_code[59] = "332111"; // "["
- $this->_code[60] = "314111"; // "\"
- $this->_code[61] = "221411"; // "]"
- $this->_code[62] = "431111"; // "^"
- $this->_code[63] = "111224"; // "_"
- $this->_code[64] = "111422"; // "`"
- $this->_code[65] = "121124"; // "a"
- $this->_code[66] = "121421"; // "b"
- $this->_code[67] = "141122"; // "c"
- $this->_code[68] = "141221"; // "d"
- $this->_code[69] = "112214"; // "e"
- $this->_code[70] = "112412"; // "f"
- $this->_code[71] = "122114"; // "g"
- $this->_code[72] = "122411"; // "h"
- $this->_code[73] = "142112"; // "i"
- $this->_code[74] = "142211"; // "j"
- $this->_code[75] = "241211"; // "k"
- $this->_code[76] = "221114"; // "l"
- $this->_code[77] = "413111"; // "m"
- $this->_code[78] = "241112"; // "n"
- $this->_code[79] = "134111"; // "o"
- $this->_code[80] = "111242"; // "p"
- $this->_code[81] = "121142"; // "q"
- $this->_code[82] = "121241"; // "r"
- $this->_code[83] = "114212"; // "s"
- $this->_code[84] = "124112"; // "t"
- $this->_code[85] = "124211"; // "u"
- $this->_code[86] = "411212"; // "v"
- $this->_code[87] = "421112"; // "w"
- $this->_code[88] = "421211"; // "x"
- $this->_code[89] = "212141"; // "y"
- $this->_code[90] = "214121"; // "z"
- $this->_code[91] = "412121"; // "{"
- $this->_code[92] = "111143"; // "|"
- $this->_code[93] = "111341"; // "}"
- $this->_code[94] = "131141"; // "~"
- $this->_code[95] = "114113"; // 95
- $this->_code[96] = "114311"; // 96
- $this->_code[97] = "411113"; // 97
- $this->_code[98] = "411311"; // 98
- $this->_code[99] = "113141"; // 99
- $this->_code[100] = "114131"; // 100
- $this->_code[101] = "311141"; // 101
- $this->_code[102] = "411131"; // 102
}
/**
* Validate barcode
- *
+ *
+ * @return void
* @throws Image_Barcode2_Exception
*/
public function validate()
@@ -214,6 +218,8 @@ public function draw()
$checksum = 104;
$allbars = $startcode;
$text = $this->getBarcode();
+ $writer = $this->getWriter();
+ $fontsize = $this->getFontSize();
// Next, we read the barcode string that was passed to the
@@ -265,7 +271,7 @@ public function draw()
$barcodewidth += ($nval * $this->getBarcodeWidth());
}
- $barcodelongheight = (int)($this->getWriter()->imagefontheight($this->getFontSize()) / 2)
+ $barcodelongheight = (int)($writer->imagefontheight($fontsize) / 2)
+ $this->getBarcodeHeight();
@@ -273,13 +279,13 @@ public function draw()
// the image with a nice, white background, ready for printing
// our black bars and the text.
- $img = $this->getWriter()->imagecreate(
+ $img = $writer->imagecreate(
$barcodewidth,
- $barcodelongheight + $this->getWriter()->imagefontheight($this->getFontSize()) + 1
+ $barcodelongheight + $writer->imagefontheight($fontsize) + 1
);
- $black = $this->getWriter()->imagecolorallocate($img, 0, 0, 0);
- $white = $this->getWriter()->imagecolorallocate($img, 255, 255, 255);
- $this->getWriter()->imagefill($img, 0, 0, $white);
+ $black = $writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $writer->imagecolorallocate($img, 255, 255, 255);
+ $writer->imagefill($img, 0, 0, $white);
//------------------------------------------------------//
@@ -288,11 +294,11 @@ public function draw()
// First, print the image, centered across the bottom.
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
- $barcodewidth / 2 - strlen($text) / 2 * ($this->getWriter()->imagefontwidth($this->getFontSize())),
- $this->getBarcodeHeight() + $this->getWriter()->imagefontheight($this->getFontSize()) / 2,
+ $fontsize,
+ $barcodewidth / 2 - strlen($text) / 2 * ($writer->imagefontwidth($fontsize)),
+ $this->getBarcodeHeight() + $writer->imagefontheight($fontsize) / 2,
$text,
$black
);
@@ -310,7 +316,7 @@ public function draw()
$width = $nval * $this->getBarcodeWidth();
if ($bar == 1) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -339,7 +345,7 @@ public function draw()
*/
private function _getCharCode($char)
{
- return $this->_code[ord($char) - 32];
+ return $this->_codingmap[ord($char) - 32];
}
@@ -374,7 +380,7 @@ private function _getStopCode()
*/
private function _getNumCode($index)
{
- return $this->_code[$index];
+ return $this->_codingmap[$index];
}
36 Image/Barcode2/Driver/Code39.php
View
@@ -4,8 +4,8 @@
/**
* Image_Barcode2_Driver_Code39 class
*
- * Image_Barcode2_Code39 creates Code 3 of 9 ( Code39 ) barcode images. It's
- * implementation borrows heavily for the perl module GD::Barcode::Code39
+ * Image_Barcode2_Code39 creates Code 3 of 9 ( Code39 ) barcode images.
+ * It's implementation borrows heavily for the perl module GD::Barcode::Code39
*
* PHP versions 5
*
@@ -20,7 +20,6 @@
* @author Ryan Briones <ryanbriones@webxdesign.org>
* @copyright 2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id$
* @link http://pear.php.net/package/Image_Barcode2
*/
@@ -49,7 +48,7 @@ class Image_Barcode2_Driver_Code39 extends Image_Barcode2_Common implements Imag
* Coding map
* @var array
*/
- var $_coding_map = array(
+ private $_codingmap = array(
'0' => '000110100',
'1' => '100100001',
'2' => '001100001',
@@ -112,7 +111,8 @@ public function __construct(Image_Barcode2_Writer $writer)
/**
* Validate barcode
- *
+ *
+ * @return void
* @throws Image_Barcode2_Exception
*/
public function validate()
@@ -133,29 +133,31 @@ public function validate()
*/
public function draw()
{
- $text = $this->getBarcode();
+ $text = $this->getBarcode();
+ $writer = $this->getWriter();
+ $fontsize = $this->getFontSize();
// add start and stop * characters
$final_text = '*' . $text . '*';
$barcode = '';
foreach (str_split($final_text) as $character) {
- $barcode .= $this->_dumpCode($this->_coding_map[$character] . '0');
+ $barcode .= $this->_dumpCode($this->_codingmap[$character] . '0');
}
$barcode_len = strlen($barcode);
// Create GD image object
- $img = $this->getWriter()->imagecreate($barcode_len, $this->getBarcodeHeight());
+ $img = $writer->imagecreate($barcode_len, $this->getBarcodeHeight());
// Allocate black and white colors to the image
- $black = $this->getWriter()->imagecolorallocate($img, 0, 0, 0);
- $white = $this->getWriter()->imagecolorallocate($img, 255, 255, 255);
- $font_height = $this->getWriter()->imagefontheight($this->getFontSize());
- $font_width = $this->getWriter()->imagefontwidth($this->getFontSize());
+ $black = $writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $writer->imagecolorallocate($img, 255, 255, 255);
+ $font_height = $writer->imagefontheight($fontsize);
+ $font_width = $writer->imagefontwidth($fontsize);
// fill background with white color
- $this->getWriter()->imagefill($img, 0, 0, $white);
+ $writer->imagefill($img, 0, 0, $white);
// Initialize X position
$xpos = 0;
@@ -163,7 +165,7 @@ public function draw()
// draw barcode bars to image
foreach (str_split($barcode) as $character_code) {
if ($character_code == 0) {
- $this->getWriter()->imageline(
+ $writer->imageline(
$img,
$xpos,
0,
@@ -172,7 +174,7 @@ public function draw()
$white
);
} else {
- $this->getWriter()->imageline(
+ $writer->imageline(
$img,
$xpos,
0,
@@ -186,9 +188,9 @@ public function draw()
}
// draw text under barcode
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
($barcode_len - $font_width * strlen($text)) / 2,
$this->getBarcodeHeight() - $font_height,
$text,
194 Image/Barcode2/Driver/Ean13.php
View
@@ -19,7 +19,6 @@
* @author Didier Fournout <didier.fournout@nyc.fr>
* @copyright 2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id$
* @link http://pear.php.net/package/Image_Barcode2
*/
@@ -44,74 +43,78 @@
class Image_Barcode2_Driver_Ean13 extends Image_Barcode2_Common implements Image_Barcode2_Driver
{
/**
- * Number set
+ * Coding map
* @var array
*/
- var $_number_set = array(
- '0' => array(
- 'A' => array(0,0,0,1,1,0,1),
- 'B' => array(0,1,0,0,1,1,1),
- 'C' => array(1,1,1,0,0,1,0)
- ),
- '1' => array(
- 'A' => array(0,0,1,1,0,0,1),
- 'B' => array(0,1,1,0,0,1,1),
- 'C' => array(1,1,0,0,1,1,0)
- ),
- '2' => array(
- 'A' => array(0,0,1,0,0,1,1),
- 'B' => array(0,0,1,1,0,1,1),
- 'C' => array(1,1,0,1,1,0,0)
- ),
- '3' => array(
- 'A' => array(0,1,1,1,1,0,1),
- 'B' => array(0,1,0,0,0,0,1),
- 'C' => array(1,0,0,0,0,1,0)
- ),
- '4' => array(
- 'A' => array(0,1,0,0,0,1,1),
- 'B' => array(0,0,1,1,1,0,1),
- 'C' => array(1,0,1,1,1,0,0)
- ),
- '5' => array(
- 'A' => array(0,1,1,0,0,0,1),
- 'B' => array(0,1,1,1,0,0,1),
- 'C' => array(1,0,0,1,1,1,0)
- ),
- '6' => array(
- 'A' => array(0,1,0,1,1,1,1),
- 'B' => array(0,0,0,0,1,0,1),
- 'C' => array(1,0,1,0,0,0,0)
- ),
- '7' => array(
- 'A' => array(0,1,1,1,0,1,1),
- 'B' => array(0,0,1,0,0,0,1),
- 'C' => array(1,0,0,0,1,0,0)
- ),
- '8' => array(
- 'A' => array(0,1,1,0,1,1,1),
- 'B' => array(0,0,0,1,0,0,1),
- 'C' => array(1,0,0,1,0,0,0)
- ),
- '9' => array(
- 'A' => array(0,0,0,1,0,1,1),
- 'B' => array(0,0,1,0,1,1,1),
- 'C' => array(1,1,1,0,1,0,0)
- )
- );
+ private $_codingmap = array(
+ '0' => array(
+ 'A' => array(0,0,0,1,1,0,1),
+ 'B' => array(0,1,0,0,1,1,1),
+ 'C' => array(1,1,1,0,0,1,0)
+ ),
+ '1' => array(
+ 'A' => array(0,0,1,1,0,0,1),
+ 'B' => array(0,1,1,0,0,1,1),
+ 'C' => array(1,1,0,0,1,1,0)
+ ),
+ '2' => array(
+ 'A' => array(0,0,1,0,0,1,1),
+ 'B' => array(0,0,1,1,0,1,1),
+ 'C' => array(1,1,0,1,1,0,0)
+ ),
+ '3' => array(
+ 'A' => array(0,1,1,1,1,0,1),
+ 'B' => array(0,1,0,0,0,0,1),
+ 'C' => array(1,0,0,0,0,1,0)
+ ),
+ '4' => array(
+ 'A' => array(0,1,0,0,0,1,1),
+ 'B' => array(0,0,1,1,1,0,1),
+ 'C' => array(1,0,1,1,1,0,0)
+ ),
+ '5' => array(
+ 'A' => array(0,1,1,0,0,0,1),
+ 'B' => array(0,1,1,1,0,0,1),
+ 'C' => array(1,0,0,1,1,1,0)
+ ),
+ '6' => array(
+ 'A' => array(0,1,0,1,1,1,1),
+ 'B' => array(0,0,0,0,1,0,1),
+ 'C' => array(1,0,1,0,0,0,0)
+ ),
+ '7' => array(
+ 'A' => array(0,1,1,1,0,1,1),
+ 'B' => array(0,0,1,0,0,0,1),
+ 'C' => array(1,0,0,0,1,0,0)
+ ),
+ '8' => array(
+ 'A' => array(0,1,1,0,1,1,1),
+ 'B' => array(0,0,0,1,0,0,1),
+ 'C' => array(1,0,0,1,0,0,0)
+ ),
+ '9' => array(
+ 'A' => array(0,0,0,1,0,1,1),
+ 'B' => array(0,0,1,0,1,1,1),
+ 'C' => array(1,1,1,0,1,0,0)
+ )
+ );
- var $_number_set_left_coding = array(
- '0' => array('A','A','A','A','A','A'),
- '1' => array('A','A','B','A','B','B'),
- '2' => array('A','A','B','B','A','B'),
- '3' => array('A','A','B','B','B','A'),
- '4' => array('A','B','A','A','B','B'),
- '5' => array('A','B','B','A','A','B'),
- '6' => array('A','B','B','B','A','A'),
- '7' => array('A','B','A','B','A','B'),
- '8' => array('A','B','A','B','B','A'),
- '9' => array('A','B','B','A','B','A')
- );
+ /**
+ * Coding map left
+ * @var array
+ */
+ private $_codingmapleft = array(
+ '0' => array('A','A','A','A','A','A'),
+ '1' => array('A','A','B','A','B','B'),
+ '2' => array('A','A','B','B','A','B'),
+ '3' => array('A','A','B','B','B','A'),
+ '4' => array('A','B','A','A','B','B'),
+ '5' => array('A','B','B','A','A','B'),
+ '6' => array('A','B','B','B','A','A'),
+ '7' => array('A','B','A','B','A','B'),
+ '8' => array('A','B','A','B','B','A'),
+ '9' => array('A','B','B','A','B','A')
+ );
/**
* Class constructor
@@ -128,7 +131,8 @@ public function __construct(Image_Barcode2_Writer $writer)
/**
* Validate barcode
- *
+ *
+ * @return void
* @throws Image_Barcode2_Exception
*/
public function validate()
@@ -151,31 +155,33 @@ public function validate()
*/
public function draw()
{
- $text = $this->getBarcode();
+ $text = $this->getBarcode();
+ $writer = $this->getWriter();
+ $fontsize = $this->getFontSize();
// Calculate the barcode width
$barcodewidth = (strlen($text)) * (7 * $this->getBarcodeWidth())
+ 3 * $this->getBarcodeWidth() // left
+ 5 * $this->getBarcodeWidth() // center
+ 3 * $this->getBarcodeWidth() // right
- + $this->getWriter()->imagefontwidth($this->getFontSize()) + 1
+ + $writer->imagefontwidth($fontsize) + 1
;
- $barcodelongheight = (int)($this->getWriter()->imagefontheight($this->getFontSize()) / 2)
+ $barcodelongheight = (int)($writer->imagefontheight($fontsize) / 2)
+ $this->getBarcodeHeight();
// Create the image
- $img = $this->getWriter()->imagecreate(
+ $img = $writer->imagecreate(
$barcodewidth,
- $barcodelongheight + $this->getWriter()->imagefontheight($this->getFontSize()) + 1
+ $barcodelongheight + $writer->imagefontheight($fontsize) + 1
);
// Alocate the black and white colors
- $black = $this->getWriter()->imagecolorallocate($img, 0, 0, 0);
- $white = $this->getWriter()->imagecolorallocate($img, 255, 255, 255);
+ $black = $writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $writer->imagecolorallocate($img, 255, 255, 255);
// Fill image with white color
- $this->getWriter()->imagefill($img, 0, 0, $white);
+ $writer->imagefill($img, 0, 0, $white);
// get the first digit which is the key for creating the first 6 bars
$key = substr($text, 0, 1);
@@ -184,20 +190,20 @@ public function draw()
$xpos = 0;
// print first digit
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
$xpos,
$this->getBarcodeHeight(),
$key,
$black
);
- $xpos = $this->getWriter()->imagefontwidth($this->getFontSize()) + 1;
+ $xpos = $writer->imagefontwidth($fontsize) + 1;
// Draws the left guard pattern (bar-space-bar)
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -209,7 +215,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -220,22 +226,22 @@ public function draw()
$xpos += $this->getBarcodeWidth();
// Draw left $text contents
- $set_array = $this->_number_set_left_coding[$key];
+ $set_array = $this->_codingmapleft[$key];
for ($idx = 1; $idx < 7; $idx ++) {
$value = substr($text, $idx, 1);
- $this->getWriter()->imagestring(
- $img,
- $this->getFontSize(),
+ $writer->imagestring(
+ $img,
+ $fontsize,
$xpos + 1,
$this->getBarcodeHeight(),
$value,
$black
);
- foreach ($this->_number_set[$value][$set_array[$idx - 1]] as $bar) {
+ foreach ($this->_codingmap[$value][$set_array[$idx - 1]] as $bar) {
if ($bar) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -252,7 +258,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -264,7 +270,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -281,18 +287,18 @@ public function draw()
for ($idx = 7; $idx < 13; $idx ++) {
$value = substr($text, $idx, 1);
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
$xpos + 1,
$this->getBarcodeHeight(),
$value,
$black
);
- foreach ($this->_number_set[$value]['C'] as $bar) {
+ foreach ($this->_codingmap[$value]['C'] as $bar) {
if ($bar) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -307,7 +313,7 @@ public function draw()
// Draws the right guard pattern (bar-space-bar)
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -319,7 +325,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
134 Image/Barcode2/Driver/Ean8.php
View
@@ -20,7 +20,6 @@
* @author Didier Fournout <didier.fournout@nyc.fr>
* @copyright 2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id:
* @link http://pear.php.net/package/Image_Barcode2
*/
@@ -45,51 +44,51 @@
class Image_Barcode2_Driver_Ean8 extends Image_Barcode2_Common implements Image_Barcode2_Driver
{
/**
- * Number set
+ * Coding map
* @var array
*/
- var $_number_set = array(
- '0' => array(
- 'A' => array(0,0,0,1,1,0,1),
- 'C' => array(1,1,1,0,0,1,0)
- ),
- '1' => array(
- 'A' => array(0,0,1,1,0,0,1),
- 'C' => array(1,1,0,0,1,1,0)
- ),
- '2' => array(
- 'A' => array(0,0,1,0,0,1,1),
- 'C' => array(1,1,0,1,1,0,0)
- ),
- '3' => array(
- 'A' => array(0,1,1,1,1,0,1),
- 'C' => array(1,0,0,0,0,1,0)
- ),
- '4' => array(
- 'A' => array(0,1,0,0,0,1,1),
- 'C' => array(1,0,1,1,1,0,0)
- ),
- '5' => array(
- 'A' => array(0,1,1,0,0,0,1),
- 'C' => array(1,0,0,1,1,1,0)
- ),
- '6' => array(
- 'A' => array(0,1,0,1,1,1,1),
- 'C' => array(1,0,1,0,0,0,0)
- ),
- '7' => array(
- 'A' => array(0,1,1,1,0,1,1),
- 'C' => array(1,0,0,0,1,0,0)
- ),
- '8' => array(
- 'A' => array(0,1,1,0,1,1,1),
- 'C' => array(1,0,0,1,0,0,0)
- ),
- '9' => array(
- 'A' => array(0,0,0,1,0,1,1),
- 'C' => array(1,1,1,0,1,0,0)
- )
- );
+ private $_codingmap = array(
+ '0' => array(
+ 'A' => array(0,0,0,1,1,0,1),
+ 'C' => array(1,1,1,0,0,1,0)
+ ),
+ '1' => array(
+ 'A' => array(0,0,1,1,0,0,1),
+ 'C' => array(1,1,0,0,1,1,0)
+ ),
+ '2' => array(
+ 'A' => array(0,0,1,0,0,1,1),
+ 'C' => array(1,1,0,1,1,0,0)
+ ),
+ '3' => array(
+ 'A' => array(0,1,1,1,1,0,1),
+ 'C' => array(1,0,0,0,0,1,0)
+ ),
+ '4' => array(
+ 'A' => array(0,1,0,0,0,1,1),
+ 'C' => array(1,0,1,1,1,0,0)
+ ),
+ '5' => array(
+ 'A' => array(0,1,1,0,0,0,1),
+ 'C' => array(1,0,0,1,1,1,0)
+ ),
+ '6' => array(
+ 'A' => array(0,1,0,1,1,1,1),
+ 'C' => array(1,0,1,0,0,0,0)
+ ),
+ '7' => array(
+ 'A' => array(0,1,1,1,0,1,1),
+ 'C' => array(1,0,0,0,1,0,0)
+ ),
+ '8' => array(
+ 'A' => array(0,1,1,0,1,1,1),
+ 'C' => array(1,0,0,1,0,0,0)
+ ),
+ '9' => array(
+ 'A' => array(0,0,0,1,0,1,1),
+ 'C' => array(1,1,1,0,1,0,0)
+ )
+ );
/**
* Class constructor
@@ -106,7 +105,8 @@ public function __construct(Image_Barcode2_Writer $writer)
/**
* Validate barcode
- *
+ *
+ * @return void
* @throws Image_Barcode2_Exception
*/
public function validate()
@@ -130,7 +130,9 @@ public function validate()
*/
public function draw()
{
- $text = $this->getBarcode();
+ $text = $this->getBarcode();
+ $writer = $this->getWriter();
+ $fontsize = $this->getFontSize();
// Calculate the barcode width
$barcodewidth = (strlen($text)) * (7 * $this->getBarcodeWidth())
@@ -139,28 +141,28 @@ public function draw()
+ 3 * $this->getBarcodeWidth() // right
;
- $barcodelongheight = (int)($this->getWriter()->imagefontheight($this->getFontSize()) / 2)
+ $barcodelongheight = (int)($writer->imagefontheight($fontsize) / 2)
+ $this->getBarcodeHeight();
// Create the image
- $img = $this->getWriter()->imagecreate(
+ $img = $writer->imagecreate(
$barcodewidth,
- $barcodelongheight + $this->getWriter()->imagefontheight($this->getFontSize()) + 1
+ $barcodelongheight + $writer->imagefontheight($fontsize) + 1
);
// Alocate the black and white colors
- $black = $this->getWriter()->imagecolorallocate($img, 0, 0, 0);
- $white = $this->getWriter()->imagecolorallocate($img, 255, 255, 255);
+ $black = $writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $writer->imagecolorallocate($img, 255, 255, 255);
// Fill image with white color
- $this->getWriter()->imagefill($img, 0, 0, $white);
+ $writer->imagefill($img, 0, 0, $white);
// Initiate x position
$xpos = 0;
// Draws the left guard pattern (bar-space-bar)
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -172,7 +174,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -184,17 +186,17 @@ public function draw()
for ($idx = 0; $idx < 4; $idx ++) {
$value = substr($text, $idx, 1);
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
$xpos + 1,
$this->getBarcodeHeight(),
$value,
$black
);
- foreach ($this->_number_set[$value]['A'] as $bar) {
+ foreach ($this->_codingmap[$value]['A'] as $bar) {
if ($bar) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -211,7 +213,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -224,7 +226,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -242,18 +244,18 @@ public function draw()
for ($idx = 4; $idx < 8; $idx ++) {
$value = substr($text, $idx, 1);
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
$xpos + 1,
$this->getBarcodeHeight(),
$value,
$black
);
- foreach ($this->_number_set[$value]['C'] as $bar) {
+ foreach ($this->_codingmap[$value]['C'] as $bar) {
if ($bar) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -268,7 +270,7 @@ public function draw()
// Draws the right guard pattern (bar-space-bar)
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -280,7 +282,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
51 Image/Barcode2/Driver/Int25.php
View
@@ -19,7 +19,6 @@
* @author Marcelo Subtil Marcal <msmarcal@php.net>
* @copyright 2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id$
* @link http://pear.php.net/package/Image_Barcode2
*/
@@ -48,18 +47,18 @@ class Image_Barcode2_Driver_Int25 extends Image_Barcode2_Common implements Image
* Coding map
* @var array
*/
- var $_coding_map = array(
- '0' => '00110',
- '1' => '10001',
- '2' => '01001',
- '3' => '11000',
- '4' => '00101',
- '5' => '10100',
- '6' => '01100',
- '7' => '00011',
- '8' => '10010',
- '9' => '01010'
- );
+ private $_codingmap = array(
+ '0' => '00110',
+ '1' => '10001',
+ '2' => '01001',
+ '3' => '11000',
+ '4' => '00101',
+ '5' => '10100',
+ '6' => '01100',
+ '7' => '00011',
+ '8' => '10010',
+ '9' => '01010'
+ );
/**
* Class constructor
@@ -77,7 +76,8 @@ public function __construct(Image_Barcode2_Writer $writer)
/**
* Validate barcode
- *
+ *
+ * @return void
* @throws Image_Barcode2_Exception
*/
public function validate()
@@ -101,7 +101,8 @@ public function validate()
*/
public function draw()
{
- $text = $this->getBarcode();
+ $text = $this->getBarcode();
+ $writer = $this->getWriter();
// if odd $text lenght adds a '0' at string beginning
$text = strlen($text) % 2 ? '0' . $text : $text;
@@ -114,14 +115,14 @@ public function draw()
+ (7 * $this->getBarcodeWidthThin() + $this->getBarcodeWidthThick()) + 3;
// Create the image
- $img = $this->getWriter()->imagecreate($barcodewidth, $this->getBarcodeHeight());
+ $img = $writer->imagecreate($barcodewidth, $this->getBarcodeHeight());
// Alocate the black and white colors
- $black = $this->getWriter()->imagecolorallocate($img, 0, 0, 0);
- $white = $this->getWriter()->imagecolorallocate($img, 255, 255, 255);
+ $black = $writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $writer->imagecolorallocate($img, 255, 255, 255);
// Fill image with white color
- $this->getWriter()->imagefill($img, 0, 0, $white);
+ $writer->imagefill($img, 0, 0, $white);
// Initiate x position
$xpos = 0;
@@ -129,7 +130,7 @@ public function draw()
// Draws the leader
for ($i = 0; $i < 2; $i++) {
$elementwidth = $this->getBarcodeWidthThin();
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -155,11 +156,11 @@ public function draw()
// Draws odd char corresponding bar (black)
$elementwidth = $this->getBarcodeWidthThin();
- if (substr($this->_coding_map[$oddchar], $baridx, 1)) {
+ if (substr($this->_codingmap[$oddchar], $baridx, 1)) {
$elementwidth = $this->getBarcodeWidthThick();
}
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -172,7 +173,7 @@ public function draw()
// Left enought space to draw even char (white)
$elementwidth = $this->getBarcodeWidthThin();
- if (substr($this->_coding_map[$evenchar], $baridx, 1)) {
+ if (substr($this->_codingmap[$evenchar], $baridx, 1)) {
$elementwidth = $this->getBarcodeWidthThick();
}
@@ -184,7 +185,7 @@ public function draw()
// Draws the trailer
$elementwidth = $this->getBarcodeWidthThick();
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -196,7 +197,7 @@ public function draw()
$xpos += $this->getBarcodeWidthThin();
$xpos ++;
$elementwidth = $this->getBarcodeWidthThin();
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
51 Image/Barcode2/Driver/Postnet.php
View
@@ -19,7 +19,6 @@
* @author Josef "Jeff" Sipek <jeffpc@optonline.net>
* @copyright 2005 Josef "Jeff" Sipek
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id$
* @link http://pear.php.net/package/Image_Barcode2
*/
@@ -61,31 +60,31 @@ class Image_Barcode2_Driver_Postnet extends Image_Barcode2_Common implements Ima
*
* @var integer
*/
- var $_barshortheight = 7;
+ private $_barshortheight = 7;
/**
* Bar tall height
*
* @var integer
*/
- var $_bartallheight = 15;
+ private $_bartallheight = 15;
/**
* Coding map
* @var array
*/
- var $_coding_map = array(
- '0' => '11000',
- '1' => '00011',
- '2' => '00101',
- '3' => '00110',
- '4' => '01001',
- '5' => '01010',
- '6' => '01100',
- '7' => '10001',
- '8' => '10010',
- '9' => '10100'
- );
+ private $_codingmap = array(
+ '0' => '11000',
+ '1' => '00011',
+ '2' => '00101',
+ '3' => '00110',
+ '4' => '01001',
+ '5' => '01010',
+ '6' => '01100',
+ '7' => '10001',
+ '8' => '10010',
+ '9' => '10100'
+ );
/**
* Class constructor
@@ -101,7 +100,8 @@ public function __construct(Image_Barcode2_Writer $writer)
/**
* Validate barcode
- *
+ *
+ * @return void
* @throws Image_Barcode2_Exception
*/
public function validate()
@@ -125,27 +125,28 @@ public function validate()
*/
public function draw()
{
- $text = $this->getBarcode();
+ $text = $this->getBarcode();
+ $writer = $this->getWriter();
// Calculate the barcode width
$barcodewidth = (strlen($text)) * 2 * 5 * $this->getBarcodeWidth()
+ $this->getBarcodeWidth() * 3;
// Create the image
- $img = $this->getWriter()->imagecreate($barcodewidth, $this->_bartallheight);
+ $img = $writer->imagecreate($barcodewidth, $this->_bartallheight);
// Alocate the black and white colors
- $black = $this->getWriter()->imagecolorallocate($img, 0, 0, 0);
- $white = $this->getWriter()->imagecolorallocate($img, 255, 255, 255);
+ $black = $writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $writer->imagecolorallocate($img, 255, 255, 255);
// Fill image with white color
- $this->getWriter()->imagefill($img, 0, 0, $white);
+ $writer->imagefill($img, 0, 0, $white);
// Initiate x position
$xpos = 0;
// Draws the leader
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -163,11 +164,11 @@ public function draw()
for ($baridx = 0; $baridx < 5; $baridx++) {
$elementheight = $this->_barshortheight;
- if (substr($this->_coding_map[$char], $baridx, 1)) {
+ if (substr($this->_codingmap[$char], $baridx, 1)) {
$elementheight = 0;
}
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
$elementheight,
@@ -181,7 +182,7 @@ public function draw()
}
// Draws the trailer
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
156 Image/Barcode2/Driver/Upca.php
View
@@ -20,7 +20,6 @@
* @author Didier Fournout <didier.fournout@nyc.fr>
* @copyright 2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id$
* @link http://pear.php.net/package/Image_Barcode2
*/
@@ -52,51 +51,51 @@
class Image_Barcode2_Driver_Upca extends Image_Barcode2_Common implements Image_Barcode2_Driver
{
/**
- * Number set
+ * Coding map
* @var array
*/
- var $_number_set = array(
- '0' => array(
- 'L' => array(0,0,0,1,1,0,1),
- 'R' => array(1,1,1,0,0,1,0)
- ),
- '1' => array(
- 'L' => array(0,0,1,1,0,0,1),
- 'R' => array(1,1,0,0,1,1,0)
- ),
- '2' => array(
- 'L' => array(0,0,1,0,0,1,1),
- 'R' => array(1,1,0,1,1,0,0)
- ),
- '3' => array(
- 'L' => array(0,1,1,1,1,0,1),
- 'R' => array(1,0,0,0,0,1,0)
- ),
- '4' => array(
- 'L' => array(0,1,0,0,0,1,1),
- 'R' => array(1,0,1,1,1,0,0)
- ),
- '5' => array(
- 'L' => array(0,1,1,0,0,0,1),
- 'R' => array(1,0,0,1,1,1,0)
- ),
- '6' => array(
- 'L' => array(0,1,0,1,1,1,1),
- 'R' => array(1,0,1,0,0,0,0)
- ),
- '7' => array(
- 'L' => array(0,1,1,1,0,1,1),
- 'R' => array(1,0,0,0,1,0,0)
- ),
- '8' => array(
- 'L' => array(0,1,1,0,1,1,1),
- 'R' => array(1,0,0,1,0,0,0)
- ),
- '9' => array(
- 'L' => array(0,0,0,1,0,1,1),
- 'R' => array(1,1,1,0,1,0,0)
- )
- );
+ var $_codingmap = array(
+ '0' => array(
+ 'L' => array(0,0,0,1,1,0,1),
+ 'R' => array(1,1,1,0,0,1,0)
+ ),
+ '1' => array(
+ 'L' => array(0,0,1,1,0,0,1),
+ 'R' => array(1,1,0,0,1,1,0)
+ ),
+ '2' => array(
+ 'L' => array(0,0,1,0,0,1,1),
+ 'R' => array(1,1,0,1,1,0,0)
+ ),
+ '3' => array(
+ 'L' => array(0,1,1,1,1,0,1),
+ 'R' => array(1,0,0,0,0,1,0)
+ ),
+ '4' => array(
+ 'L' => array(0,1,0,0,0,1,1),
+ 'R' => array(1,0,1,1,1,0,0)
+ ),
+ '5' => array(
+ 'L' => array(0,1,1,0,0,0,1),
+ 'R' => array(1,0,0,1,1,1,0)
+ ),
+ '6' => array(
+ 'L' => array(0,1,0,1,1,1,1),
+ 'R' => array(1,0,1,0,0,0,0)
+ ),
+ '7' => array(
+ 'L' => array(0,1,1,1,0,1,1),
+ 'R' => array(1,0,0,0,1,0,0)
+ ),
+ '8' => array(
+ 'L' => array(0,1,1,0,1,1,1),
+ 'R' => array(1,0,0,1,0,0,0)
+ ),
+ '9' => array(
+ 'L' => array(0,0,0,1,0,1,1),
+ 'R' => array(1,1,1,0,1,0,0)
+ )
+ );
/**
* Class constructor
@@ -113,7 +112,8 @@ public function __construct(Image_Barcode2_Writer $writer)
/**
* Validate barcode
- *
+ *
+ * @return void
* @throws Image_Barcode2_Exception
*/
public function validate()
@@ -135,33 +135,35 @@ public function validate()
*/
public function draw()
{
- $text = $this->getBarcode();
+ $text = $this->getBarcode();
+ $writer = $this->getWriter();
+ $fontsize = $this->getFontSize();
// Calculate the barcode width
$barcodewidth = (strlen($text)) * (7 * $this->getBarcodeWidth())
+ 3 // left
+ 5 // center
+ 3 // right
- + $this->getWriter()->imagefontwidth($this->getFontSize()) + 1
- + $this->getWriter()->imagefontwidth($this->getFontSize()) + 1 // check digit padding
+ + $writer->imagefontwidth($fontsize) + 1
+ + $writer->imagefontwidth($fontsize) + 1 // check digit padding
;
- $barcodelongheight = (int)($this->getWriter()->imagefontheight($this->getFontSize()) / 2)
+ $barcodelongheight = (int)($writer->imagefontheight($fontsize) / 2)
+ $this->getBarcodeHeight();
// Create the image
- $img = $this->getWriter()->imagecreate(
+ $img = $writer->imagecreate(
$barcodewidth,
- $barcodelongheight + $this->getWriter()->imagefontheight($this->getFontSize()) + 1
+ $barcodelongheight + $writer->imagefontheight($fontsize) + 1
);
// Alocate the black and white colors
- $black = $this->getWriter()->imagecolorallocate($img, 0, 0, 0);
- $white = $this->getWriter()->imagecolorallocate($img, 255, 255, 255);
+ $black = $writer->imagecolorallocate($img, 0, 0, 0);
+ $white = $writer->imagecolorallocate($img, 255, 255, 255);
// Fill image with white color
- $this->getWriter()->imagefill($img, 0, 0, $white);
+ $writer->imagefill($img, 0, 0, $white);
// get the first digit which is the key for creating the first 6 bars
$key = substr($text, 0, 1);
@@ -170,20 +172,20 @@ public function draw()
$xpos = 0;
// print first digit
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
$xpos,
$this->getBarcodeHeight(),
$key,
$black
);
- $xpos = $this->getWriter()->imagefontwidth($this->getFontSize()) + 1;
+ $xpos = $writer->imagefontwidth($fontsize) + 1;
// Draws the left guard pattern (bar-space-bar)
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -196,7 +198,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -208,9 +210,9 @@ public function draw()
$xpos += $this->getBarcodeWidth();
- foreach ($this->_number_set[$key]['L'] as $bar) {
+ foreach ($this->_codingmap[$key]['L'] as $bar) {
if ($bar) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -227,18 +229,18 @@ public function draw()
// Draw left $text contents
for ($idx = 1; $idx < 6; $idx ++) {
$value = substr($text, $idx, 1);
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
$xpos + 1,
$this->getBarcodeHeight(),
$value,
$black
);
- foreach ($this->_number_set[$value]['L'] as $bar) {
+ foreach ($this->_codingmap[$value]['L'] as $bar) {
if ($bar) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -256,7 +258,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -268,7 +270,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -284,17 +286,17 @@ public function draw()
// Draw right $text contents
for ($idx = 6; $idx < 11; $idx ++) {
$value = substr($text, $idx, 1);
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
$xpos + 1,
$this->getBarcodeHeight(),
$value,
$black
);
- foreach ($this->_number_set[$value]['R'] as $bar) {
+ foreach ($this->_codingmap[$value]['R'] as $bar) {
if ($bar) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -310,9 +312,9 @@ public function draw()
$value = substr($text, 11, 1);
- foreach ($this->_number_set[$value]['R'] as $bar) {
+ foreach ($this->_codingmap[$value]['R'] as $bar) {
if ($bar) {
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -329,7 +331,7 @@ public function draw()
// Draws the right guard pattern (bar-space-bar)
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -342,7 +344,7 @@ public function draw()
// space
$xpos += $this->getBarcodeWidth();
// bar
- $this->getWriter()->imagefilledrectangle(
+ $writer->imagefilledrectangle(
$img,
$xpos,
0,
@@ -355,9 +357,9 @@ public function draw()
// Print Check Digit
- $this->getWriter()->imagestring(
+ $writer->imagestring(
$img,
- $this->getFontSize(),
+ $fontsize,
$xpos + 1,
$this->getBarcodeHeight(),
$value,
35 Image/Barcode2/DualHeight.php
View
@@ -1,4 +1,39 @@
<?php
+/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
+
+/**
+ * Image_Barcode2_DualHeight class
+ *
+ * DualHeight code
+ *
+ * PHP versions 5
+ *
+ * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
+/**
+ * Image_Barcode2_DualHeight class
+ *
+ * DualHeight code
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
interface Image_Barcode2_DualHeight
{
35 Image/Barcode2/DualWidth.php
View
@@ -1,4 +1,39 @@
<?php
+/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
+
+/**
+ * Image_Barcode2_DualWidth class
+ *
+ * DualWidth code
+ *
+ * PHP versions 5
+ *
+ * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
+/**
+ * Image_Barcode2_DualWidth class
+ *
+ * DualWidth code
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
interface Image_Barcode2_DualWidth
{
public function setBarcodeWidthThick($width);
35 Image/Barcode2/Exception.php
View
@@ -1,4 +1,39 @@
<?php
+/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
+
+/**
+ * Image_Barcode2_Exception class
+ *
+ * Exception code
+ *
+ * PHP versions 5
+ *
+ * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
+/**
+ * Image_Barcode2_Exception class
+ *
+ * Exception code
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
class Image_Barcode2_Exception extends Exception
{
31 Image/Barcode2/Writer.php
View
@@ -1,8 +1,39 @@
<?php
+/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
+
/**
+ * Image_Barcode2_Writer class
+ *
+ * An adapter for the non oo image writing code.
+ *
+ * PHP versions 5
+ *
+ * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @link http://pear.php.net/package/Image_Barcode2
+ */
+/**
+ * Image_Barcode2_Writer class
+ *
* An adapter for the non oo image writing code.
* Just used to create a seam for phpunit
*
+ * @category Image
+ * @package Image_Barcode2
+ * @author Ryan Briones <ryanbriones@webxdesign.org>
+ * @copyright 2005 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/Image_Barcode2
* @todo See if http://pear.php.net/package/Image_Canvas can be made to work well
*/
class Image_Barcode2_Writer
Please sign in to comment.
Something went wrong with that request. Please try again.