|
|
@@ -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;
|
|
|
}
|