Last active
January 13, 2023 21:37
-
-
Save BenSibley/a5daf1064480592dd7c4e7f6ffa4d4d2 to your computer and use it in GitHub Desktop.
Top Ten Pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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