From ce8b3466ffefe1da3d9e6ad35c53a41fec8ebc09 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 13 Jan 2022 21:41:27 +0000 Subject: [PATCH] refactor: simplify the "is host" logic --- tests/FakeEventRepository.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/FakeEventRepository.php b/tests/FakeEventRepository.php index e80d4d3..232cd01 100644 --- a/tests/FakeEventRepository.php +++ b/tests/FakeEventRepository.php @@ -11,18 +11,18 @@ use Tightenco\Collect\Support\Collection; final class FakeEventRepository implements EventRepository { private static array $rsvps = [ - ['name' => 'Oliver Davies.', 'response' => RsvpResponse::RESPONSE_YES, 'member' => ['event_context' => ['host' => true]]], - ['name' => 'matthew s.', 'response' => RsvpResponse::RESPONSE_YES, 'member' => ['event_context' => ['host' => false]]], - ['name' => 'Michael P.', 'response' => RsvpResponse::RESPONSE_YES, 'member' => ['event_context' => ['host' => false]]], - ['name' => 'Kathryn "Kat" R.', 'response' => RsvpResponse::RESPONSE_YES, 'member' => ['event_context' => ['host' => false]]], - ['name' => 'Did not attend', 'response' => RsvpResponse::RESPONSE_NO, 'member' => ['event_context' => ['host' => false]]], + ['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], ]; public function getConfirmedAttendees(): Collection { return Collection::make(self::$rsvps) ->filter(fn (array $attendee): bool => $attendee['response'] == RsvpResponse::RESPONSE_YES) - ->filter(fn (array $attendee): bool => !$attendee['member']['event_context']['host']) + ->filter(fn (array $attendee): bool => !$attendee['is_host']) ; } }