Refactor AddressBookGetContacts and ContactManager to improve parameter validation and error handling

https://github.com/nosial/Socialbox-PHP/issues/34
This commit is contained in:
netkas 2025-03-11 19:14:58 -04:00
parent eadf1cd3a4
commit b29f3ed1e2
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
2 changed files with 10 additions and 18 deletions

View file

@ -7,6 +7,7 @@
use ncc\ThirdParty\Symfony\Uid\UuidV4;
use PDO;
use PDOException;
use Socialbox\Classes\Configuration;
use Socialbox\Classes\Cryptography;
use Socialbox\Classes\Database;
use Socialbox\Classes\Validator;
@ -317,12 +318,16 @@
{
if ($page < 1)
{
$page = 1;
throw new InvalidArgumentException('The page number cannot be less than 1');
}
if ($limit < 1)
{
$limit = 1;
throw new InvalidArgumentException('The limit cannot be less than 1');
}
elseif($limit > Configuration::getPoliciesConfiguration()->getGetContactsLimit())
{
throw new InvalidArgumentException('The limit cannot exceed a value of ' . Configuration::getPoliciesConfiguration()->getGetContactsLimit());
}
$contacts = [];