**Added**
- better exception handling with new class `SilentApiHandler`: to not raise any exception during API request but instead return an `ApiResponse` with errors
- version constant
- `ApiReponse` has new `errors()` and `hasError()` methods
This commit is contained in:
kristuff 2021-01-17 19:09:15 +01:00
commit 3c5c7155c2
7 changed files with 210 additions and 9 deletions

View file

@ -14,7 +14,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @version 0.9.8
* @version 0.9.9
* @copyright 2020-2021 Kristuff
*/
@ -32,6 +32,11 @@ class ApiHandler extends ApiBase
*/
use CurlTrait;
/**
* @var string $version
*/
const VERSION = 'v0.9.9';
/**
* The ips to remove from report messages
* Generally you will add to this list yours ipv4 and ipv6, hostname, domain names
@ -214,8 +219,8 @@ class ApiHandler extends ApiBase
public function check(string $ip, int $maxAgeInDays = 30, bool $verbose = false): ApiResponse
{
// max age must be less or equal to 365
if ($maxAgeInDays > 365 || $maxAgeInDays < 1){
throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365 (' . $maxAgeInDays . ' was given)');
if ( $maxAgeInDays > 365 || $maxAgeInDays < 1 ){
throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365.');
}
// ip must be set