/** * Constructor * * @param string $text * @param int $moduleSize */ public function __construct($text, $moduleSize = 2) { try { // Fill set A for ($i = 32; $i <= 95; $i++) { // chars SPACE - UNDERSPACE $this->setA[$i] = $i - 32; $this->charsA .= chr($i); $allowedChars[] = chr($i); } for ($i = 0; $i <= 31; $i++) { // chars NUL - US (Unit seperator) $this->setA[$i] = $i + 64; $this->charsA .= chr($i); $allowedChars[] = chr($i); } /* Fill set B * chars SPACE " " - "DEL" */ for ($i = 32; $i <= 127; $i++) { $this->setB[$i] = $i - 32; $this->charsB .= chr($i); $allowedChars[] = chr($i); } parent::__construct($text, $moduleSize, $allowedChars); $this->biteCode = $this->createBiteCode(); } catch (Exception $e) { throw $e; } }
/** * Constructor * * @param string $text * @param int $modulesize */ public function __construct($text, $moduleSize) { try { parent::__construct($text, $moduleSize, $this->allowedChars); $this->biteCode = $this->createBiteCode(); } catch (Exception $e) { throw $e; } }
/** * Constructor * * @param string $text * @param int $modulesize */ public function __construct($text, $moduleSize) { try { parent::__construct($text, $moduleSize, $this->allowedChars); if (strlen($this->text) % 2 != 0) { throw new Exception('The number of characters must be even', E_ODD_LENGTH); } $this->biteCode = $this->createBiteCode(); } catch (Exception $e) { throw $e; } }
/** * Constructor * * @param string $text * @param int $modulesize */ public function __construct($text, $moduleSize) { try { parent::__construct($text, $moduleSize, $this->allowedChars); if (strlen($this->text) != 12) { throw new Exception('Text length must be 12 characters.', E_BAD_EAN_LENGTH); } $this->biteCode = $this->createBiteCode(); } catch (Exception $e) { throw $e; } }
/** * Constructor * * @param string $text * @param int $modulesize */ public function __construct($text, $moduleSize) { try { parent::__construct($text, $moduleSize, $this->allowedChars); if (strlen($this->text) != 11) { throw new Exception('Chyba: Délka musí být 11 znaků.', E_BAD_UPC_LENGTH); } // Add zero to the beginnign of code (compatibility with EAN) $this->text = '0' . $this->text; $this->biteCode = $this->createBiteCode(); } catch (Exception $e) { throw $e; } }