示例#1
0
文件: ISBNTest.php 项目: tillk/vufind
 /**
  * Test Invalid ISBN-10.
  *
  * @return void
  */
 public function testInvalidISBN10()
 {
     // Invalid ISBN-10:
     $isbn = new ISBN('2314346323');
     $this->assertFalse($isbn->get10());
     $this->assertFalse($isbn->get13());
     $this->assertFalse($isbn->isValid());
 }
示例#2
0
 /**
  * Return the first valid ISBN found in the record (favoring ISBN-10 over
  * ISBN-13 when possible).
  *
  * @return mixed
  */
 public function getCleanISBN()
 {
     // Get all the ISBNs and initialize the return value:
     $isbns = $this->getISBNs();
     $isbn13 = false;
     // Loop through the ISBNs:
     foreach ($isbns as $isbn) {
         // Strip off any unwanted notes:
         if ($pos = strpos($isbn, ' ')) {
             $isbn = substr($isbn, 0, $pos);
         }
         // If we find an ISBN-10, return it immediately; otherwise, if we find
         // an ISBN-13, save it if it is the first one encountered.
         $isbnObj = new ISBN($isbn);
         if ($isbn10 = $isbnObj->get10()) {
             return $isbn10;
         }
         if (!$isbn13) {
             $isbn13 = $isbnObj->get13();
         }
     }
     return $isbn13;
 }