chore: Increase PHPStan to level 6 [ci skip]
This commit is contained in:
parent
e15b317d09
commit
b924e51103
|
@ -1,4 +1,4 @@
|
|||
parameters:
|
||||
level: 5
|
||||
level: 6
|
||||
paths:
|
||||
- src
|
||||
|
|
|
@ -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<TKey, TValue>
|
||||
*/
|
||||
public function getEvents(): self
|
||||
{
|
||||
return $this->flatMap(fn($talk): array => (array) $talk[self::KEY_EVENTS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self<TKey, TValue>
|
||||
*/
|
||||
public function onlyPastTalks(): self
|
||||
{
|
||||
$today = Carbon::today()->format(self::DATE_FORMAT);
|
||||
|
|
|
@ -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<int, TValue> $talks
|
||||
*/
|
||||
public function getPastTalkCount(iterable $talks = []): int
|
||||
{
|
||||
return $this->getEventsFromTalks($talks)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable<int, TValue> $talks
|
||||
*
|
||||
* @return TalkCollection<int, TValue>
|
||||
*/
|
||||
private function getEventsFromTalks(iterable $talks): TalkCollection
|
||||
{
|
||||
$talkCollection = new TalkCollection($talks);
|
||||
|
|
Loading…
Reference in a new issue