cvs: pear /Validate/Validate ISPN.php
| From: | Helgi �ormar �orbj�rnsson | Date: | Fri, 21 Jan 2005 19:30:33 +0000 |
| Subject: | cvs: pear /Validate/Validate ISPN.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-28728@lists.php.net to get a copy of this message | ||
dufuz Fri Jan 21 14:30:33 2005 EDT
Modified files:
/pear/Validate/Validate ISPN.php
Log:
make _process public and renamed to process, add params modulo and subtract so it can be used to
make other functions then just with modulo 10 and subtract 10 like before, should make things a
little more flexible.
http://cvs.php.net/diff.php/pear/Validate/Validate/ISPN.php?r1=1.4&r2=1.5&ty=u
Index: pear/Validate/Validate/ISPN.php
diff -u pear/Validate/Validate/ISPN.php:1.4 pear/Validate/Validate/ISPN.php:1.5
--- pear/Validate/Validate/ISPN.php:1.4 Fri Jan 21 12:50:09 2005
+++ pear/Validate/Validate/ISPN.php Fri Jan 21 14:30:32 2005
@@ -17,7 +17,7 @@
// | Damien Seguy <dams@nexen.net> |
// +----------------------------------------------------------------------+
//
-// $Id: ISPN.php,v 1.4 2005/01/21 17:50:09 dufuz Exp $
+// $Id: ISPN.php,v 1.5 2005/01/21 19:30:32 dufuz Exp $
require_once 'Validate.php';
@@ -26,7 +26,7 @@
*
* @category PHP
* @package Validate_ISPN
- * @version $Id: ISPN.php,v 1.4 2005/01/21 17:50:09 dufuz Exp $
+ * @version $Id: ISPN.php,v 1.5 2005/01/21 19:30:32 dufuz Exp $
* @see Validate
* @access public
*/
@@ -152,13 +152,13 @@
* @param string $ean number (only numeric chars will be considered)
* @return bool true if number is valid, otherwise false
* @access public
- * @see Validate_ISPN::_process()
+ * @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
function ean8($ean)
{
static $weights_ean8 = array(3,1,3,1,3,1,3);
- return Validate_ISPN::_process($ean, 8, $weights_ean8);
+ return Validate_ISPN::process($ean, 8, $weights_ean8, 10, 10);
}
/**
@@ -172,13 +172,13 @@
* @param string $ean number (only numeric chars will be considered)
* @return bool true if number is valid, otherwise false
* @access public
- * @see Validate_ISPN::_process()
+ * @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
function ean13($ean)
{
static $weights_ean13 = array(1,3,1,3,1,3,1,3,1,3,1,3);
- return Validate_ISPN::_process($ean, 13, $weights_ean13);
+ return Validate_ISPN::process($ean, 13, $weights_ean13, 10, 10);
}
/**
@@ -192,13 +192,13 @@
* @param string $ean number (only numeric chars will be considered)
* @return bool true if number is valid, otherwise false
* @access public
- * @see Validate_ISPN::_process()
+ * @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
function ean14($ean)
{
static $weights_ean14 = array(3,1,3,1,3,1,3,1,3,1,3,1,3);
- return Validate_ISPN::_process($ean, 14, $weights_ean14);
+ return Validate_ISPN::process($ean, 14, $weights_ean14, 10, 10);
}
/**
@@ -212,13 +212,13 @@
* @param string $ucc number (only numeric chars will be considered)
* @return bool true if number is valid, otherwise false
* @access public
- * @see Validate_ISPN::_process()
+ * @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
function ucc12($ucc)
{
static $weights_ucc12 = array(3,1,3,1,3,1,3,1,3,1,3);
- return Validate_ISPN::_process($ucc, 12, $weights_ucc12);
+ return Validate_ISPN::process($ucc, 12, $weights_ucc12, 10, 10);
}
/**
@@ -232,26 +232,29 @@
* @param string $sscc number (only numeric chars will be considered)
* @return bool true if number is valid, otherwise false
* @access public
- * @see Validate_ISPN::_process()
+ * @see Validate_ISPN::process()
* @author Piotr Klaban <makler@man.torun.pl>
*/
function sscc($sscc)
{
static $weights_sscc = array(3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3);
- return Validate_ISPN::_process($sscc, 18, $weights_sscc);
+ return Validate_ISPN::process($sscc, 18, $weights_sscc, 10, 10);
}
/**
* Does all the work for EAN8, EAN13, EAN14, UCC12 and SSCC
+ * and can be used for as base for similar kind of calculations
*
* @param int $data number (only numeric chars will be considered)
* @param int $lenght required length of number string
+ * @param int $modulo (optionsl) number
+ * @param int $subtract (optional) numbier
* @param array $weights holds the weight that will be used in calculations for the validation
* @return bool true if number is valid, otherwise false
- * @access private
+ * @access public
* @see Validate::_checkControlNumber()
*/
- function _process($data, $length, &$weights)
+ function process($data, $length, &$weights, $modulo = 10, $subtract = 0)
{
//$weights = array(3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3);
//$weights = array_slice($weights, 0, $length);
@@ -263,7 +266,7 @@
return false;
}
- return Validate::_checkControlNumber($data, $weights, 10, 10);
+ return Validate::_checkControlNumber($data, $weights, $modulo, $subtract);
}
}
?>
\ No newline at end of file