From 465bc2a9495e5e807c2e023aef02e36d86706b2d Mon Sep 17 00:00:00 2001 From: Marc Beinder Date: Thu, 20 Jun 2024 09:04:22 -0500 Subject: [PATCH 1/5] [Exceptions] Organize NullExceptions --- src/Exceptions/ArgumentNullException.php | 8 ++++---- .../NullExceptions/ArgumentNullException.php | 16 ++++++++++++++++ .../ClassPropertyNullException.php | 16 ++++++++++++++++ src/Exceptions/NullExceptions/NullException.php | 15 +++++++++++++++ .../NullExceptions/VariableNullException.php | 16 ++++++++++++++++ 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 src/Exceptions/NullExceptions/ArgumentNullException.php create mode 100644 src/Exceptions/NullExceptions/ClassPropertyNullException.php create mode 100644 src/Exceptions/NullExceptions/NullException.php create mode 100644 src/Exceptions/NullExceptions/VariableNullException.php diff --git a/src/Exceptions/ArgumentNullException.php b/src/Exceptions/ArgumentNullException.php index a026c19..6135885 100644 --- a/src/Exceptions/ArgumentNullException.php +++ b/src/Exceptions/ArgumentNullException.php @@ -2,14 +2,14 @@ namespace EncoreDigitalGroup\StdLib\Exceptions; +use EncoreDigitalGroup\StdLib\Exceptions\NullExceptions\ArgumentNullException as BaseArgumentNullException; use EncoreDigitalGroup\StdLib\Objects\ExitCode; -class ArgumentNullException extends BaseException +/** @deprecated use EncoreDigitalGroup\StdLib\Exceptions\NullExceptions\ArgumentNullException instead */ +class ArgumentNullException extends BaseArgumentNullException { public function __construct(string $argumentName = 'Argument') { - $msg = "{$argumentName} is null on {$this->line}, in {$this->file}"; - - parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious()); + parent::__construct($argumentName); } } diff --git a/src/Exceptions/NullExceptions/ArgumentNullException.php b/src/Exceptions/NullExceptions/ArgumentNullException.php new file mode 100644 index 0000000..cc42dfb --- /dev/null +++ b/src/Exceptions/NullExceptions/ArgumentNullException.php @@ -0,0 +1,16 @@ +line}, in {$this->file}"; + + parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious()); + } +} diff --git a/src/Exceptions/NullExceptions/ClassPropertyNullException.php b/src/Exceptions/NullExceptions/ClassPropertyNullException.php new file mode 100644 index 0000000..484079f --- /dev/null +++ b/src/Exceptions/NullExceptions/ClassPropertyNullException.php @@ -0,0 +1,16 @@ +getPrevious()); + } +} diff --git a/src/Exceptions/NullExceptions/NullException.php b/src/Exceptions/NullExceptions/NullException.php new file mode 100644 index 0000000..39bc1cb --- /dev/null +++ b/src/Exceptions/NullExceptions/NullException.php @@ -0,0 +1,15 @@ +getPrevious()); + } +} diff --git a/src/Exceptions/NullExceptions/VariableNullException.php b/src/Exceptions/NullExceptions/VariableNullException.php new file mode 100644 index 0000000..5ad9367 --- /dev/null +++ b/src/Exceptions/NullExceptions/VariableNullException.php @@ -0,0 +1,16 @@ +getPrevious()); + } +} From 33eeecb3eb7476d81b42252eaa87026ea13d73f0 Mon Sep 17 00:00:00 2001 From: Marc Beinder Date: Thu, 20 Jun 2024 09:04:35 -0500 Subject: [PATCH 2/5] [Exceptions] Organize FilesystemExceptions --- src/Exceptions/DirectoryNotFoundException.php | 12 ++++-------- src/Exceptions/FileNotFoundException.php | 12 ++++-------- .../DirectoryNotFoundException.php | 19 +++++++++++++++++++ .../FileNotFoundException.php | 19 +++++++++++++++++++ 4 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 src/Exceptions/FilesystemExceptions/DirectoryNotFoundException.php create mode 100644 src/Exceptions/FilesystemExceptions/FileNotFoundException.php diff --git a/src/Exceptions/DirectoryNotFoundException.php b/src/Exceptions/DirectoryNotFoundException.php index 64fb9ab..ac91d66 100644 --- a/src/Exceptions/DirectoryNotFoundException.php +++ b/src/Exceptions/DirectoryNotFoundException.php @@ -2,18 +2,14 @@ namespace EncoreDigitalGroup\StdLib\Exceptions; +use EncoreDigitalGroup\StdLib\Exceptions\FilesystemExceptions\DirectoryNotFoundException as BaseDirectoryNotFoundException; use EncoreDigitalGroup\StdLib\Objects\ExitCode; -class DirectoryNotFoundException extends BaseException +/** @deprecated use EncoreDigitalGroup\StdLib\Exceptions\FilesystemExceptions\DirectoryNotFoundException instead */ +class DirectoryNotFoundException extends BaseDirectoryNotFoundException { public function __construct(?string $path = null) { - if (is_null($path)) { - $msg = str_concat_space('Unable to locate directory on line', $this->line, 'in', $this->file); - } else { - $msg = str_concat_space('Unable to locate directory', $path, 'on line', $this->line, 'in', $this->file); - } - - parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious()); + parent::__construct($msg); } } diff --git a/src/Exceptions/FileNotFoundException.php b/src/Exceptions/FileNotFoundException.php index 5e22915..414b1c3 100644 --- a/src/Exceptions/FileNotFoundException.php +++ b/src/Exceptions/FileNotFoundException.php @@ -2,18 +2,14 @@ namespace EncoreDigitalGroup\StdLib\Exceptions; +use EncoreDigitalGroup\StdLib\Exceptions\FilesystemExceptions\FileNotFoundException as BaseFileNotFoundException; use EncoreDigitalGroup\StdLib\Objects\ExitCode; -class FileNotFoundException extends BaseException +/** @deprecated use EncoreDigitalGroup\StdLib\Exceptions\FilesystemExceptions\FileNotFoundException instead. */ +class FileNotFoundException extends BaseFileNotFoundException { public function __construct(?string $path = null) { - if (is_null($path)) { - $msg = str_concat_space('Unable to locate file on line', $this->line, 'in', $this->file); - } else { - $msg = str_concat_space('Unable to locate file', $path, 'on line', $this->line, 'in', $this->file); - } - - parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious()); + parent::__construct($msg); } } diff --git a/src/Exceptions/FilesystemExceptions/DirectoryNotFoundException.php b/src/Exceptions/FilesystemExceptions/DirectoryNotFoundException.php new file mode 100644 index 0000000..64fb9ab --- /dev/null +++ b/src/Exceptions/FilesystemExceptions/DirectoryNotFoundException.php @@ -0,0 +1,19 @@ +line, 'in', $this->file); + } else { + $msg = str_concat_space('Unable to locate directory', $path, 'on line', $this->line, 'in', $this->file); + } + + parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious()); + } +} diff --git a/src/Exceptions/FilesystemExceptions/FileNotFoundException.php b/src/Exceptions/FilesystemExceptions/FileNotFoundException.php new file mode 100644 index 0000000..5e22915 --- /dev/null +++ b/src/Exceptions/FilesystemExceptions/FileNotFoundException.php @@ -0,0 +1,19 @@ +line, 'in', $this->file); + } else { + $msg = str_concat_space('Unable to locate file', $path, 'on line', $this->line, 'in', $this->file); + } + + parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious()); + } +} From 5e8254f58d0af7f0f49a60fa415542336c862d59 Mon Sep 17 00:00:00 2001 From: Marc Beinder Date: Thu, 20 Jun 2024 09:04:43 -0500 Subject: [PATCH 3/5] [Exceptions] Create EmptyExceptions --- .../EmptyExceptions/ArrayEmptyException.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/Exceptions/EmptyExceptions/ArrayEmptyException.php diff --git a/src/Exceptions/EmptyExceptions/ArrayEmptyException.php b/src/Exceptions/EmptyExceptions/ArrayEmptyException.php new file mode 100644 index 0000000..c0d6c56 --- /dev/null +++ b/src/Exceptions/EmptyExceptions/ArrayEmptyException.php @@ -0,0 +1,16 @@ +getPrevious()); + } +} From affcffb2174e052862325f3be9db499d8b2df2a2 Mon Sep 17 00:00:00 2001 From: Marc Beinder Date: Thu, 20 Jun 2024 09:06:43 -0500 Subject: [PATCH 4/5] [Exceptions] Add missing use statements --- .../FilesystemExceptions/DirectoryNotFoundException.php | 3 ++- src/Exceptions/FilesystemExceptions/FileNotFoundException.php | 3 ++- src/Exceptions/NullExceptions/NullException.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Exceptions/FilesystemExceptions/DirectoryNotFoundException.php b/src/Exceptions/FilesystemExceptions/DirectoryNotFoundException.php index 64fb9ab..a7d2fd6 100644 --- a/src/Exceptions/FilesystemExceptions/DirectoryNotFoundException.php +++ b/src/Exceptions/FilesystemExceptions/DirectoryNotFoundException.php @@ -1,7 +1,8 @@ getPrevious()); } From 202e57662f45e8504378bcb4b9b6c947e495bbee Mon Sep 17 00:00:00 2001 From: Marc Beinder Date: Thu, 20 Jun 2024 09:13:28 -0500 Subject: [PATCH 5/5] Run Gauntlet --- src/Exceptions/ArgumentNullException.php | 1 - src/Exceptions/DirectoryNotFoundException.php | 3 +-- src/Exceptions/FileNotFoundException.php | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Exceptions/ArgumentNullException.php b/src/Exceptions/ArgumentNullException.php index 6135885..f38f8ec 100644 --- a/src/Exceptions/ArgumentNullException.php +++ b/src/Exceptions/ArgumentNullException.php @@ -3,7 +3,6 @@ namespace EncoreDigitalGroup\StdLib\Exceptions; use EncoreDigitalGroup\StdLib\Exceptions\NullExceptions\ArgumentNullException as BaseArgumentNullException; -use EncoreDigitalGroup\StdLib\Objects\ExitCode; /** @deprecated use EncoreDigitalGroup\StdLib\Exceptions\NullExceptions\ArgumentNullException instead */ class ArgumentNullException extends BaseArgumentNullException diff --git a/src/Exceptions/DirectoryNotFoundException.php b/src/Exceptions/DirectoryNotFoundException.php index ac91d66..dd7ec28 100644 --- a/src/Exceptions/DirectoryNotFoundException.php +++ b/src/Exceptions/DirectoryNotFoundException.php @@ -3,13 +3,12 @@ namespace EncoreDigitalGroup\StdLib\Exceptions; use EncoreDigitalGroup\StdLib\Exceptions\FilesystemExceptions\DirectoryNotFoundException as BaseDirectoryNotFoundException; -use EncoreDigitalGroup\StdLib\Objects\ExitCode; /** @deprecated use EncoreDigitalGroup\StdLib\Exceptions\FilesystemExceptions\DirectoryNotFoundException instead */ class DirectoryNotFoundException extends BaseDirectoryNotFoundException { public function __construct(?string $path = null) { - parent::__construct($msg); + parent::__construct($path); } } diff --git a/src/Exceptions/FileNotFoundException.php b/src/Exceptions/FileNotFoundException.php index 414b1c3..607f12d 100644 --- a/src/Exceptions/FileNotFoundException.php +++ b/src/Exceptions/FileNotFoundException.php @@ -3,13 +3,12 @@ namespace EncoreDigitalGroup\StdLib\Exceptions; use EncoreDigitalGroup\StdLib\Exceptions\FilesystemExceptions\FileNotFoundException as BaseFileNotFoundException; -use EncoreDigitalGroup\StdLib\Objects\ExitCode; /** @deprecated use EncoreDigitalGroup\StdLib\Exceptions\FilesystemExceptions\FileNotFoundException instead. */ class FileNotFoundException extends BaseFileNotFoundException { public function __construct(?string $path = null) { - parent::__construct($msg); + parent::__construct($path); } }