Skip to content

Instantly share code, notes, and snippets.

@BenSibley
Last active January 13, 2023 21:37
Show Gist options
  • Save BenSibley/a5daf1064480592dd7c4e7f6ffa4d4d2 to your computer and use it in GitHub Desktop.
Save BenSibley/a5daf1064480592dd7c4e7f6ffa4d4d2 to your computer and use it in GitHub Desktop.
Top Ten Pages
namespace IAWP;
function get_top_ten() : array
{
$start = new \DateTime('30 days ago');
$top_ten = [];
$query = new Resources([
'start' => $start
]);
$data = array_slice($query->fetch(), 0, 10);
$top_ten = array_map(function ($row, $index){
return [
'title' => $row->title(),
'views' => $row->views(),
];
}, $data, array_keys($data));
return $top_ten;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment