Fix ::canBeReOpened.

1. Fix call to `::getOpenParticipationContainsPerson` instead of `::getParticipationsContainsPerson`.
2. Use early returns to reduce cyclomatic complexity.
3. Avoid storing variable that are used only once.
This commit is contained in:
Pol Dellaiera 2021-05-14 10:43:21 +02:00
parent a6e0b16032
commit 484259c8ab

View File

@ -435,15 +435,16 @@ class AccompanyingPeriod
return false;
}
$participation = $this->getParticipationsContainsPerson($person);
if (!null === $participation)
$participation = $this->getOpenParticipationContainsPerson($person);
if (null === $participation)
{
$person = $participation->getPerson();
$periods = $person->getAccompanyingPeriodsOrdered();
return end($periods) === $this;
return false;
}
return false;
$periods = $participation->getPerson()->getAccompanyingPeriodsOrdered();
return end($periods) === $this;
}
/**