Ean2.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Barcode
  17. * @subpackage Object
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Barcode_Object_Ean5
  24. */
  25. require_once 'Zend/Barcode/Object/Ean5.php';
  26. /**
  27. * @see Zend_Validate_Barcode
  28. */
  29. require_once 'Zend/Validate/Barcode.php';
  30. /**
  31. * Class for generate Ean2 barcode
  32. *
  33. * @category Zend
  34. * @package Zend_Barcode
  35. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Barcode_Object_Ean2 extends Zend_Barcode_Object_Ean5
  39. {
  40. protected $_parities = array(
  41. 0 => array('A','A'),
  42. 1 => array('A','B'),
  43. 2 => array('B','A'),
  44. 3 => array('B','B')
  45. );
  46. /**
  47. * Default options for Ean2 barcode
  48. * @return void
  49. */
  50. protected function _getDefaultOptions()
  51. {
  52. $this->_barcodeLength = 2;
  53. }
  54. protected function _getParity($i)
  55. {
  56. $modulo = $this->getText() % 4;
  57. return $this->_parities[$modulo][$i];
  58. }
  59. }