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
10 namespace Zend\Barcode\
Object;
13 * Class for generate Identcode barcode
15 class Identcode
extends Code25interleaved
19 * Default options for Identcode barcode
22 protected function getDefaultOptions()
24 $this->barcodeLength
= 12;
25 $this->mandatoryChecksum
= true;
29 * Retrieve text to display
32 public function getTextToDisplay()
34 return preg_replace('/([0-9]{2})([0-9]{3})([0-9]{3})([0-9]{3})([0-9])/',
40 * Check allowed characters
41 * @param string $value
45 public function validateText($value)
47 $this->validateSpecificText($value, array('validator' => $this->getType()));
51 * Get barcode checksum
56 public function getChecksum($text)
58 $this->checkText($text);
61 for ($i = strlen($text); $i > 0; $i --) {
62 $checksum +
= intval($text{$i - 1}) * (($i %
2) ?
4 : 9);
65 $checksum = (10 - ($checksum %
10)) %
10;