diff --git a/src/ncc/Enums/ExceptionCodes.php b/src/ncc/Enums/ExceptionCodes.php index e9a8bc5..c358582 100644 --- a/src/ncc/Enums/ExceptionCodes.php +++ b/src/ncc/Enums/ExceptionCodes.php @@ -26,98 +26,80 @@ * @author Zi Xing Narrakas * @copyright Copyright (C) 2022-2023. Nosial - All Rights Reserved. */ - final class ExceptionCodes + enum ExceptionCodes : int { /** * @see RuntimeException */ - public const RUNTIME = -1706; + case RUNTIME = -1706; /** * @see BuildException */ - public const BUILD_EXCEPTION = -1727; + case BUILD_EXCEPTION = -1727; /** * @see IOException */ - public const IO_EXCEPTION = -1735; + case IO_EXCEPTION = -1735; /** * @see ComposerException */ - public const COMPOSER_EXCEPTION = -1749; + case COMPOSER_EXCEPTION = -1749; /** * @see AuthenticationException */ - public const AUTHENTICATION_EXCEPTION = -1760; + case AUTHENTICATION_EXCEPTION = -1760; /** * @see NotSupportedException */ - public const NOT_SUPPORTED_EXCEPTION = -1761; + case NOT_SUPPORTED_EXCEPTION = -1761; /** * @see ArchiveException */ - public const ARCHIVE_EXCEPTION = -1764; + case ARCHIVE_EXCEPTION = -1764; /** * @see PathNotFoundException */ - public const PATH_NOT_FOUND = -1769; + case PATH_NOT_FOUND = -1769; /** * @see GitException */ - public const GIT_EXCEPTION = -1770; + case GIT_EXCEPTION = -1770; /** * @see ConfigurationException */ - public const CONFIGURATION_EXCEPTION = -1772; + case CONFIGURATION_EXCEPTION = -1772; /** * @see PackageException */ - public const PACKAGE_EXCEPTION = -1773; + case PACKAGE_EXCEPTION = -1773; /** * @see NetworkException */ - public const NETWORK_EXCEPTION = -1774; + case NETWORK_EXCEPTION = -1774; /** * @see IntegrityException */ - public const INTEGRITY_EXCEPTION = -1775; + case INTEGRITY_EXCEPTION = -1775; /** * @see OperationException */ - public const OPERATION_EXCEPTION = -1776; - - public const IMPORT_EXCEPTION = -1777; + case OPERATION_EXCEPTION = -1776; /** - * All the exception codes from NCC + * @see ImportException */ - public const All = [ - self::RUNTIME, - self::BUILD_EXCEPTION, - self::IO_EXCEPTION, - self::COMPOSER_EXCEPTION, - self::AUTHENTICATION_EXCEPTION, - self::NOT_SUPPORTED_EXCEPTION, - self::ARCHIVE_EXCEPTION, - self::PATH_NOT_FOUND, - self::GIT_EXCEPTION, - self::CONFIGURATION_EXCEPTION, - self::PACKAGE_EXCEPTION, - self::NETWORK_EXCEPTION, - self::INTEGRITY_EXCEPTION, - self::OPERATION_EXCEPTION, - self::IMPORT_EXCEPTION - ]; + case IMPORT_EXCEPTION = -1777; } \ No newline at end of file diff --git a/src/ncc/Exceptions/ArchiveException.php b/src/ncc/Exceptions/ArchiveException.php index 4ecfd0a..1f8bcd3 100644 --- a/src/ncc/Exceptions/ArchiveException.php +++ b/src/ncc/Exceptions/ArchiveException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::ARCHIVE_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::ARCHIVE_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/AuthenticationException.php b/src/ncc/Exceptions/AuthenticationException.php index 0a1c79d..099ac17 100644 --- a/src/ncc/Exceptions/AuthenticationException.php +++ b/src/ncc/Exceptions/AuthenticationException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::AUTHENTICATION_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::AUTHENTICATION_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/BuildException.php b/src/ncc/Exceptions/BuildException.php index 4e88a09..9d11954 100644 --- a/src/ncc/Exceptions/BuildException.php +++ b/src/ncc/Exceptions/BuildException.php @@ -34,6 +34,6 @@ namespace ncc\Exceptions; */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::BUILD_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::BUILD_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/ComposerException.php b/src/ncc/Exceptions/ComposerException.php index d279686..35b85e1 100644 --- a/src/ncc/Exceptions/ComposerException.php +++ b/src/ncc/Exceptions/ComposerException.php @@ -34,6 +34,6 @@ namespace ncc\Exceptions; */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::COMPOSER_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::COMPOSER_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/ConfigurationException.php b/src/ncc/Exceptions/ConfigurationException.php index 87ef8b9..58e5e93 100644 --- a/src/ncc/Exceptions/ConfigurationException.php +++ b/src/ncc/Exceptions/ConfigurationException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::CONFIGURATION_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::CONFIGURATION_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/GitException.php b/src/ncc/Exceptions/GitException.php index cc6dc7e..3305ddf 100644 --- a/src/ncc/Exceptions/GitException.php +++ b/src/ncc/Exceptions/GitException.php @@ -30,6 +30,6 @@ { public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::GIT_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::GIT_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/IOException.php b/src/ncc/Exceptions/IOException.php index 2e08b2d..eb68822 100644 --- a/src/ncc/Exceptions/IOException.php +++ b/src/ncc/Exceptions/IOException.php @@ -34,6 +34,6 @@ namespace ncc\Exceptions; */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::IO_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::IO_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/ImportException.php b/src/ncc/Exceptions/ImportException.php index 2595198..1e3daa3 100644 --- a/src/ncc/Exceptions/ImportException.php +++ b/src/ncc/Exceptions/ImportException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::IMPORT_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::IMPORT_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/IntegrityException.php b/src/ncc/Exceptions/IntegrityException.php index d2e7765..bc6435d 100644 --- a/src/ncc/Exceptions/IntegrityException.php +++ b/src/ncc/Exceptions/IntegrityException.php @@ -30,6 +30,6 @@ { public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::INTEGRITY_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::INTEGRITY_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/NetworkException.php b/src/ncc/Exceptions/NetworkException.php index 9967df5..f91b331 100644 --- a/src/ncc/Exceptions/NetworkException.php +++ b/src/ncc/Exceptions/NetworkException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::NETWORK_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::NETWORK_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/NotSupportedException.php b/src/ncc/Exceptions/NotSupportedException.php index 65cb77d..bd686e7 100644 --- a/src/ncc/Exceptions/NotSupportedException.php +++ b/src/ncc/Exceptions/NotSupportedException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::NOT_SUPPORTED_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::NOT_SUPPORTED_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/OperationException.php b/src/ncc/Exceptions/OperationException.php index b0ba020..8c2ff15 100644 --- a/src/ncc/Exceptions/OperationException.php +++ b/src/ncc/Exceptions/OperationException.php @@ -30,6 +30,6 @@ { public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::OPERATION_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::OPERATION_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/PackageException.php b/src/ncc/Exceptions/PackageException.php index edbfda4..2c08952 100644 --- a/src/ncc/Exceptions/PackageException.php +++ b/src/ncc/Exceptions/PackageException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::PACKAGE_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::PACKAGE_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/PathNotFoundException.php b/src/ncc/Exceptions/PathNotFoundException.php index 25b8d96..1802f5f 100644 --- a/src/ncc/Exceptions/PathNotFoundException.php +++ b/src/ncc/Exceptions/PathNotFoundException.php @@ -41,7 +41,7 @@ */ public function __construct(string $path, ?Throwable $previous = null) { - parent::__construct(sprintf('Path "%s" not found', $path), ExceptionCodes::PATH_NOT_FOUND, $previous); + parent::__construct(sprintf('Path "%s" not found', $path), ExceptionCodes::PATH_NOT_FOUND->value, $previous); $this->path = $path; } diff --git a/src/ncc/Exceptions/RuntimeException.php b/src/ncc/Exceptions/RuntimeException.php index e38a139..71c3ce8 100644 --- a/src/ncc/Exceptions/RuntimeException.php +++ b/src/ncc/Exceptions/RuntimeException.php @@ -35,6 +35,6 @@ namespace ncc\Exceptions; */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::RUNTIME, $previous); + parent::__construct($message, ExceptionCodes::RUNTIME->value, $previous); } } \ No newline at end of file