fix test warning for undefined array key by using array_find

This commit is contained in:
Yisroel Baum 2026-02-21 21:09:08 +02:00
parent b3453a4604
commit 424d46104b
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 11 additions and 1 deletions

View file

@ -9,6 +9,11 @@ class Text
private string $name,
) {}
public function getId(): int
{
return $this->id;
}
public function getName(): string
{
return $this->name;

View file

@ -27,7 +27,12 @@ class FakeTextRepository implements TextRepository
public function find(int $id): ?Text
{
$text = $this->existingTexts[$id];
$text = array_find(
$this->existingTexts,
function (Text $text) use ($id){
return $text->getId() === $id;
}
);
if ($text === null) {
return null;
}