refactor: add RsvpResponse
This commit is contained in:
parent
aadb1e0176
commit
78841ad9d6
11
src/RsvpResponse.php
Normal file
11
src/RsvpResponse.php
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
final class RsvpResponse
|
||||||
|
{
|
||||||
|
public const RESPONSE_NO = 'no';
|
||||||
|
public const RESPONSE_YES = 'yes';
|
||||||
|
}
|
|
@ -5,20 +5,22 @@ declare(strict_types=1);
|
||||||
namespace App\Tests;
|
namespace App\Tests;
|
||||||
|
|
||||||
use App\EventRepository;
|
use App\EventRepository;
|
||||||
|
use App\RsvpResponse;
|
||||||
use Tightenco\Collect\Support\Collection;
|
use Tightenco\Collect\Support\Collection;
|
||||||
|
|
||||||
final class FakeEventRepository implements EventRepository
|
final class FakeEventRepository implements EventRepository
|
||||||
{
|
{
|
||||||
private static array $rsvps = [
|
private static array $rsvps = [
|
||||||
['name' => 'matthew s.', 'response' => 'yes'],
|
['name' => 'matthew s.', 'response' => RsvpResponse::RESPONSE_YES],
|
||||||
['name' => 'Michael P.', 'response' => 'yes'],
|
['name' => 'Michael P.', 'response' => RsvpResponse::RESPONSE_YES],
|
||||||
['name' => 'Kathryn "Kat" R.', 'response' => 'yes'],
|
['name' => 'Kathryn "Kat" R.', 'response' => RsvpResponse::RESPONSE_YES],
|
||||||
['name' => 'Did not attend', 'response' => 'no'],
|
['name' => 'Did not attend', 'response' => RsvpResponse::RESPONSE_NO],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getConfirmedAttendees(): Collection {
|
public function getConfirmedAttendees(): Collection {
|
||||||
return Collection::make(self::$rsvps)
|
return Collection::make(self::$rsvps)
|
||||||
->filter(fn (array $attendee): bool => $attendee['response'] == 'yes')
|
->filter(fn (array $attendee): bool => $attendee['response']
|
||||||
|
== RsvpResponse::RESPONSE_YES)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue