for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Cecil/Cecil package.
*
* Copyright (c) Arnaud Ligny <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cecil\Collection\Page;
use Cecil\Collection\Collection as CecilCollection;
* Class Collection.
class Collection extends CecilCollection
{
* Returns all non virtual pages.
* @return self
public function all(): self
$filteredPages = $this->filter(function (Page $page) {
if ($page->isVirtual() === false) {
return true;
}
});
return $filteredPages;
* Sorts pages by date: the most recent first.
public function sortByDate(): self
return $this->usort(function ($a, $b) {
if ($a['date'] == $b['date']) {
return 0;
return ($a['date'] > $b['date']) ? -1 : 1;
* Sorts pages by title (natural sort).
public function sortByTitle(): self
return strnatcmp($a['title'], $b['title']);
* Sorts by weight (the heaviest first).
public function sortByWeight(): self
if ($a['weight'] == $b['weight']) {
return ($a['weight'] < $b['weight']) ? -1 : 1;