Skip to content

Commit

Permalink
Merge pull request #24 from superchlastac/master
Browse files Browse the repository at this point in the history
Added throw message if the page is out of range
  • Loading branch information
thorewi authored Aug 4, 2022
2 parents e8c15ef + c6b6ed6 commit c75254a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/PageIsOutOfRangeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace ADT\DoctrineComponents;

class PageIsOutOfRangeException extends \Exception
{

}
5 changes: 5 additions & 0 deletions src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public function getPaginator(): Paginator
$paginator->setPage($this->page);
$paginator->setItemsPerPage($this->itemsPerPage);

if ($paginator->getPage() !== $this->page)
{
throw new PageIsOutOfRangeException('Page number is out of range. Page number '.$this->page . ' is not in the range ('.$paginator->getFirstPage().', '.$paginator->getLastPage().')');
}

return $this->paginator = $paginator;
}

Expand Down

0 comments on commit c75254a

Please sign in to comment.