cvs: pear /Validate package_ISPN.xml /Validate/Validate ISPN.php /Validate/tests product_numbers.phpt

From: Date: Sat, 12 Nov 2005 15:55:53 +0000
Subject: cvs: pear /Validate package_ISPN.xml /Validate/Validate ISPN.php /Validate/tests product_numbers.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36242@lists.php.net to get a copy of this message
dufuz Sat Nov 12 10:55:53 2005 EDT Modified files: /pear/Validate package_ISPN.xml /pear/Validate/Validate ISPN.php /pear/Validate/tests product_numbers.phpt Log: - ISRC (International Standard Recording Code) added by the courtesy of David Grant [david at grant dot org dot uk] - Update changelog and bump version http://cvs.php.net/diff.php/pear/Validate/package_ISPN.xml?r1=1.15&r2=1.16&ty=u Index: pear/Validate/package_ISPN.xml diff -u pear/Validate/package_ISPN.xml:1.15 pear/Validate/package_ISPN.xml:1.16 --- pear/Validate/package_ISPN.xml:1.15 Fri Nov 4 11:23:28 2005 +++ pear/Validate/package_ISPN.xml Sat Nov 12 10:55:51 2005 @@ -7,6 +7,7 @@ * ISSN * ISBN * ISMN + * ISRC (International Standard Recording Code) * EAN8 * EAN13 * EAN14 @@ -29,12 +30,13 @@ </maintainer> </maintainers> <release> - <version>0.5.1</version> + <version>0.6.0</version> <state>alpha</state> <date>2005-11-04</date> <notes> -- Switch to the new BSD License -(see http://www.opensource.org/licenses/bsd-license.php) +- ISRC (International Standard Recording Code) added by the courtesy of David Grant [david at grant dot org dot uk] +- ISBN13 added, the isbn() function is used at all times and will figure out if it should validate against isbn10 or isbn13 +- Piotr Klaban added as lead </notes> <filelist> <dir name="/"> @@ -53,15 +55,24 @@ </deps> </release> <changelog> - <release> - <version>0.5.0</version> - <state>alpha</state> - <date>2005-05-20</date> - <notes> + <release> + <version>0.5.1</version> + <state>alpha</state> + <date>2005-11-04</date> + <notes> +- Switch to the new BSD License +(see http://www.opensource.org/licenses/bsd-license.php) + </notes> + </release> + <release> + <version>0.5.0</version> + <state>alpha</state> + <date>2005-05-20</date> + <notes> - Split from Validate into independent package - CS fixes - Added product_numbers test (tests for ISSN, EAN8, EAN13, EAN14, UCC12 and SSCC) - </notes> + </notes> </release> </changelog> </package> http://cvs.php.net/diff.php/pear/Validate/Validate/ISPN.php?r1=1.10&r2=1.11&ty=u Index: pear/Validate/Validate/ISPN.php diff -u pear/Validate/Validate/ISPN.php:1.10 pear/Validate/Validate/ISPN.php:1.11 --- pear/Validate/Validate/ISPN.php:1.10 Tue Nov 8 03:17:19 2005 +++ pear/Validate/Validate/ISPN.php Sat Nov 12 10:55:53 2005 @@ -27,7 +27,7 @@ * @copyright 1997-2005 Piotr Klaban, Damien Seguy, Helgi Þormar Þorbjörnsson, * Pierre-Alain Joye * @license http://www.opensource.org/licenses/bsd-license.php new BSD - * @version CVS: $Id: ISPN.php,v 1.10 2005/11/08 08:17:19 makler Exp $ + * @version CVS: $Id: ISPN.php,v 1.11 2005/11/12 15:55:53 dufuz Exp $ * @link http://pear.php.net/package/Validate_ISPN */ @@ -38,6 +38,7 @@ * - ISBN (International Standard Book Number) * - ISSN (International Standard Serial Number) * - ISMN (International Standard Music Number) + * - ISRC (International Standard Recording Code) * - EAN/UCC-8 number * - EAN/UCC-13 number * - EAN/UCC-14 number @@ -48,7 +49,7 @@ * @package Validate_ISPN * @author Piotr Klaban <makler@man.torun.pl> * @author Damien Seguy <dams@nexen.net> - * @author Helgi Þormar Þorbjörnsson <dufuz@php.net> + * @author Helgi Þormar Þorbjönsson <dufuz@php.net> * @copyright 1997-2005 Piotr Klaban, Damien Seguy, Helgi Þormar Þorbjörnsson, * Pierre-Alain Joye * @license http://www.opensource.org/licenses/bsd-license.php new BSD @@ -217,6 +218,28 @@ return Validate::_checkControlNumber($ismn, $weights_ismn, 10, 10); } + /** + * Validate a ISRC (International Standard Recording Code) + * + * This function validates an International Standard Recording Code + * which is the international identification system for sound recordings + * and music videorecordings. + * + * @param string $isrc ISRC number + * @return bool true if number is valid, otherwise false + * @see http://www.ifpi.org/isrc/isrc_handbook.html + * @access public + * @author David Grant <david@grant.org.uk> + */ + function isrc($isrc) + { + $isrc = str_replace(array('ISRC', '-', ' '), '', strtoupper($isrc)); + if (!preg_match("/[A-Z]{2}[A-Z0-9]{3}[0-9]{7}/", $isrc)) { + return false; + } + + return true; + } /** * Validate a EAN/UCC-8 number http://cvs.php.net/diff.php/pear/Validate/tests/product_numbers.phpt?r1=1.4&r2=1.5&ty=u Index: pear/Validate/tests/product_numbers.phpt diff -u pear/Validate/tests/product_numbers.phpt:1.4 pear/Validate/tests/product_numbers.phpt:1.5 --- pear/Validate/tests/product_numbers.phpt:1.4 Wed Oct 19 01:17:15 2005 +++ pear/Validate/tests/product_numbers.phpt Sat Nov 12 10:55:53 2005 @@ -2,7 +2,7 @@ product_numbers.phpt: Unit tests for --FILE-- <?php -// $Id: product_numbers.phpt,v 1.4 2005/10/19 05:17:15 dufuz Exp $ +// $Id: product_numbers.phpt,v 1.5 2005/11/12 15:55:53 dufuz Exp $ // Validate test script $noYes = array('NO', 'YES'); @@ -82,6 +82,18 @@ 'M-345-24680-4', // NOK ); +$isrcs = array( + 'FR-Z03-98-00212', // OK + 'ISRC FR-Z03-98-00212', // OK + 'ISRC FR - Z03 - 98 - 00212', // OK + 'FR-Z03-91-01231', // OK + 'FR-Z03-91-01232', // OK + 'US-G34-04-25384', // OK + 'US-MR1-63-10018', // OK + '34-234-34-12312', // NOK + 'US-MR1-HE-ASDFG', // NOK +); + echo "\nTest UCC12\n"; foreach ($ucc12s as $ucc12) { echo "{$ucc12} : ".$noYes[Validate_ISPN::ucc12($ucc12)]."\n"; @@ -121,6 +133,11 @@ foreach ($ismns as $ismn) { echo "{$ismn} : ".$noYes[Validate_ISPN::ismn($ismn)]."\n"; } + +echo "\nTest ISRC\n"; +foreach ($isrcs as $isrc) { + echo "{$isrc} : ".$noYes[Validate_ISPN::isrc($isrc)]."\n"; +} ?> --EXPECT-- Test Validate_ISPN @@ -181,3 +198,14 @@ M-345-24680-5 : YES 2-345-24680-5 : NO M-345-24680-4 : NO + +Test ISRC +FR-Z03-98-00212 : YES +ISRC FR-Z03-98-00212 : YES +ISRC FR - Z03 - 98 - 00212 : YES +FR-Z03-91-01231 : YES +FR-Z03-91-01232 : YES +US-G34-04-25384 : YES +US-MR1-63-10018 : YES +34-234-34-12312 : NO +US-MR1-HE-ASDFG : NO \ No newline at end of file

« previous php.pear.cvs (#36242) next »