Refactor PersonACLAwareRepository to simplify condition handling in search clause construction

- Replaced `count` check with an `empty` comparison for clarity.
- Streamlined conditional logic for search clause initialization.
- Removed unnecessary `isset` check before applying `andWhereClause`.
This commit is contained in:
2026-03-19 17:15:23 +01:00
parent 33e60377b5
commit 59d8bf75b2

View File

@@ -169,8 +169,10 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor
if (null !== $phonenumber) {
$personPhoneClause = "person.phonenumber LIKE '%' || ? || '%' OR person.mobilenumber LIKE '%' || ? || '%' OR EXISTS (SELECT 1 FROM chill_person_phone where person_id = person.id AND phonenumber LIKE '%' || ? || '%')";
if (count($andWhereSearchClauseArgs) > 0) {
if ([] !== $andWhereSearchClauseArgs) {
$initialSearchClause = '(('.\implode(' AND ', $andWhereSearchClause).') OR '.$personPhoneClause.')';
} else {
$initialSearchClause = $personPhoneClause;
}
$andWhereSearchClauseArgs = [...$andWhereSearchClauseArgs, $phonenumber, $phonenumber, $phonenumber];
@@ -181,12 +183,10 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor
$initialSearchClause = \implode(' AND ', $andWhereSearchClause);
}
if (isset($initialSearchClause)) {
$query->andWhereClause(
$initialSearchClause,
$andWhereSearchClauseArgs
);
}
$query->andWhereClause(
$initialSearchClause,
$andWhereSearchClauseArgs
);
$query
->setSelectPertinence(\implode(' + ', $pertinence), $pertinenceArgs);