From 35c6293ff7fb430018716778b3486507a8d324ca Mon Sep 17 00:00:00 2001 From: Michael Albrecht Date: Tue, 24 Jan 2023 13:18:44 +0100 Subject: [PATCH] Refactor PersonNamePopulator fixture --- tests/Fixtures/Populator/PersonNamePopulator.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/Fixtures/Populator/PersonNamePopulator.php b/tests/Fixtures/Populator/PersonNamePopulator.php index 652ecc0..b04b77a 100644 --- a/tests/Fixtures/Populator/PersonNamePopulator.php +++ b/tests/Fixtures/Populator/PersonNamePopulator.php @@ -16,8 +16,17 @@ class PersonNamePopulator implements Populator { public function populate(object $target, object $source, ?object $ctx = null): void { - $separator = $ctx?->getValue('separator') ?? ' '; + $separator = ' '; + if ($ctx?->hasKey('separator')) { + $separator = $ctx->getValue('separator'); + } - $target->setFullName(implode($separator, [$source->getFirstname(), $source->getLastname()])); + $target->setFullName(implode( + $separator, + [ + $source->getFirstname(), + $source->getLastname() + ] + )); } }