96 lines
3.7 KiB
PHP
Executable File
96 lines
3.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\core;
|
|
Class DVC
|
|
{
|
|
public static string $nameOfResponsePackage = "response_package";
|
|
|
|
public static string $successName = "Success";
|
|
public static string $genericExceptionName = "GenericErrorException";
|
|
public static string $invalidTokenName = "InvalidTokenException";
|
|
public static string $invalidRequestName = "InvalidRequestException";
|
|
public static string $invalidCurlStructureName = "InvalidCurlStructureException";
|
|
public static string $invalidBodyName = "InvalidBodyException";
|
|
public static string $alreadyExistsName = "AlreadyExistsException";
|
|
public static string $userNotExistingName = "userNotExistingException";
|
|
public static string $fieldNotExistingName = "FieldNotExistingException";
|
|
public static string $pageNotFoundName = "pageNotfoundException";
|
|
public static string $forbiddenAccessName = "forbiddenAccessException";
|
|
public static string $serviceNotFoundName = "FieldNotFoundException";
|
|
|
|
public static string $returnCode = "returnCode";
|
|
public static string $returnMessage = "returnMessage";
|
|
|
|
public static int $successReturnCode = 460;
|
|
|
|
public static function getArrayResponse(string $name): array
|
|
{
|
|
return match ($name){
|
|
DVC::$successName => [
|
|
DVC::$returnCode => 460,
|
|
DVC::$returnMessage => "Operation done successfully"
|
|
],
|
|
DVC::$genericExceptionName => [
|
|
DVC::$returnCode => 461,
|
|
DVC::$returnMessage => "Internal Server Error"
|
|
],
|
|
DVC::$invalidTokenName => [
|
|
DVC::$returnCode => 462,
|
|
DVC::$returnMessage => "Unauthorized access"
|
|
],
|
|
DVC::$invalidRequestName => [
|
|
DVC::$returnCode => 463,
|
|
DVC::$returnMessage => "Service doesn't provide this type of request"
|
|
],
|
|
DVC::$invalidBodyName => [
|
|
DVC::$returnCode => 464,
|
|
DVC::$returnMessage => "Not valid parameters sent"
|
|
],
|
|
DVC::$alreadyExistsName => [
|
|
|
|
DVC::$returnCode => 465,
|
|
DVC::$returnMessage => "Field already existing"
|
|
],
|
|
DVC::$fieldNotExistingName => [
|
|
DVC::$returnCode => 466,
|
|
DVC::$returnMessage => "Field not existing anymore"
|
|
],
|
|
DVC::$invalidCurlStructureName => [
|
|
DVC::$returnCode => 467,
|
|
DVC::$returnMessage => "cURL class needs URL, request method and headers to run"
|
|
],
|
|
DVC::$userNotExistingName => [
|
|
DVC::$returnCode => 468,
|
|
DVC::$returnMessage => "User account doesn't exists"
|
|
],
|
|
DVC::$pageNotFoundName => [
|
|
DVC::$returnCode => 469,
|
|
DVC::$returnMessage => "Page not found"
|
|
],
|
|
DVC::$forbiddenAccessName => [
|
|
DVC::$returnCode => 470,
|
|
DVC::$returnMessage => "You are not authorised to access this page"
|
|
],
|
|
DVC::$serviceNotFoundName => [
|
|
DVC::$returnCode => 471,
|
|
DVC::$returnMessage => "Service not existing"
|
|
]
|
|
};
|
|
}
|
|
|
|
public static function getHttpCodeWithCode(int $code): int
|
|
{
|
|
return match ($code){
|
|
460 => 200,
|
|
461 => 500,
|
|
462 => 401,
|
|
463 => 405,
|
|
464 => 400,
|
|
465, 466 => 204,
|
|
467 => 409,
|
|
468, 469, 471 => 404,
|
|
470 => 403,
|
|
default => 100
|
|
};
|
|
}
|
|
} |