| Total Complexity | 9 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | class Collection extends CecilCollection |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * Returns all non virtual pages. |
||
| 22 | * |
||
| 23 | * @return self |
||
| 24 | */ |
||
| 25 | public function all(): self |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Sorts pages by date: the most recent first. |
||
| 38 | * |
||
| 39 | * @return self |
||
| 40 | */ |
||
| 41 | public function sortByDate(): self |
||
| 42 | { |
||
| 43 | return $this->usort(function ($a, $b) { |
||
| 44 | if ($a['date'] == $b['date']) { |
||
| 45 | return 0; |
||
| 46 | } |
||
| 47 | |||
| 48 | return ($a['date'] > $b['date']) ? -1 : 1; |
||
| 49 | }); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Sorts pages by title (natural sort). |
||
| 54 | * |
||
| 55 | * @return self |
||
| 56 | */ |
||
| 57 | public function sortByTitle(): self |
||
| 61 | }); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Sorts by weight (the heaviest first). |
||
| 66 | * |
||
| 67 | * @return self |
||
| 68 | */ |
||
| 69 | public function sortByWeight(): self |
||
| 77 | }); |
||
| 78 | } |
||
| 80 |