source-class-Com.Tecnick.Barcode.Type.Linear.PharmaTwoTracks

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Exceptions

 1: <?php
 2: /**
 3:  * PharmaTwoTracks.php
 4:  *
 5:  * @since       2015-02-21
 6:  * @category    Library
 7:  * @package     Barcode
 8:  * @author      Nicola Asuni <info@tecnick.com>
 9:  * @copyright   2010-2016 Nicola Asuni - Tecnick.com LTD
10:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
11:  * @link        https://github.com/tecnickcom/tc-lib-barcode
12:  *
13:  * This file is part of tc-lib-barcode software library.
14:  */
15: 
16: namespace Com\Tecnick\Barcode\Type\Linear;
17: 
18: use \Com\Tecnick\Barcode\Exception as BarcodeException;
19: 
20: /**
21:  * Com\Tecnick\Barcode\Type\Linear\PharmaTwoTracks;
22:  *
23:  * PharmaTwoTracks Barcode type class
24:  * PHARMACODE TWO-TRACKS
25:  *
26:  * @since       2015-02-21
27:  * @category    Library
28:  * @package     Barcode
29:  * @author      Nicola Asuni <info@tecnick.com>
30:  * @copyright   2010-2016 Nicola Asuni - Tecnick.com LTD
31:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
32:  * @link        https://github.com/tecnickcom/tc-lib-barcode
33:  */
34: class PharmaTwoTracks extends \Com\Tecnick\Barcode\Type\Linear
35: {
36:     /**
37:      * Barcode format
38:      *
39:      * @var string
40:      */
41:     protected $format = 'PHARMA2T';
42:     
43:     /**
44:      * Get the bars array
45:      *
46:      * @throws BarcodeException in case of error
47:      */
48:     protected function setBars()
49:     {
50:         $seq = '';
51:         $code = intval($this->code);
52: 
53:         do {
54:             switch ($code % 3) {
55:                 case 0:
56:                     $seq .= '3';
57:                     $code = (($code - 3) / 3);
58:                     break;
59:                 case 1:
60:                     $seq .= '1';
61:                     $code = (($code - 1) / 3);
62:                     break;
63:                 case 2:
64:                     $seq .= '2';
65:                     $code = (($code - 2) / 3);
66:             }
67:         } while ($code != 0);
68:         
69:         $seq = strrev($seq);
70:         $this->ncols = 0;
71:         $this->nrows = 2;
72:         $this->bars = array();
73:         $len = strlen($seq);
74:         for ($pos = 0; $pos < $len; ++$pos) {
75:             switch ($seq[$pos]) {
76:                 case '1':
77:                     $this->bars[] = array($this->ncols, 1, 1, 1);
78:                     break;
79:                 case '2':
80:                     $this->bars[] = array($this->ncols, 0, 1, 1);
81:                     break;
82:                 case '3':
83:                     $this->bars[] = array($this->ncols, 0, 1, 2);
84:                     break;
85:             }
86:             $this->ncols += 2;
87:         }
88:         --$this->ncols;
89:     }
90: }
91: 
 

© 2004-2017 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy