From aadb1e0176ad6ba259bf808268452b162de78e10 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 13 Jan 2022 20:51:14 +0000 Subject: [PATCH] refactor: move RSVPs into a static property --- tests/FakeEventRepository.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/FakeEventRepository.php b/tests/FakeEventRepository.php index f082305..af4a378 100644 --- a/tests/FakeEventRepository.php +++ b/tests/FakeEventRepository.php @@ -9,15 +9,15 @@ use Tightenco\Collect\Support\Collection; final class FakeEventRepository implements EventRepository { - public function getConfirmedAttendees(): Collection { - $rsvps = Collection::make([ - ['name' => 'matthew s.', 'response' => 'yes'], - ['name' => 'Michael P.', 'response' => 'yes'], - ['name' => 'Kathryn "Kat" R.', 'response' => 'yes'], - ['name' => 'Did not attend', 'response' => 'no'], - ]); + private static array $rsvps = [ + ['name' => 'matthew s.', 'response' => 'yes'], + ['name' => 'Michael P.', 'response' => 'yes'], + ['name' => 'Kathryn "Kat" R.', 'response' => 'yes'], + ['name' => 'Did not attend', 'response' => 'no'], + ]; - return $rsvps + public function getConfirmedAttendees(): Collection { + return Collection::make(self::$rsvps) ->filter(fn (array $attendee): bool => $attendee['response'] == 'yes') ; }