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

30 lines
1 KiB
PHP
Raw Normal View History

2022-01-13 20:13:28 +00:00
<?php
declare(strict_types=1);
namespace App\Tests;
use App\EventRepository;
2022-01-13 20:54:29 +00:00
use App\RsvpResponse;
use Tightenco\Collect\Support\Collection;
2022-01-13 20:13:28 +00:00
final class FakeEventRepository implements EventRepository
{
private static array $rsvps = [
2022-01-13 21:41:27 +00:00
['name' => 'Oliver Davies.', 'response' => RsvpResponse::RESPONSE_YES, 'is_host' => true],
['name' => 'matthew s.', 'response' => RsvpResponse::RESPONSE_YES, 'is_host' => false],
['name' => 'Michael P.', 'response' => RsvpResponse::RESPONSE_YES, 'is_host' => false],
['name' => 'Kathryn "Kat" R.', 'response' => RsvpResponse::RESPONSE_YES, 'is_host' => false],
['name' => 'Did not attend', 'response' => RsvpResponse::RESPONSE_NO, 'is_host' => false],
];
2022-01-13 21:43:23 +00:00
public function getConfirmedAttendees(): Collection
{
return Collection::make(self::$rsvps)
2022-01-13 20:54:29 +00:00
->filter(fn (array $attendee): bool => $attendee['response']
== RsvpResponse::RESPONSE_YES)
2022-01-13 21:41:27 +00:00
->filter(fn (array $attendee): bool => !$attendee['is_host'])
;
2022-01-13 20:13:28 +00:00
}
}