Major incomplete Change

This commit is contained in:
Omair Saleh
2019-02-14 11:43:19 +08:00
parent 771c52883f
commit 79131671bf
138 changed files with 2345 additions and 69018 deletions
@@ -0,0 +1,12 @@
<?php
namespace App\Classes\Modules\ControllerLogic\Exceptions;
use App\Classes\ValueObjects\Constants\HttpStatus;
final class AccessForbiddenException extends ServiceApiException {
public function __construct(?string $message = null) {
parent::__construct($message ?? 'A forbidden attempt to access protected resources was detected',
HttpStatus::ACCESS_FORBIDDEN);
}
}
@@ -0,0 +1,12 @@
<?php
namespace App\Classes\Modules\ControllerLogic\Exceptions;
use App\Classes\ValueObjects\Constants\HttpStatus;
final class AccessUnauthorisedException extends ServiceApiException {
public function __construct(?string $message = null) {
parent::__construct($message ?? 'An unauthorised attempt to access protected resources was detected',
HttpStatus::ACCESS_UNAUTHORISED);
}
}
@@ -0,0 +1,12 @@
<?php
namespace App\Classes\Modules\ControllerLogic\Exceptions;
use App\Classes\ValueObjects\Constants\HttpStatus;
final class InternalServerErrorException extends ServiceApiException {
public function __construct(?string $message = null) {
parent::__construct($message ?? 'An internal server error has occurred. Please check application logs for more information.',
HttpStatus::SERVER_ERROR);
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Classes\Modules\ControllerLogic\Exceptions;
use App\Classes\ValueObjects\Constants\HttpStatus;
final class MalformedRequestException extends ServiceApiException {
public function __construct(?string $message = null) {
parent::__construct($message ?? 'Unable to process the request as it is malformed', HttpStatus::BAD_REQUEST);
}
}
@@ -0,0 +1,12 @@
<?php
namespace App\Classes\Modules\ControllerLogic\Exceptions;
use App\Classes\ValueObjects\Constants\HttpStatus;
final class ResourceConflictException extends ServiceApiException {
public function __construct(?string $message = null) {
parent::__construct($message ?? 'Unable to create the requested resource as it already exists',
HttpStatus::RESOURCE_ALREADY_EXISTS);
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Classes\Modules\ControllerLogic\Exceptions;
use App\Classes\ValueObjects\Constants\HttpStatus;
final class ResourceNotFoundException extends ServiceApiException {
public function __construct(?string $message = null) {
parent::__construct($message ?? 'Unable to find the requested resource', HttpStatus::RESOURCE_NOT_FOUND);
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Classes\Modules\ControllerLogic\Exceptions;
use App\Classes\Exceptions\Common\ErrorException;
abstract class ServiceApiException extends ErrorException {
/** @var int */
private $httpStatusCode;
public function __construct(string $message, int $httpStatusCode = 500) {
parent::__construct($message, $httpStatusCode);
$this->httpStatusCode = $httpStatusCode;
}
/**
* @return int
*/
public function getHttpStatusCode(): int {
return $this->httpStatusCode;
}
}