本文整理汇总了PHP中Zend_Validate_Barcode类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Barcode类的具体用法?PHP Zend_Validate_Barcode怎么用?PHP Zend_Validate_Barcode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Validate_Barcode类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testSetType
public function testSetType()
{
$barcode = new Zend_Validate_Barcode('upc-a');
$this->assertTrue($barcode->isValid('065100004327'));
$barcode->setType('ean-13');
$this->assertTrue($barcode->isValid('0075678164125'));
}
开发者ID:jon9872,项目名称:zend-framework,代码行数:7,代码来源:BarcodeTest.php
示例2: isWorldWideId
private function isWorldWideId($worldWideId, $type)
{
$adapters = array('UPC' => array('8' => 'Upce', '12' => 'Upca'), 'EAN' => array('8' => 'Ean8', '13' => 'Ean13'));
$length = strlen($worldWideId);
if (!isset($adapters[$type], $adapters[$type][$length])) {
return false;
}
try {
$validator = new Zend_Validate_Barcode($adapters[$type][$length]);
return $validator->isValid($worldWideId);
} catch (Zend_Validate_Exception $e) {
return true;
}
}
开发者ID:xiaoguizhidao,项目名称:bb,代码行数:14,代码来源:Validation.php
示例3: testUPCE
public function testUPCE()
{
$barcode = new Zend_Validate_Barcode('upce');
$this->assertTrue($barcode->isValid('02345673'));
$this->assertFalse($barcode->isValid('02345672'));
$this->assertFalse($barcode->isValid('123'));
$this->assertTrue($barcode->isValid('123456'));
$this->assertTrue($barcode->isValid('0234567'));
}
开发者ID:netvlies,项目名称:zf,代码行数:9,代码来源:BarcodeTest.php
示例4: _validateText
/**
* Particular validation for Upce barcode objects
* (to suppress checksum character substitution)
*
* @param string $value
* @param array $options
* @throws Zend_Barcode_Object_Exception
*/
protected function _validateText($value, $options = array())
{
$validator = new Zend_Validate_Barcode(array('adapter' => 'upce', 'checksum' => false));
$value = $this->_addLeadingZeros($value, true);
if (!$validator->isValid($value)) {
$message = implode("\n", $validator->getMessages());
/**
* @see Zend_Barcode_Object_Exception
*/
throw new Zend_Barcode_Object_Exception($message);
}
}
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:20,代码来源:Upce.php
示例5: _validateText
/**
* Standard validation for most of barcode objects
* @param string $value
* @param array $options
*/
protected function _validateText($value, $options = array())
{
$validatorName = isset($options['validator']) ? $options['validator'] : $this->getType();
$validator = new Zend_Validate_Barcode(array('adapter' => $validatorName, 'checksum' => false));
$checksumCharacter = '';
$withChecksum = false;
if ($this->_mandatoryChecksum) {
$checksumCharacter = $this->_substituteChecksumCharacter;
$withChecksum = true;
}
$value = $this->_addLeadingZeros($value, $withChecksum) . $checksumCharacter;
if (!$validator->isValid($value)) {
$message = implode("\n", $validator->getMessages());
/**
* @see Zend_Barcode_Object_Exception
*/
require_once 'Zend/Barcode/Object/Exception.php';
throw new Zend_Barcode_Object_Exception($message);
}
}
开发者ID:vicfryzel,项目名称:zf,代码行数:25,代码来源:ObjectAbstract.php
示例6: testArrayLengthMessage
/**
* @group ZF-10116
*/
public function testArrayLengthMessage()
{
$barcode = new Zend_Validate_Barcode('ean8');
$this->assertFalse($barcode->isValid('123'));
$message = $barcode->getMessages();
$this->assertTrue(array_key_exists('barcodeInvalidLength', $message));
$this->assertContains("length of 7/8 characters", $message['barcodeInvalidLength']);
}
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:11,代码来源:BarcodeTest.php
示例7: _validateText
/**
* Particular validation for Ean8 barcode objects
* (to suppress checksum character substitution)
* @param string $value
* @param array $options
*/
protected function _validateText($value, $options = array())
{
$validator = new Zend_Validate_Barcode(array('adapter' => 'ean8', 'checksum' => false));
$value = $this->_addLeadingZeros($value, true);
if (!$validator->isValid($value)) {
$message = implode("\n", $validator->getMessages());
/**
* @see Zend_Barcode_Object_Exception
*/
require_once PHP_LIBRARY_PATH . 'Zend/Barcode/Object/Exception.php';
throw new Zend_Barcode_Object_Exception($message);
}
}
开发者ID:netixx,项目名称:Stock,代码行数:19,代码来源:Ean8.php
注:本文中的Zend_Validate_Barcode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论