From a02a765f11f8b63ab7379f732741fb87dd66c1a2 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 29 Jan 2025 15:25:22 -0500 Subject: [PATCH] Updated method getField() to return null instead of an exception if the requested record was not found --- src/Socialbox/Managers/PeerInformationManager.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Socialbox/Managers/PeerInformationManager.php b/src/Socialbox/Managers/PeerInformationManager.php index f529b19..1cbe88f 100644 --- a/src/Socialbox/Managers/PeerInformationManager.php +++ b/src/Socialbox/Managers/PeerInformationManager.php @@ -171,10 +171,10 @@ * * @param string|PeerRecord $peerUuid The UUID of the peer to get the property from. * @param InformationFieldName $property The name of the property to get. - * @return PeerInformationFieldRecord + * @return PeerInformationFieldRecord|null The property record, or null if it does not exist. * @throws DatabaseOperationException Thrown if the operation fails. */ - public static function getField(string|PeerRecord $peerUuid, InformationFieldName $property): PeerInformationFieldRecord + public static function getField(string|PeerRecord $peerUuid, InformationFieldName $property): ?PeerInformationFieldRecord { if($peerUuid instanceof PeerRecord) { @@ -192,7 +192,7 @@ $result = $stmt->fetch(); if($result === false) { - throw new DatabaseOperationException(sprintf('Property %s does not exist for peer %s', $property->value, $peerUuid)); + return null; } return PeerInformationFieldRecord::fromArray($result);