Refactor AddressBookGetContacts and ContactManager to improve parameter validation and error handling
https://github.com/nosial/Socialbox-PHP/issues/34
This commit is contained in:
parent
eadf1cd3a4
commit
b29f3ed1e2
2 changed files with 10 additions and 18 deletions
|
@ -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 = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue