Install zendframework via composer, update build.xml and run, updates to composer
[openemr.git] / vendor / zendframework / zendframework / library / Zend / Barcode / Object / Codabar.php
blobe9766788384508bfc5ff2d0981d0076e1214ddaa
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Barcode\Object;
12 /**
13 * Class for generate Codabar barcode
15 class Codabar extends AbstractObject
17 /**
18 * Coding map
19 * - 0 = space
20 * - 1 = bar
21 * @var array
23 protected $codingMap = array(
24 '0' => "101010011", '1' => "101011001", '2' => "101001011",
25 '3' => "110010101", '4' => "101101001", '5' => "110101001",
26 '6' => "100101011", '7' => "100101101", '8' => "100110101",
27 '9' => "110100101", '-' => "101001101", '$' => "101100101",
28 ':' => "1101011011", '/' => "1101101011", '.' => "1101101101",
29 '+' => "1011011011", 'A' => "1011001001", 'B' => "1010010011",
30 'C' => "1001001011", 'D' => "1010011001"
33 /**
34 * Width of the barcode (in pixels)
35 * @return int
37 protected function calculateBarcodeWidth()
39 $quietZone = $this->getQuietZone();
40 $encodedData = 0;
41 $barcodeChar = str_split($this->getText());
42 if (count($barcodeChar) > 1) {
43 foreach ($barcodeChar as $c) {
44 $encodedData += ((strlen($this->codingMap[$c]) + 1) * $this->barThinWidth) * $this->factor;
47 $encodedData -= (1 * $this->barThinWidth * $this->factor);
48 return $quietZone + $encodedData + $quietZone;
51 /**
52 * Partial check of Codabar barcode
53 * @return void
55 protected function checkSpecificParams()
59 /**
60 * Prepare array to draw barcode
61 * @return array
63 protected function prepareBarcode()
65 $text = str_split($this->getText());
66 $barcodeTable = array();
67 foreach ($text as $char) {
68 $barcodeChar = str_split($this->codingMap[$char]);
69 foreach ($barcodeChar as $c) {
70 // visible, width, top, length
71 $barcodeTable[] = array($c, $this->barThinWidth, 0, 1);
73 $barcodeTable[] = array(0, $this->barThinWidth);
75 return $barcodeTable;