當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BCGBarcode1D::validate方法代碼示例

本文整理匯總了PHP中BCGBarcode1D::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP BCGBarcode1D::validate方法的具體用法?PHP BCGBarcode1D::validate怎麽用?PHP BCGBarcode1D::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BCGBarcode1D的用法示例。


在下文中一共展示了BCGBarcode1D::validate方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = strlen($this->text);
     if ($c === 0) {
         throw new BCGParseException('othercode', 'No data has been entered.');
     }
     parent::validate();
 }
開發者ID:hscomp2002,項目名稱:superp,代碼行數:11,代碼來源:BCGothercode.barcode.php

示例2: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = strlen($this->text);
     if ($c === 0) {
         throw new BCGParseException('othercode', 'No data has been entered.');
     }
     // Checking if all chars are allowed
     for ($i = 0; $i < $c; $i++) {
         if (array_search($this->text[$i], $this->keys) === false) {
             throw new BCGParseException('othercode', 'The character \'' . $this->text[$i] . '\' is not allowed.');
         }
     }
     parent::validate();
 }
開發者ID:sea129,項目名稱:kbay,代碼行數:17,代碼來源:BCGothercode.barcode.php

示例3: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = strlen($this->text);
     if ($c === 0) {
         throw new BCGParseException('s25', 'No data has been entered.');
     }
     // Checking if all chars are allowed
     for ($i = 0; $i < $c; $i++) {
         if (array_search($this->text[$i], $this->keys) === false) {
             throw new BCGParseException('s25', 'The character \'' . $this->text[$i] . '\' is not allowed.');
         }
     }
     // Must be even
     if ($c % 2 !== 0 && $this->checksum === false) {
         throw new BCGParseException('s25', 's25 must contain an even amount of digits if checksum is false.');
     } elseif ($c % 2 === 0 && $this->checksum === true) {
         throw new BCGParseException('s25', 's25 must contain an odd amount of digits if checksum is true.');
     }
     parent::validate();
 }
開發者ID:minorusal,項目名稱:administrador,代碼行數:23,代碼來源:BCGs25.barcode.php

示例4: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = strlen($this->text);
     if ($c === 0) {
         throw new BCGParseException('codabar', 'No data has been entered.');
     }
     // Checking if all chars are allowed
     for ($i = 0; $i < $c; $i++) {
         if (array_search($this->text[$i], $this->keys) === false) {
             throw new BCGParseException('codabar', 'The character \'' . $this->text[$i] . '\' is not allowed.');
         }
     }
     // Must start by A, B, C or D
     if ($c == 0 || $this->text[0] !== 'A' && $this->text[0] !== 'B' && $this->text[0] !== 'C' && $this->text[0] !== 'D') {
         throw new BCGParseException('codabar', 'The text must start by the character A, B, C, or D.');
     }
     // Must end by A, B, C or D
     $c2 = $c - 1;
     if ($c2 === 0 || $this->text[$c2] !== 'A' && $this->text[$c2] !== 'B' && $this->text[$c2] !== 'C' && $this->text[$c2] !== 'D') {
         throw new BCGParseException('codabar', 'The text must end by the character A, B, C, or D.');
     }
     parent::validate();
 }
開發者ID:shojibflamon,項目名稱:Bar-Code-example,代碼行數:26,代碼來源:BCGcodabar.barcode.php

示例5: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = strlen($this->text);
     if ($c === 0) {
         throw new BCGParseException('ean13', 'No data has been entered.');
     }
     $this->checkCharsAllowed();
     $this->checkCorrectLength();
     parent::validate();
 }
開發者ID:shojibflamon,項目名稱:Bar-Code-example,代碼行數:13,代碼來源:BCGean13.barcode.php

示例6: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = strlen($this->text);
     if ($c === 0) {
         throw new BCGParseException('postnet', 'No data has been entered.');
     }
     // Checking if all chars are allowed
     for ($i = 0; $i < $c; $i++) {
         if (array_search($this->text[$i], $this->keys) === false) {
             throw new BCGParseException('postnet', 'The character \'' . $this->text[$i] . '\' is not allowed.');
         }
     }
     // Must contain 5, 9 or 11 chars
     if ($c !== 5 && $c !== 9 && $c !== 11) {
         throw new BCGParseException('postnet', 'Must contain 5, 9, or 11 characters.');
     }
     parent::validate();
 }
開發者ID:hscomp2002,項目名稱:superp,代碼行數:21,代碼來源:BCGpostnet.barcode.php

示例7: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     // Tracking must have been entered
     if ($this->barcodeIdentifier === null || $this->serviceTypeIdentifier === null || $this->mailerIdentifier === null || $this->serialNumber === null) {
         throw new BCGParseException('intelligentmail', 'The tracking code must be set before calling the parse method.');
     }
     // Checking if all chars are allowed
     $match = array();
     if (preg_match('/[^0-9]/', $this->text, $match)) {
         throw new BCGParseException('intelligentmail', 'The character \'' . $match[0] . '\' is not allowed.');
     }
     // Must contain 0, 5, 9 or 11 chars
     $c = strlen($this->text);
     if ($c !== 0 && $c !== 5 && $c !== 9 && $c !== 11) {
         throw new BCGParseException('intelligentmail', 'Must contain 0, 5, 9, or 11 characters.');
     }
     parent::validate();
 }
