Example #1
0
 /**
  * Test Invalid ISBN-10.
  *
  * @return void
  */
 public function testInvalidISBN10()
 {
     // Invalid ISBN-10:
     $isbn = new ISBN('2314346323');
     $this->assertEquals($isbn->get10(), false);
     $this->assertEquals($isbn->get13(), false);
     $this->assertFalse($isbn->isValid());
 }
Example #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;
 }
Example #3
0
 /**
  * Retrieve a Summon cover.
  *
  * @param string $id Serials Solutions client key.
  *
  * @return bool      True if image displayed, false otherwise.
  */
 protected function summon($id)
 {
     // convert normalized 10 char isn to 13 digits
     $isn = $this->isn;
     if (strlen($isn) != 13) {
         $ISBN = new ISBN($isn);
         $isn = $ISBN->get13();
     }
     $url = 'http://api.summon.serialssolutions.com/image/isbn/' . $id . '/' . $isn . '/' . $this->size;
     return $this->processImageURL($url);
 }