This commit is contained in:
xl
2023-11-06 10:12:11 +08:00
parent 796676af48
commit b21db849fa
2 changed files with 47 additions and 0 deletions
+29
View File
@@ -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;
}
}
+18
View File
@@ -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__);
}
}