meetup-raffle-winner-picker/tests/Fake/FakeEventRepository.php

33 lines
1 KiB
PHP
Raw Normal View History

2022-01-13 20:13:28 +00:00
<?php
declare(strict_types=1);
2022-01-14 00:08:24 +00:00
namespace App\Tests\Fake;
2022-01-13 20:13:28 +00:00
use App\EventRepository;
2022-01-14 00:32:22 +00:00
use Illuminate\Support\Collection;
2022-01-13 20:13:28 +00:00
final class FakeEventRepository implements EventRepository
{
private static array $rsvps = [];
public function __construct()
{
self::$rsvps = [
(object) ['name' => 'Oliver Davies.', 'is_attending' => true, 'is_host' => true],
(object) ['name' => 'matthew s.', 'is_attending' => true, 'is_host' => false],
(object) ['name' => 'Michael P.', 'is_attending' => true, 'is_host' => false],
(object) ['name' => 'Kathryn "Kat" R.', 'is_attending' => true, 'is_host' => false],
(object) ['name' => 'Did not attend', 'is_attending' => false, 'is_host' => false],
];
}
2022-01-14 01:00:47 +00:00
public function findAttendeesForEvent(int $eventId): Collection
2022-01-13 21:43:23 +00:00
{
return Collection::make(self::$rsvps)
->filter(fn (\stdClass $attendee): bool => $attendee->is_attending)
->filter(fn (\stdClass $attendee): bool => !$attendee->is_host)
;
2022-01-13 20:13:28 +00:00
}
}