Exemplo n.º 1
0
 /**
  * Setter for ISBN
  *
  * @param string $isbn ISBN Number
  *          this is a valid ISBN Number or it is an Empty string
  *          which will reset the class
  *
  * @return void
  *
  * @throws ISBN_Exception in case it fails
  *
  */
 function setISBN($isbn)
 {
     if ($isbn == '') {
         $this->ver = ISBN_VERSION_NONE;
         $this->isbn_group = '';
         $this->isbn_publisher = '';
         $this->isbn_title = '';
     } else {
         $isbnn = ISBN::_normaliseISBN($isbn);
         $ver = ISBN::_getVersion($isbnn);
         if ($ver === false) {
             return new ISBN_Exception('Invalid ISBN');
         }
         if ($ver != $this->ver && $this->ver !== ISBN_VERSION_NONE) {
             return new ISBN_Exception('ISBN Version of passed ISBN (' . $ver . ') ' . 'does not match existing (' . $this->ver . ').');
         } elseif ($this->ver === ISBN_VERSION_NONE) {
             $this->ver = $ver;
         }
         $body = ISBN::_extractISBNBody($isbnn);
         if ($body === false) {
             return new ISBN_Exception('Invalid ISBN (could not extract body)');
         }
         $e = $this->_setISBNBody($body);
         if ("ISBN_Exception" == get_class($e)) {
             return new ISBN_Exception('Invalid ISBN (invalid body "' . $body . '")', $e);
         }
     }
 }