Count the number of events from talks

This commit is contained in:
Oliver Davies 2021-08-25 01:11:57 +01:00
parent 5048781ae3
commit 92f3865ee7
3 changed files with 51 additions and 5 deletions

View file

@ -17,10 +17,16 @@ final class TalkExtension extends AbstractExtension
];
}
public function getPastTalkCount(array $talks = []): int
public function getPastTalkCount(iterable $talks = []): int
{
return $this->getEventsFromTalks($talks)->count();
}
private function getEventsFromTalks(iterable $talks): Collection
{
$talkCollection = new Collection($talks);
return $talkCollection->count();
return $talkCollection
->flatMap(fn($talk): array => (array) $talk['events']);
}
}