Skip to content

Commit

Permalink
Merge pull request #33 from bookboon/hotfix/prevent-incorrect-use
Browse files Browse the repository at this point in the history
Prevent performance issues in Book::getMultiple
  • Loading branch information
lkm committed Jan 31, 2019
2 parents 7d7965b + 4da169c commit e9df690
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Entity/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Bookboon\Api\Bookboon;
use Bookboon\Api\Client\BookboonResponse;
use Bookboon\Api\Client\ClientInterface;
use Bookboon\Api\Exception\UsageException;

class Book extends Entity
{
Expand Down Expand Up @@ -57,6 +58,11 @@ public static function getMultiple(
array $bookIds,
bool $extendedMetadata = false
) : BookboonResponse {
if (count($bookIds) === 0) {
throw new UsageException('At least one id is required for bookIds');
}


$variables = [
'id' => $bookIds,
'extendedMetadata' => $extendedMetadata ? 'true' : 'false'
Expand All @@ -79,6 +85,8 @@ public static function getMultiple(
* @param string $type
* @return BookboonResponse
* @throws \Bookboon\Api\Exception\UsageException
*
* @deprecated Shouln't be used for performance reasons
*/
public static function getAll(
Bookboon $bookboon,
Expand Down

0 comments on commit e9df690

Please sign in to comment.