Count the number of events from talks
This commit is contained in:
parent
5048781ae3
commit
92f3865ee7
3 changed files with 51 additions and 5 deletions
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue