From 5915df1b83c86f4fc31ad075e99e61ecd03433fc Mon Sep 17 00:00:00 2001 From: Clinton Graham Date: Mon, 16 Nov 2020 12:43:02 -0500 Subject: [PATCH] scriptotek#21: Add setter for pagination of SimplePaginatedList --- src/Model/SimplePaginatedList.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Model/SimplePaginatedList.php b/src/Model/SimplePaginatedList.php index 6f33e62..f9f9f6f 100644 --- a/src/Model/SimplePaginatedList.php +++ b/src/Model/SimplePaginatedList.php @@ -84,4 +84,19 @@ public function count() return $this->totalRecordCount; } + + /** + * Mutate the pagination limit + * + * @param int $limit Maximum number of items per page (0 - 100) + * @throws \RuntimeException + */ + public function setPaginationLimit($limit) + { + if ((int)$limit < 0 || (int)$limit > 100) { + throw new \RuntimeException('Invalid limit value (0 - 100): '.$limit); + } + $this->limit = (int) $limit; + } + }