From 59807d8e33fb13eeedd5395d2dcb4d21b5c51ecd Mon Sep 17 00:00:00 2001 From: myrmidex Date: Thu, 18 Jun 2026 21:25:39 +0200 Subject: [PATCH] 31 - Add domain enums --- src/Enum/BucketAllocationType.php | 10 +++++++++ src/Enum/BucketType.php | 26 ++++++++++++++++++++++ src/Enum/DistributionMode.php | 9 ++++++++ src/Enum/StreamFrequency.php | 14 ++++++++++++ src/Enum/StreamType.php | 9 ++++++++ tests/Enum/BucketTypeTest.php | 32 +++++++++++++++++++++++++++ tests/Enum/RemainingEnumsTest.php | 36 +++++++++++++++++++++++++++++++ 7 files changed, 136 insertions(+) create mode 100644 src/Enum/BucketAllocationType.php create mode 100644 src/Enum/BucketType.php create mode 100644 src/Enum/DistributionMode.php create mode 100644 src/Enum/StreamFrequency.php create mode 100644 src/Enum/StreamType.php create mode 100644 tests/Enum/BucketTypeTest.php create mode 100644 tests/Enum/RemainingEnumsTest.php diff --git a/src/Enum/BucketAllocationType.php b/src/Enum/BucketAllocationType.php new file mode 100644 index 0000000..59ee44e --- /dev/null +++ b/src/Enum/BucketAllocationType.php @@ -0,0 +1,10 @@ + + */ + public function getAllowedAllocationTypes(): array + { + return match ($this) { + self::NEED, self::WANT => [ + BucketAllocationType::FIXED_LIMIT, + BucketAllocationType::PERCENTAGE, + ], + self::OVERFLOW => [ + BucketAllocationType::UNLIMITED, + ], + }; + } +} diff --git a/src/Enum/DistributionMode.php b/src/Enum/DistributionMode.php new file mode 100644 index 0000000..b418f7e --- /dev/null +++ b/src/Enum/DistributionMode.php @@ -0,0 +1,9 @@ +assertSame('need', BucketType::NEED->value); + $this->assertSame('want', BucketType::WANT->value); + $this->assertSame('overflow', BucketType::OVERFLOW->value); + + $this->assertSame( + [BucketAllocationType::FIXED_LIMIT, BucketAllocationType::PERCENTAGE], + BucketType::NEED->getAllowedAllocationTypes(), + ); + + $this->assertSame( + [BucketAllocationType::FIXED_LIMIT, BucketAllocationType::PERCENTAGE], + BucketType::WANT->getAllowedAllocationTypes(), + ); + + $this->assertSame( + [BucketAllocationType::UNLIMITED], + BucketType::OVERFLOW->getAllowedAllocationTypes(), + ); + } +} diff --git a/tests/Enum/RemainingEnumsTest.php b/tests/Enum/RemainingEnumsTest.php new file mode 100644 index 0000000..4dbcfa5 --- /dev/null +++ b/tests/Enum/RemainingEnumsTest.php @@ -0,0 +1,36 @@ +assertSame('once', StreamFrequency::ONCE->value); + $this->assertSame('daily', StreamFrequency::DAILY->value); + $this->assertSame('weekly', StreamFrequency::WEEKLY->value); + $this->assertSame('biweekly', StreamFrequency::BIWEEKLY->value); + $this->assertSame('monthly', StreamFrequency::MONTHLY->value); + $this->assertSame('quarterly', StreamFrequency::QUARTERLY->value); + $this->assertSame('yearly', StreamFrequency::YEARLY->value); + + $this->assertSame('income', StreamType::INCOME->value); + $this->assertSame('expense', StreamType::EXPENSE->value); + + $this->assertSame('even', DistributionMode::EVEN->value); + $this->assertSame('priority', DistributionMode::PRIORITY->value); + } + + public function testBucketAllocationTypeBackingValues(): void + { + $this->assertSame('fixed_limit', BucketAllocationType::FIXED_LIMIT->value); + $this->assertSame('percentage', BucketAllocationType::PERCENTAGE->value); + $this->assertSame('unlimited', BucketAllocationType::UNLIMITED->value); + } +}