| @@ 334-353 (lines=20) @@ | ||
| 331 | * @throws InvalidArgumentException If the parameter is not numeric or < 0. |
|
| 332 | * @return self |
|
| 333 | */ |
|
| 334 | public function setPage($page) |
|
| 335 | { |
|
| 336 | if (!is_numeric($page)) { |
|
| 337 | throw new InvalidArgumentException( |
|
| 338 | 'Page number needs to be numeric.' |
|
| 339 | ); |
|
| 340 | } |
|
| 341 | ||
| 342 | $page = (int)$page; |
|
| 343 | ||
| 344 | if ($page < 0) { |
|
| 345 | throw new InvalidArgumentException( |
|
| 346 | 'Page number needs to be >= 0.' |
|
| 347 | ); |
|
| 348 | } |
|
| 349 | ||
| 350 | $this->page = $page; |
|
| 351 | ||
| 352 | return $this; |
|
| 353 | } |
|
| 354 | ||
| 355 | /** |
|
| 356 | * Retrieve the widget's title. |
|
| @@ 511-530 (lines=20) @@ | ||
| 508 | * @throws InvalidArgumentException If the parameter is not numeric or < 0. |
|
| 509 | * @return self |
|
| 510 | */ |
|
| 511 | public function setNumPerPage($num) |
|
| 512 | { |
|
| 513 | if (!is_numeric($num)) { |
|
| 514 | throw new InvalidArgumentException( |
|
| 515 | 'Num-per-page needs to be numeric.' |
|
| 516 | ); |
|
| 517 | } |
|
| 518 | ||
| 519 | $num = (int)$num; |
|
| 520 | ||
| 521 | if ($num < 0) { |
|
| 522 | throw new InvalidArgumentException( |
|
| 523 | 'Num-per-page needs to be >= 0.' |
|
| 524 | ); |
|
| 525 | } |
|
| 526 | ||
| 527 | $this->numPerPage = $num; |
|
| 528 | ||
| 529 | return $this; |
|
| 530 | } |
|
| 531 | ||
| 532 | /** |
|
| 533 | * Retrieve the current widget's options as a JSON object. |
|