import v1.1.0_RC2 | 2009-09-20
This commit is contained in:
@ -15,9 +15,9 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Validate
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Ean13.php 11791 2008-10-09 18:19:13Z andries $
|
||||
* @version $Id: Ean13.php 16223 2009-06-21 20:04:53Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ require_once 'Zend/Validate/Abstract.php';
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Validate
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Abstract
|
||||
@ -74,20 +74,18 @@ class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Abstract
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if (false === ctype_digit($value)) {
|
||||
if (!is_string($value) || !ctype_digit($value)) {
|
||||
$this->_error(self::NOT_NUMERIC);
|
||||
return false;
|
||||
}
|
||||
|
||||
$valueString = (string) $value;
|
||||
$this->_setValue($valueString);
|
||||
|
||||
if (strlen($valueString) !== 13) {
|
||||
$this->_setValue($value);
|
||||
if (strlen($value) !== 13) {
|
||||
$this->_error(self::INVALID_LENGTH);
|
||||
return false;
|
||||
}
|
||||
|
||||
$barcode = strrev(substr($valueString, 0, -1));
|
||||
$barcode = strrev(substr($value, 0, -1));
|
||||
$oddSum = 0;
|
||||
$evenSum = 0;
|
||||
|
||||
@ -102,7 +100,7 @@ class Zend_Validate_Barcode_Ean13 extends Zend_Validate_Abstract
|
||||
$calculation = ($oddSum + $evenSum) % 10;
|
||||
$checksum = ($calculation === 0) ? 0 : 10 - $calculation;
|
||||
|
||||
if ($valueString[12] != $checksum) {
|
||||
if ($value[12] != $checksum) {
|
||||
$this->_error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user