| @@ 286-304 (lines=19) @@ | ||
| 283 | * @throws InvalidArgumentException If the parameter is not numeric or < 0. |
|
| 284 | * @return Pagination (Chainable) |
|
| 285 | */ |
|
| 286 | public function setPage($page) |
|
| 287 | { |
|
| 288 | if (!is_numeric($page)) { |
|
| 289 | throw new InvalidArgumentException( |
|
| 290 | 'Page number needs to be numeric.' |
|
| 291 | ); |
|
| 292 | } |
|
| 293 | ||
| 294 | $page = (int)$page; |
|
| 295 | if ($page < 0) { |
|
| 296 | throw new InvalidArgumentException( |
|
| 297 | 'Page number needs to be >= 0.' |
|
| 298 | ); |
|
| 299 | } |
|
| 300 | ||
| 301 | $this->page = $page; |
|
| 302 | ||
| 303 | return $this; |
|
| 304 | } |
|
| 305 | ||
| 306 | /** |
|
| 307 | * @return integer |
|
| @@ 319-338 (lines=20) @@ | ||
| 316 | * @throws InvalidArgumentException If the parameter is not numeric or < 0. |
|
| 317 | * @return Pagination (Chainable) |
|
| 318 | */ |
|
| 319 | public function setNumPerPage($num) |
|
| 320 | { |
|
| 321 | if (!is_numeric($num)) { |
|
| 322 | throw new InvalidArgumentException( |
|
| 323 | 'Num-per-page needs to be numeric.' |
|
| 324 | ); |
|
| 325 | } |
|
| 326 | ||
| 327 | $num = (int)$num; |
|
| 328 | ||
| 329 | if ($num < 0) { |
|
| 330 | throw new InvalidArgumentException( |
|
| 331 | 'Num-per-page needs to be >= 0.' |
|
| 332 | ); |
|
| 333 | } |
|
| 334 | ||
| 335 | $this->numPerPage = $num; |
|
| 336 | ||
| 337 | return $this; |
|
| 338 | } |
|
| 339 | ||
| 340 | /** |
|
| 341 | * @return integer |
|