本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}