diff --git a/phpstan.neon b/phpstan.neon index c839c3fa..db37782f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 5 + level: 6 paths: - src diff --git a/src/Collection/TalkCollection.php b/src/Collection/TalkCollection.php index 7389990f..a4e31795 100644 --- a/src/Collection/TalkCollection.php +++ b/src/Collection/TalkCollection.php @@ -7,17 +7,27 @@ namespace App\Collection; use Carbon\Carbon; use Illuminate\Support\Collection; +/** + * @template TKey of array-key + * @template TValue + */ final class TalkCollection extends Collection { private const DATE_FORMAT = 'Y-m-d'; private const KEY_EVENTS = 'events'; private const KEY_EVENT_DATE = 'date'; + /** + * @return self + */ public function getEvents(): self { return $this->flatMap(fn($talk): array => (array) $talk[self::KEY_EVENTS]); } + /** + * @return self + */ public function onlyPastTalks(): self { $today = Carbon::today()->format(self::DATE_FORMAT); diff --git a/src/TwigExtension/TalkExtension.php b/src/TwigExtension/TalkExtension.php index 0c538b39..a300e771 100644 --- a/src/TwigExtension/TalkExtension.php +++ b/src/TwigExtension/TalkExtension.php @@ -9,6 +9,10 @@ use Illuminate\Support\Collection; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; +/** + * @template TKey of array-key + * @template TValue + */ final class TalkExtension extends AbstractExtension { public function getFunctions() @@ -19,6 +23,9 @@ final class TalkExtension extends AbstractExtension ]; } + /** + * @param TValue $talk + */ public function getLastEventDate($talk): ?string { $events = new Collection($talk['events']); @@ -26,11 +33,19 @@ final class TalkExtension extends AbstractExtension return $events->pluck('date')->sort()->last(); } + /** + * @param iterable $talks + */ public function getPastTalkCount(iterable $talks = []): int { return $this->getEventsFromTalks($talks)->count(); } + /** + * @param iterable $talks + * + * @return TalkCollection + */ private function getEventsFromTalks(iterable $talks): TalkCollection { $talkCollection = new TalkCollection($talks);