public function testIsValid()
 {
     $ean13 = array('7310070030603', '7310070130402', '7310400021554', '7310400021561', '7310500078045', '4000339039029', '5000159382731');
     foreach ($ean13 as $e) {
         $x = new BarcodeEan13($e);
         $this->assertEquals($x->isValid(), true);
     }
 }
Beispiel #2
0
 /**
  * @return true if input is a valid ISBN-13 code (EAN-13)
  */
 static function isValid($s)
 {
     // XXX improve using regexp who matches on n-n-n-n-n  (always 5 numbers divided by -)
     $s = str_replace('-', '', $s);
     $s = trim($s);
     if (strlen($s) != 13 || !is_numeric($s)) {
         return false;
     }
     $ean13 = new BarcodeEan13($s);
     if (!$ean13->isValid()) {
         return false;
     }
     return true;
 }