Skip to content

Commit

Permalink
Make Book entity abstract
Browse files Browse the repository at this point in the history
Signed-off-by: Lasse Mammen <[email protected]>
  • Loading branch information
lkm committed Jan 31, 2019
1 parent d62561e commit 9ccd486
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Entity/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Bookboon\Api\Client\BookboonResponse;
use Bookboon\Api\Client\ClientInterface;

class Book extends Entity
abstract class Book extends Entity
{
const _OWN_TYPE = '';

Expand Down Expand Up @@ -104,7 +104,7 @@ public static function getAll(
* @param array $objectArray
* @return Book
*/
private static function objectTransformer(array $objectArray)
public static function objectTransformer(array $objectArray)
{
$className = 'Bookboon\Api\Entity\\' . ucfirst($objectArray['_type']) . 'Book';
return new $className($objectArray);
Expand Down
3 changes: 1 addition & 2 deletions src/Entity/Exam.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,10 @@ public function getTimeSeconds()
* Return book to which the exam is related
*
* @return Book
* @throws \Bookboon\Api\Exception\EntityDataException
*/
public function getBook()
{
return new Book($this->safeGet('book', []));
return Book::objectTransformer($this->safeGet('book', []));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Entity/BookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testHasPdf()
*/
public function testInvalidBook()
{
$book = new Book(['blah']);
$book = new PdfBook(['blah']);
}

public function testBookDownloadOauth()
Expand Down

0 comments on commit 9ccd486

Please sign in to comment.