feat: refactoring and cleanup
This commit is contained in:
1 parent
230c53875f
commit
8c8aae9a1e
41 files changed
+2591
-2233
No files matched your search
@@ -182,4 +182,33 @@ abstract class AbstractParticipantFieldHandler implements ParticipantFieldHandle
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds an item by ID from an array of objects.
|
||||
*
|
||||
* Generic helper for validating a selected ID against an array of available
|
||||
* items and returning the matching object. Used by handlers that need to
|
||||
* validate service, pickup, or other selections against available options.
|
||||
*
|
||||
* @param mixed $selectedId The submitted ID to find (string or int)
|
||||
* @param object[] $items Array of objects with an `id` property
|
||||
*
|
||||
* @return object|null The matching item, or null if not found or invalid ID
|
||||
*/
|
||||
protected function findItemById(mixed $selectedId, array $items): ?object
|
||||
{
|
||||
if (null === $selectedId || (false === is_string($selectedId) && false === is_int($selectedId))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$id = (int) $selectedId;
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item->id === $id) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user