"Fossies" - the Fresh Open Source Software Archive

Member "pandora_console/vendor/mpdf/mpdf/src/Barcode/AbstractBarcode.php" (27 Mar 2019, 1103 Bytes) of package /linux/misc/pandorafms_console-7.0NG.733.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AbstractBarcode.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Mpdf\Barcode;
    4 
    5 abstract class AbstractBarcode
    6 {
    7 
    8     /**
    9      * @var mixed[]
   10      */
   11     protected $data;
   12 
   13     /**
   14      * @return mixed[]
   15      */
   16     public function getData()
   17     {
   18         return $this->data;
   19     }
   20 
   21     /**
   22      * @param string $key
   23      *
   24      * @return mixed
   25      */
   26     public function getKey($key)
   27     {
   28         return isset($this->data[$key]) ? $this->data[$key] : null;
   29     }
   30 
   31     /**
   32      * @return string
   33      */
   34     public function getChecksum()
   35     {
   36         return $this->getKey('checkdigit');
   37     }
   38 
   39     /**
   40      * Convert binary barcode sequence to barcode array
   41      *
   42      * @param string $seq
   43      * @param mixed[] $barcodeData
   44      *
   45      * @return mixed[]
   46      */
   47     protected function binseqToArray($seq, array $barcodeData)
   48     {
   49         $len = strlen($seq);
   50         $w = 0;
   51         $k = 0;
   52         for ($i = 0; $i < $len; ++$i) {
   53             $w += 1;
   54             if (($i == ($len - 1)) or (($i < ($len - 1)) and ($seq[$i] != $seq[($i + 1)]))) {
   55                 if ($seq[$i] == '1') {
   56                     $t = true; // bar
   57                 } else {
   58                     $t = false; // space
   59                 }
   60                 $barcodeData['bcode'][$k] = ['t' => $t, 'w' => $w, 'h' => 1, 'p' => 0];
   61                 $barcodeData['maxw'] += $w;
   62                 ++$k;
   63                 $w = 0;
   64             }
   65         }
   66         return $barcodeData;
   67     }
   68 
   69 }