Example #1
0
 /**
  * 
  * @param EncoderInterface $bars
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $encoded = '';
     $parityTab =& self::$parityTable[$data % 4];
     $encoded = '1011' . self::$encodingTable[$data[0]][$parityTab[0]] . '01' . self::$encodingTable[$data[1]][$parityTab[1]];
     $encoder->addBinary($encoded);
 }
Example #2
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $encoded = '';
     $data = \str_split($data);
     \array_unshift($data, $this->start);
     \array_push($data, $this->stop);
     foreach ($data as &$char) {
         $encoded .= self::$encodingTable[$char] . '0';
     }
     $encoded = \substr($encoded, 0, -1);
     $encoder->addBinary($encoded);
 }
Example #3
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $data = \str_split($data);
     $check = \substr(self::sumAlternateWeight($data, 3, 9), -1);
     $parityTab =& self::$parityTable[$check];
     $encoded = '1011';
     foreach ($data as $i => &$char) {
         $encoded .= self::$encodingTable[$char][$parityTab[$i]];
         $encoded .= '01';
     }
     $encoded = \substr($encoded, 0, -2);
     $encoder->addBinary($encoded);
 }
Example #4
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $data = \str_split($data);
     $encoded = $this->widthToBinary('WNWNNN');
     $encoder->addBinary($encoded);
     foreach ($data as &$char) {
         $nwChar =& self::$encodingTable[$char];
         for ($i = 0; $i < 5; $i++) {
             $encoded = $this->encodeWithWidth($nwChar[$i] == 'N', true);
             $encoded .= $this->encodeWithWidth(true, false);
             $encoder->addBinary($encoded);
         }
     }
     $encoded = $this->widthToBinary('WNNNW');
     $encoder->addBinary($encoded);
 }
Example #5
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $data = \str_split($data);
     $encoded = $this->widthToBinary('NNNN');
     $encoder->addBinary($encoded);
     while (!empty($data)) {
         $nwChar1 =& self::$encodingTable[\array_shift($data)];
         $nwChar2 =& self::$encodingTable[\array_shift($data)];
         for ($i = 0; $i < 5; $i++) {
             $encoded = $this->encodeWithWidth($nwChar1[$i] == 'N', true);
             $encoded .= $this->encodeWithWidth($nwChar2[$i] == 'N', false);
             $encoder->addBinary($encoded);
         }
     }
     $encoded = $this->widthToBinary('WNN');
     $encoder->addBinary($encoded);
 }
 /**
  * 
  * @return EncoderInterface
  */
 public function getEncoded()
 {
     if (empty($this->encoded)) {
         $this->encoded = new BarSpace();
         $this->encodeData($this->encoded, $this->data);
         $this->encoded->close();
     }
     return $this->encoded;
 }
Example #7
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $encoder->addBinary('10110010');
     while (!empty($data)) {
         $char = \substr_remove($data, 0, 1);
         $encoded = self::$encodingTable[$char] . '0';
         $encoder->addBinary($encoded);
     }
     $encoder->addBinary('1011001');
 }
Example #8
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(Encoder\EncoderInterface &$encoder, $data)
 {
     $codes = $this->convertToCodes($data);
     $this->insertChecksumCode($codes);
     foreach ($codes as &$code) {
         $encoded = self::$encodingTable[$code];
         $encoder->addBinary($encoded);
     }
     $encoder->addBinary('1100011101011');
 }
Example #9
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $n = \strlen($data);
     $encoder->addBinary('110');
     for ($i = 0; $i < $n; $i++) {
         $encoded = self::$encodingTable[$data[$i]];
         $encoder->addBinary($encoded);
     }
     $encoder->addBinary('1001');
 }
Example #10
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $encoded = '';
     $parityTab =& self::$parityTable[$data[0]];
     for ($i = 1; $i < 13; $i++) {
         $parity = $i <= 6 ? $parityTab[$i - 1] : 2;
         $encoded .= self::$encodingTable[$data[$i]][$parity];
     }
     $barHeight = $this->showText ? 1.2 : 1;
     $encoder->addBinary('101', $barHeight)->addBinary(\substr($encoded, 0, 42))->addBinary('01010', $barHeight)->addBinary(\substr($encoded, 42))->addBinary('101', $barHeight);
 }
Example #11
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $data = "*{$data}*";
     $data = \str_split($data);
     $encoded = '';
     foreach ($data as &$char) {
         $nwChar =& self::$encodingTable[$char];
         $encoded .= $this->widthToBinary($nwChar . 'N');
     }
     $encoded = \substr($encoded, 0, $this->narrowWidth * -1);
     $encoder->addBinary($encoded);
 }
Example #12
0
 /**
  * 
  * @param EncoderInterface $encoder
  * @param string $data
  */
 protected function encodeData(EncoderInterface &$encoder, $data)
 {
     $check = $this->extractChecksum($data, $data);
     $parityTab =& self::$parityTable[$check][$data[0]];
     $encoded = '';
     for ($i = 1; $i < 7; $i++) {
         $parity = $parityTab[$i - 1];
         $encoded .= self::$encodingTable[$data[$i]][$parity];
     }
     $barHeight = $this->showText ? 1.2 : 1;
     $encoder->addBinary('101', $barHeight)->addBinary($encoded)->addBinary('010')->addBinary('101', $barHeight);
 }