Refactor SettingsUpdateInformationField and PeerInformationManager to enhance UUID validation and improve error handling for property values

https://github.com/nosial/Socialbox-PHP/issues/68
This commit is contained in:
netkas 2025-03-12 14:22:19 -04:00
parent 2967c87990
commit d47251c251
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
2 changed files with 22 additions and 7 deletions

View file

@ -27,7 +27,8 @@
{
throw new MissingRpcArgumentException('field');
}
$fieldName = InformationFieldName::tryFrom(strtoupper($rpcRequest->getParameter('field')));
$fieldName = InformationFieldName::tryFrom(strtoupper((string)$rpcRequest->getParameter('field')));
if($fieldName === null)
{
throw new InvalidRpcArgumentException('field');
@ -38,11 +39,7 @@
{
throw new MissingRpcArgumentException('value');
}
$value = $rpcRequest->getParameter('value');
if(!$fieldName->validate($value))
{
throw new InvalidRpcArgumentException('value');
}
$value = (string)$rpcRequest->getParameter('value');
try
{