Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Barcode / Object / Identcode.php
blob4e7268cf4917f80fea2d42e343042da906cabb11
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-2013 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 Identcode barcode
15 class Identcode extends Code25interleaved
18 /**
19 * Default options for Identcode barcode
20 * @return void
22 protected function getDefaultOptions()
24 $this->barcodeLength = 12;
25 $this->mandatoryChecksum = true;
28 /**
29 * Retrieve text to display
30 * @return string
32 public function getTextToDisplay()
34 return preg_replace('/([0-9]{2})([0-9]{3})([0-9]{3})([0-9]{3})([0-9])/',
35 '$1.$2 $3.$4 $5',
36 $this->getText());
39 /**
40 * Check allowed characters
41 * @param string $value
42 * @return string
43 * @throws Exception
45 public function validateText($value)
47 $this->validateSpecificText($value, array('validator' => $this->getType()));
50 /**
51 * Get barcode checksum
53 * @param string $text
54 * @return int
56 public function getChecksum($text)
58 $this->checkText($text);
59 $checksum = 0;
61 for ($i = strlen($text); $i > 0; $i --) {
62 $checksum += intval($text{$i - 1}) * (($i % 2) ? 4 : 9);
65 $checksum = (10 - ($checksum % 10)) % 10;
67 return $checksum;