From fb78024ae5a8366dbdf653277ec670b1b50d3567 Mon Sep 17 00:00:00 2001 From: ruff Date: Thu, 12 Jan 2023 05:58:29 +0100 Subject: [PATCH] Seperated exception Codes (const in OrderExceptionCodes class), Renamed Exception class "OrderUnknownDateFormat" to "OrderUnknownDateFormatException" --- src/OrderObjectHelper.php | 4 ++-- .../OrderCannotFindProfileString.php | 2 +- src/exception/OrderExceptionCodes.php | 20 +++++++++++++++++++ src/exception/OrderFileNotFoundException.php | 2 +- .../OrderMimeTypeNotSupportedException.php | 2 +- ...erNoValidAttachmentFoundInPdfException.php | 2 +- ...hp => OrderUnknownDateFormatException.php} | 4 ++-- .../OrderUnknownProfileException.php | 2 +- .../testcases/OrderObjectHelperBasicTest.php | 4 ++-- .../OrderObjectHelperComfortTest.php | 4 ++-- .../OrderObjectHelperExtendedTest.php | 4 ++-- 11 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 src/exception/OrderExceptionCodes.php rename src/exception/{OrderUnknownDateFormat.php => OrderUnknownDateFormatException.php} (85%) diff --git a/src/OrderObjectHelper.php b/src/OrderObjectHelper.php index 08fdfe0..ad097fc 100644 --- a/src/OrderObjectHelper.php +++ b/src/OrderObjectHelper.php @@ -11,7 +11,7 @@ use DateTime; use horstoeko\orderx\exception\OrderMimeTypeNotSupportedException; -use horstoeko\orderx\exception\OrderUnknownDateFormat; +use horstoeko\orderx\exception\OrderUnknownDateFormatException; use horstoeko\stringmanagement\FileUtils; use horstoeko\stringmanagement\StringUtils; use MimeTyper\Repository\MimeDbRepository; @@ -1319,7 +1319,7 @@ public function toDateTime(?string $dateTimeString = null, ?string $format = nul } elseif ($format == "204") { return DateTime::createFromFormat("YmdHis", $dateTimeString); } else { - throw new OrderUnknownDateFormat($format); + throw new OrderUnknownDateFormatException($format); } } diff --git a/src/exception/OrderCannotFindProfileString.php b/src/exception/OrderCannotFindProfileString.php index 8ffc2ec..540cefa 100644 --- a/src/exception/OrderCannotFindProfileString.php +++ b/src/exception/OrderCannotFindProfileString.php @@ -29,6 +29,6 @@ class OrderCannotFindProfileString extends OrderBaseException */ public function __construct(?Throwable $previous = null) { - parent::__construct("The string containing the profile was not found", -1101, $previous); + parent::__construct("The string containing the profile was not found", OrderExceptionCodes::CANNOTFINDPROFILESTRING, $previous); } } diff --git a/src/exception/OrderExceptionCodes.php b/src/exception/OrderExceptionCodes.php new file mode 100644 index 0000000..d2d34af --- /dev/null +++ b/src/exception/OrderExceptionCodes.php @@ -0,0 +1,20 @@ +assertEquals("31.12.2022 14:30:00", self::$objectHelper->toDateTime("202212311430", "203")->format("d.m.Y H:i:s")); $this->assertEquals("31.12.2022 14:30:44", self::$objectHelper->toDateTime("20221231143044", "204")->format("d.m.Y H:i:s")); - $this->expectException(OrderUnknownDateFormat::class); + $this->expectException(OrderUnknownDateFormatException::class); self::$objectHelper->toDateTime("20221231", "999"); } diff --git a/tests/testcases/OrderObjectHelperComfortTest.php b/tests/testcases/OrderObjectHelperComfortTest.php index 6fe6767..c901ddc 100644 --- a/tests/testcases/OrderObjectHelperComfortTest.php +++ b/tests/testcases/OrderObjectHelperComfortTest.php @@ -3,7 +3,7 @@ namespace horstoeko\orderx\tests\testcases; use horstoeko\orderx\exception\OrderMimeTypeNotSupportedException; -use horstoeko\orderx\exception\OrderUnknownDateFormat; +use horstoeko\orderx\exception\OrderUnknownDateFormatException; use horstoeko\orderx\OrderObjectHelper; use horstoeko\orderx\OrderProfiles; use horstoeko\orderx\tests\TestCase; @@ -1202,7 +1202,7 @@ public function testToDateTime(): void $this->assertEquals("31.12.2022 14:30:00", self::$objectHelper->toDateTime("202212311430", "203")->format("d.m.Y H:i:s")); $this->assertEquals("31.12.2022 14:30:44", self::$objectHelper->toDateTime("20221231143044", "204")->format("d.m.Y H:i:s")); - $this->expectException(OrderUnknownDateFormat::class); + $this->expectException(OrderUnknownDateFormatException::class); self::$objectHelper->toDateTime("20221231", "999"); } diff --git a/tests/testcases/OrderObjectHelperExtendedTest.php b/tests/testcases/OrderObjectHelperExtendedTest.php index b558f3f..b893b72 100644 --- a/tests/testcases/OrderObjectHelperExtendedTest.php +++ b/tests/testcases/OrderObjectHelperExtendedTest.php @@ -3,7 +3,7 @@ namespace horstoeko\orderx\tests\testcases; use horstoeko\orderx\exception\OrderMimeTypeNotSupportedException; -use horstoeko\orderx\exception\OrderUnknownDateFormat; +use horstoeko\orderx\exception\OrderUnknownDateFormatException; use horstoeko\orderx\OrderObjectHelper; use horstoeko\orderx\OrderProfiles; use horstoeko\orderx\tests\TestCase; @@ -1226,7 +1226,7 @@ public function testToDateTime(): void $this->assertEquals("31.12.2022 14:30:00", self::$objectHelper->toDateTime("202212311430", "203")->format("d.m.Y H:i:s")); $this->assertEquals("31.12.2022 14:30:44", self::$objectHelper->toDateTime("20221231143044", "204")->format("d.m.Y H:i:s")); - $this->expectException(OrderUnknownDateFormat::class); + $this->expectException(OrderUnknownDateFormatException::class); self::$objectHelper->toDateTime("20221231", "999"); }