added Exception classes
implement Exceptions in the main class
This commit is contained in:
853
src/Client.php
853
src/Client.php
File diff suppressed because it is too large
Load Diff
13
src/Exceptions/CurlExtensionNotLoadedException.php
Executable file
13
src/Exceptions/CurlExtensionNotLoadedException.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class CurlExtensionNotLoadedException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The PHP curl extension is not loaded. Please correct this before proceeding!');
|
||||
}
|
||||
}
|
||||
42
src/Exceptions/CurlGeneralErrorException.php
Executable file
42
src/Exceptions/CurlGeneralErrorException.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class CurlGeneralErrorException extends Exception
|
||||
{
|
||||
/** @var mixed $_http_response_code */
|
||||
private $_http_response_code;
|
||||
|
||||
/** @var mixed $_curl_getinfo_results */
|
||||
private $_curl_getinfo_results;
|
||||
|
||||
public function __construct(string $message, $http_response_code, $_curl_getinfo_results)
|
||||
{
|
||||
$this->_http_response_code = $http_response_code;
|
||||
$this->_curl_getinfo_results = $_curl_getinfo_results;
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP response code.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getHttpResponseCode()
|
||||
{
|
||||
return $this->_http_response_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cURL curl_getinfo results.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCurlGetinfoResults()
|
||||
{
|
||||
return $this->_curl_getinfo_results;
|
||||
}
|
||||
}
|
||||
42
src/Exceptions/CurlTimeoutException.php
Executable file
42
src/Exceptions/CurlTimeoutException.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class CurlTimeoutException extends Exception
|
||||
{
|
||||
/** @var mixed $_http_response_code */
|
||||
private $_http_response_code;
|
||||
|
||||
/** @var mixed $_curl_getinfo_results */
|
||||
private $_curl_getinfo_results;
|
||||
|
||||
public function __construct(string $message, $http_response_code, $curl_getinfo_results)
|
||||
{
|
||||
$this->_http_response_code = $http_response_code;
|
||||
$this->_curl_getinfo_results = $curl_getinfo_results;
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP response code.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getHttpResponseCode()
|
||||
{
|
||||
return $this->_http_response_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cURL curl_getinfo results.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCurlGetinfoResults()
|
||||
{
|
||||
return $this->_curl_getinfo_results;
|
||||
}
|
||||
}
|
||||
13
src/Exceptions/EmailInvalidException.php
Executable file
13
src/Exceptions/EmailInvalidException.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class EmailInvalidException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('Invalid email address provided.');
|
||||
}
|
||||
}
|
||||
13
src/Exceptions/InvalidBaseUrlException.php
Executable file
13
src/Exceptions/InvalidBaseUrlException.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidBaseUrlException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The base URL provided is invalid.');
|
||||
}
|
||||
}
|
||||
13
src/Exceptions/InvalidCurlMethodException.php
Executable file
13
src/Exceptions/InvalidCurlMethodException.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidCurlMethodException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('Invalid cURL method provided.');
|
||||
}
|
||||
}
|
||||
13
src/Exceptions/InvalidSiteNameException.php
Executable file
13
src/Exceptions/InvalidSiteNameException.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidSiteNameException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('Invalid site name provided.');
|
||||
}
|
||||
}
|
||||
10
src/Exceptions/JsonDecodeException.php
Executable file
10
src/Exceptions/JsonDecodeException.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class JsonDecodeException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
10
src/Exceptions/LoginFailedException.php
Executable file
10
src/Exceptions/LoginFailedException.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class LoginFailedException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
13
src/Exceptions/LoginRequiredException.php
Executable file
13
src/Exceptions/LoginRequiredException.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class LoginRequiredException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('This method requires the API client to be logged in first.');
|
||||
}
|
||||
}
|
||||
10
src/Exceptions/MethodDeprecatedException.php
Executable file
10
src/Exceptions/MethodDeprecatedException.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace UniFi_API\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class MethodDeprecatedException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user