using composer package format, decoupling bsr libraries and implementation

This commit is contained in:
Guillermo Dev
2018-10-09 21:17:41 +02:00
parent adb8552602
commit 1478569426
62 changed files with 1848 additions and 2187 deletions

View File

@@ -0,0 +1,16 @@
<?php
namespace BSR\Lib\Exception;
/**
* This exception should be raised when an error
* related to the authentication mechanism arise.
*
* @package BSR\Lib\Exception
*/
class AuthenticationException extends WebException {
const USER_NOT_FOUND = 200;
const BAD_LOGIN = 201;
const AUTHENTICATION_FAILED = 202;
const LOGIN_EMPTY = 203;
}

View File

@@ -0,0 +1,8 @@
<?php
namespace BSR\Lib\Exception;
/**
* Exception raised when an invalid attribute name is accessed
*/
class InvalidAttributeException extends \Exception { }

View File

@@ -0,0 +1,19 @@
<?php
namespace BSR\Lib\Exception;
class SqlException extends \Exception
{
private $query;
public function __construct($message = "Sql Error", $query = "")
{
$this->query = $query;
parent::__construct($message, 0);
}
public function getSqlError()
{
return $this->getMessage().' while executing: '.$this->query;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace BSR\Lib\Exception;
/**
* This exception should be raised by the WebService engine when
* there is an error preventing the correct calling of a method.
*
* @package BSR\Lib\Exception
*/
class UsageException extends WebException {
const NO_ARGS = 100;
const MISSING_METHOD = 101;
const BAD_METHOD = 102;
const TOO_FEW_ARGS = 103;
const TOO_MANY_ARGS = 104;
}

View File

@@ -0,0 +1,24 @@
<?php
namespace BSR\Lib\Exception;
class WebException extends \Exception
{
private $exceptionName;
/**
* @param string $name
* @param string $reason
* @param int $code
*/
function __construct($name, $reason, $code)
{
$this->exceptionName = $name;
parent::__construct($reason, $code);
}
public function getName()
{
return $this->exceptionName;
}
}