開發者ID:sea129,項目名稱:kbay,代碼行數:21,代碼來源:BCGintelligentmail.barcode.php

示例8: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = count($this->data);
     if ($c === 0) {
         throw new BCGParseException('code128', 'No data has been entered.');
     }
     parent::validate();
 }
開發者ID:hscomp2002,項目名稱:superp,代碼行數:11,代碼來源:BCGcode128.barcode.php

示例9: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = strlen($this->text);
     if ($c === 0) {
         throw new BCGParseException('ean8', 'No data has been entered.');
     }
     // Checking if all chars are allowed
     for ($i = 0; $i < $c; $i++) {
         if (array_search($this->text[$i], $this->keys) === false) {
             throw new BCGParseException('ean8', 'The character \'' . $this->text[$i] . '\' is not allowed.');
         }
     }
     // If we have 8 chars just flush the last one
     if ($c === 8) {
         $this->text = substr($this->text, 0, 7);
     } elseif ($c !== 7) {
         throw new BCGParseException('ean8', 'Must contain 7 digits, the 8th digit is automatically added.');
     }
     parent::validate();
 }
開發者ID:dducrest,項目名稱:brewcompetitiononlineentry,代碼行數:23,代碼來源:BCGean8.barcode.php

示例10: validate

 /**
  * Validates the input.
  */
 protected function validate()
 {
     $c = strlen($this->text);
     if ($c === 0) {
         throw new BCGParseException('upce', 'No data has been entered.');
     }
     // Checking if all chars are allowed
     for ($i = 0; $i < $c; $i++) {
         if (array_search($this->text[$i], $this->keys) === false) {
             throw new BCGParseException('upce', 'The character \'' . $this->text[$i] . '\' is not allowed.');
         }
     }
     // Must contain 11 chars
     // Must contain 6 chars (if starting with upce directly)
     // First Chars must be 0 or 1
     if ($c !== 11 && $c !== 6) {
         throw new BCGParseException('upce', 'You must provide a UPC-A (11 characters) or a UPC-E (6 characters).');
     } elseif ($this->text[0] !== '0' && $this->text[0] !== '1' && $c !== 6) {
         throw new BCGParseException('upce', 'UPC-A must start with 0 or 1 to be converted to UPC-E.');
     }
     // Convert part
     $this->upce = '';
     if ($c !== 6) {
         // Checking if UPC-A is convertible
         $temp1 = substr($this->text, 3, 3);
         if ($temp1 === '000' || $temp1 === '100' || $temp1 === '200') {
             // manufacturer code ends with 100,200 or 300
             if (substr($this->text, 6, 2) === '00') {
                 // Product must start with 00
                 $this->upce = substr($this->text, 1, 2) . substr($this->text, 8, 3) . substr($this->text, 3, 1);
             }
         } elseif (substr($this->text, 4, 2) === '00') {
             // manufacturer code ends with 00
             if (substr($this->text, 6, 3) === '000') {
                 // Product must start with 000
                 $this->upce = substr($this->text, 1, 3) . substr($this->text, 9, 2) . '3';
             }
         } elseif (substr($this->text, 5, 1) === '0') {
             // manufacturer code ends with 0
             if (substr($this->text, 6, 4) === '0000') {
                 // Product must start with 0000
                 $this->upce = substr($this->text, 1, 4) . substr($this->text, 10, 1) . '4';
             }
         } else {
             // No zero leading at manufacturer code
             $temp2 = intval(substr($this->text, 10, 1));
             if (substr($this->text, 6, 4) === '0000' && $temp2 >= 5 && $temp2 <= 9) {
                 // Product must start with 0000 and must end by 5,6,7,8 or 9
                 $this->upce = substr($this->text, 1, 5) . substr($this->text, 10, 1);
             }
         }
     } else {
         $this->upce = $this->text;
     }
     if ($this->upce === '') {
         throw new BCGParseException('upce', 'Your UPC-A can\'t be converted to UPC-E.');
     }
     if ($c === 6) {
         $upca = '';
         // We convert UPC-E to UPC-A to find the checksum
         if ($this->text[5] === '0' || $this->text[5] === '1' || $this->text[5] === '2') {
             $upca = substr($this->text, 0, 2) . $this->text[5] . '0000' . substr($this->text, 2, 3);
         } elseif ($this->text[5] === '3') {
             $upca = substr($this->text, 0, 3) . '00000' . substr($this->text, 3, 2);
         } elseif ($this->text[5] === '4') {
             $upca = substr($this->text, 0, 4) . '00000' . $this->text[4];
         } else {
             $upca = substr($this->text, 0, 5) . '0000' . $this->text[5];
         }
         $this->text = '0' . $upca;
     }
     parent::validate();
 }
開發者ID:marsa1985,項目名稱:kazabiz,代碼行數:76,代碼來源:BCGupce.barcode.php


注:本文中的BCGBarcode1D::validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。