diff --git a/src/Constrict/ConstrictRequest.php b/src/Constrict/ConstrictRequest.php index 4349252..fd34a80 100644 --- a/src/Constrict/ConstrictRequest.php +++ b/src/Constrict/ConstrictRequest.php @@ -501,4 +501,33 @@ class ConstrictRequest extends Message implements RequestInterface, ServerReques // TODO: Implement withoutAttribute() method. return $this; } + + + /** + * @return int + */ + public function offset(): int + { + $params = $this->getQueryParams(); + $page = (int)($params['page'] ?? 1); + $size = $this->size(); + if ($page < 1) { + $page = 1; + } + return ($size - $page) * $page; + } + + + /** + * @return int + */ + public function size(): int + { + $params = $this->getQueryParams(); + $size = (int)($params['size'] ?? 1); + if ($size < 1) { + $size = 1; + } + return $size; + } } diff --git a/src/Request.php b/src/Request.php index 187189b..400f2a0 100644 --- a/src/Request.php +++ b/src/Request.php @@ -776,4 +776,22 @@ class Request implements ServerRequestInterface // TODO: Implement withoutAttribute() method. return $this->__call__(__FUNCTION__, $name); } + + + /** + * @return int + */ + public function offset(): int + { + return $this->__call__(__FUNCTION__); + } + + + /** + * @return int + */ + public function size(): int + { + return $this->__call__(__FUNCTION__); + } }