Beispiel #1
0
 /**
  * Check to see if the specification is satisfied
  *
  * @param Isbn $isbn
  * @param $organization
  * @return bool
  */
 public function isSatisfiedBy(Isbn $isbn, $organization = null)
 {
     if (!$organization instanceof Organization) {
         throw new \InvalidArgumentException($organization . ' must be of type Organization');
     }
     if (!$this->repository->bookOfIsbn($organization, $isbn)) {
         return true;
     }
     return false;
 }
 /**
  * @test
  * @group bookrepo
  */
 public function should_return_null_when_book_of_isbn_not_found()
 {
     $isbn = new Isbn('9788879116190');
     $klimtoren = $this->getKlimtoren();
     $book = $this->bookRepo->bookOfIsbn($klimtoren, $isbn);
     $this->assertNull($book);
 }
Beispiel #3
0
 /**
  * Updates an existing book
  *
  * @param $id
  * @param $data
  * @return Book
  * @throws BookNotFoundException
  */
 public function update($id, $data)
 {
     $name = $this->nameIsRequired($data);
     $isbn = $this->isbnIsRequired($data);
     $book = $this->bookRepo->bookOfId($id);
     if (!$book) {
         throw new BookNotFoundException($id);
     }
     $book->setName($name);
     $book->setIsbn($isbn);
     $this->setDescription($data, $book);
     $this->setAgeRange($data, $book);
     $this->addImage($data, $book);
     $this->syncAuthors($data, $book);
     $this->syncPublishers($data, $book);
     $this->syncTags($data, $book);
     $this->bookRepo->update($book);
     return $book;
 }