feat: shows popular movies

This commit is contained in:
2025-04-25 16:42:57 -05:00
parent 7270fa2936
commit 0120ddcedd
4 changed files with 18 additions and 12 deletions

View File

@@ -94,12 +94,18 @@ class Tmdb
$this->tvRepository = new TvRepository($this->client);
}
public function popularMovies(int $page = 1)
public function popularMovies(int $page = 1, ?int $limit = null)
{
$movies = $this->movieRepository->getPopular(['page' => $page]);
foreach ($movies as $movie) {
$this->parseResult($movie);
$movies = $movies->map(function ($movie) use ($movies) {
return $this->parseResult($movies[$movie], "movie");
});
$movies = array_values($movies->toArray());
if (null !== $limit) {
$movies = array_slice($movies, 0, $limit);
}
return $movies;