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

28 lines
914 B
PHP
Raw Normal View History

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