From dbdd59bd7223b84147d67a9762562e694e3f0ab4 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Wed, 7 Jun 2023 16:19:17 +0700 Subject: [PATCH 1/7] fea: support strict enum --- src/Strictus.php | 22 +++++++++++++++++++ src/Types/StrictusEnum.php | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/Types/StrictusEnum.php diff --git a/src/Strictus.php b/src/Strictus.php index 7a4426e..b8b9ecb 100644 --- a/src/Strictus.php +++ b/src/Strictus.php @@ -6,6 +6,7 @@ use Strictus\Types\StrictusArray; use Strictus\Types\StrictusBoolean; +use Strictus\Types\StrictusEnum; use Strictus\Types\StrictusFloat; use Strictus\Types\StrictusInstance; use Strictus\Types\StrictusInteger; @@ -148,4 +149,25 @@ public static function nullableInstance(string $instanceType, mixed $instance): { return new StrictusInstance($instanceType, $instance, true); } + + /** + * @param string $enumType + * @param mixed $enum + * @param bool $nullable + * @return StrictusEnum + */ + public static function enum(string $enumType, mixed $enum, bool $nullable = false): StrictusEnum + { + return new StrictusEnum($enumType, $enum, $nullable); + } + + /** + * @param string $enumType + * @param mixed $enum + * @return StrictusEnum + */ + public static function nullableEnum(string $enumType, mixed $enum): StrictusEnum + { + return new StrictusEnum($enumType, $enum, true); + } } diff --git a/src/Types/StrictusEnum.php b/src/Types/StrictusEnum.php new file mode 100644 index 0000000..892304d --- /dev/null +++ b/src/Types/StrictusEnum.php @@ -0,0 +1,45 @@ +errorMessage = 'Expected Enum Of '.$this->enumType; + + if ($this->nullable) { + $this->errorMessage .= ' Or Null'; + } + + $this->validate($value); + } + + private function validate(mixed $value): void + { + if (false === enum_exists($this->enumType)) { + throw new StrictusTypeException('Invalid Enum Type'); + } + + if ($value === null && ! $this->nullable) { + throw new StrictusTypeException($this->errorMessage); + } + + if ($value !== null && ! $value instanceof $this->enumType) { + throw new StrictusTypeException($this->errorMessage); + } + } +} From a001347bf8e9c62f3ad634356ae60c11b7f61eb3 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Wed, 7 Jun 2023 16:19:27 +0700 Subject: [PATCH 2/7] test: strict enum --- tests/Unit/EnumTest.php | 105 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/Unit/EnumTest.php diff --git a/tests/Unit/EnumTest.php b/tests/Unit/EnumTest.php new file mode 100644 index 0000000..077fdcd --- /dev/null +++ b/tests/Unit/EnumTest.php @@ -0,0 +1,105 @@ +expect(fn () => Strictus::enum(MyEnum::class, MyEnum::BAR)) + ->toBeInstanceOf(StrictusEnum::class); + +it('instantiates a nullable variable', function () { + $value = Strictus::enum(MyEnum::class, null, true); + expect($value) + ->toBeInstanceOf(StrictusEnum::class); + + $value = Strictus::nullableEnum(MyEnum::class, null); + expect($value) + ->toBeInstanceOf(StrictusEnum::class); + +}); + +it('throws exception when trying to instantiate variable with wrong enum type', function () { + expect(fn () => Strictus::enum('foo', MyEnum::FOO)) + ->toThrow(StrictusTypeException::class); +}); + +it('throws exception when trying to instantiate non-nullable variable with null', function () { + expect(fn () => Strictus::enum(MyClass::class, null)) + ->toThrow(StrictusTypeException::class); +}); + +it('throws exception when trying to instantiate variable with wrong enum', function () { + expect(fn () => Strictus::enum(MyEnum::class, 'foo')) + ->toThrow(StrictusTypeException::class); +}); + +it('returns the value correctly', function () { + $value = Strictus::enum(MyEnum::class, MyEnum::FOO); + + expect($value->value) + ->toBeInstanceOf(MyEnum::class) + ->and($value()) + ->toBeInstanceOf(MyEnum::class); +}); + +it('updates the value correctly', function () { + $value = Strictus::enum(MyEnum::class, MyEnum::FOO); + + expect($value->value) + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::FOO) + ->and($value()) + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::FOO); + + $value->value = MyEnum::BAR; + expect($value->value) + ->toBeInstanceOf(MyEnum::class); + + $value(MyEnum::BAR); + expect($value()) + ->toBeInstanceOf(MyEnum::class); +}); + +it('updates the nullable value to enum correctly', function () { + $value = Strictus::nullableEnum(MyEnum::class, null); + + expect($value->value) + ->toBeNull() + ->and($value()) + ->toBeNull(); + + $value->value = MyEnum::BAR; + expect($value->value) + ->toBeInstanceOf(MyEnum::class); + + $value(MyEnum::BAR); + expect($value()) + ->toBeInstanceOf(MyEnum::class); +}); + +it('updates the enum value to nullable correctly', function () { + $value = Strictus::enum(MyEnum::class, MyEnum::FOO, true); + + expect($value->value) + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::FOO) + ->and($value()) + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::FOO); + + $value->value = null; + expect($value->value) + ->toBeNull(); + + $value(null); + expect($value()) + ->toBeNull(); +}); + +enum MyEnum +{ + case FOO; + case BAR; +} From 151254402e583a6600cd51fdaab07f10be592dc3 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Wed, 7 Jun 2023 16:25:07 +0700 Subject: [PATCH 3/7] chore: update README for strict enum usage --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ba529c2..3aa962f 100644 --- a/README.md +++ b/README.md @@ -133,10 +133,18 @@ $person = Strictus::object((object) ['name' => 'Wendell', 'country' => 'BR']); //instantiates a class $calculator = Strictus::instance(CalculatorClass::class, new CalculatorClass()); +//instantiates an enum +$role = Strictus::enum(Role::class, Role::CONTRIBUTOR); + class CalculatorClass { //... } + +enum Role +{ + case CONTRIBUTOR; +} ``` 💡 Check out all the available [variable methods](#variable-methods). @@ -220,6 +228,9 @@ You can use the following methods to create variables: | Class Type | No | Strictus::instance($instanceType, $value) | | Class Type | Yes | Strictus::instance($instanceType, $value, true) | | Class Type | Yes | Strictus::nullableInstance($instanceType, $value) | +| Enum Type | No | Strictus::enum($enumType, $value) | +| Enum Type | Yes | Strictus::enum($enumType, $value, true) | +| Enum Type | Yes | Strictus::nullableEnum($enumType, $value) | ### Error Handling @@ -249,4 +260,4 @@ for PHP we quickly decided a package was the right approach whilst we could get We welcome contributions! -Please visit the **[Contributing Guide](CONTRIBUTING.md)** to learn more about contributing to Strictus. \ No newline at end of file +Please visit the **[Contributing Guide](CONTRIBUTING.md)** to learn more about contributing to Strictus. From ea8f11e99467b1bad4ab0b1a0d2f14ac7d354f79 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Wed, 7 Jun 2023 18:12:39 +0700 Subject: [PATCH 4/7] test: add backed enum test cases --- tests/Unit/EnumTest.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/Unit/EnumTest.php b/tests/Unit/EnumTest.php index 077fdcd..9fdbc9b 100644 --- a/tests/Unit/EnumTest.php +++ b/tests/Unit/EnumTest.php @@ -60,6 +60,31 @@ $value(MyEnum::BAR); expect($value()) ->toBeInstanceOf(MyEnum::class); + + $backedEnumValue = Strictus::enum(MyBackedEnum::class, MyBackedEnum::BAZ); + + expect($backedEnumValue->value) + ->toBeInstanceOf(MyBackedEnum::class) + ->toEqual(MyBackedEnum::BAZ) + ->and($backedEnumValue->value->value) + ->toEqual(MyBackedEnum::BAZ->value) + ->and($backedEnumValue()) + ->toBeInstanceOf(MyBackedEnum::class) + ->toEqual(MyBackedEnum::BAZ) + ->and($backedEnumValue()->value) + ->toEqual(MyBackedEnum::BAZ->value); + + $backedEnumValue->value = MyBackedEnum::BAZZ; + expect($backedEnumValue->value) + ->toBeInstanceOf(MyBackedEnum::class) + ->and($backedEnumValue->value->value) + ->toEqual(MyBackedEnum::BAZZ->value); + + $backedEnumValue(MyBackedEnum::BAZZ); + expect($backedEnumValue()) + ->toBeInstanceOf(MyBackedEnum::class) + ->and($backedEnumValue()->value) + ->toEqual(MyBackedEnum::BAZZ->value); }); it('updates the nullable value to enum correctly', function () { @@ -103,3 +128,9 @@ enum MyEnum case FOO; case BAR; } + +enum MyBackedEnum: int +{ + case BAZ = 1; + case BAZZ = 2; +} From c00bd8909c694b249d63b059b64915c656cbf6ff Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Wed, 7 Jun 2023 18:13:40 +0700 Subject: [PATCH 5/7] fix: linter --- src/Interfaces/StrictusTypeInterface.php | 13 ---- src/Strictus.php | 76 ------------------------ src/Traits/StrictusTyping.php | 21 ------- src/Types/StrictusInstance.php | 9 --- 4 files changed, 119 deletions(-) diff --git a/src/Interfaces/StrictusTypeInterface.php b/src/Interfaces/StrictusTypeInterface.php index e93886c..1e82f98 100644 --- a/src/Interfaces/StrictusTypeInterface.php +++ b/src/Interfaces/StrictusTypeInterface.php @@ -11,22 +11,9 @@ */ interface StrictusTypeInterface { - /** - * @param string $value - * @return mixed - */ public function __get(string $value): mixed; - /** - * @param string $name - * @param mixed $value - * @return void - */ public function __set(string $name, mixed $value): void; - /** - * @param mixed $value - * @return mixed - */ public function __invoke(mixed $value = new StrictusUndefined()): mixed; } diff --git a/src/Strictus.php b/src/Strictus.php index b8b9ecb..2e27d14 100644 --- a/src/Strictus.php +++ b/src/Strictus.php @@ -15,157 +15,81 @@ final class Strictus { - /** - * @param mixed $string - * @param bool $nullable - * @return StrictusString - */ public static function string(mixed $string, bool $nullable = false): StrictusString { return new StrictusString($string, $nullable); } - /** - * @param mixed $string - * @return StrictusString - */ public static function nullableString(mixed $string): StrictusString { return new StrictusString($string, true); } - /** - * @param mixed $integer - * @param bool $nullable - * @return StrictusInteger - */ public static function int(mixed $integer, bool $nullable = false): StrictusInteger { return new StrictusInteger($integer, $nullable); } - /** - * @param mixed $integer - * @return StrictusInteger - */ public static function nullableInt(mixed $integer): StrictusInteger { return new StrictusInteger($integer, true); } - /** - * @param mixed $float - * @param bool $nullable - * @return StrictusFloat - */ public static function float(mixed $float, bool $nullable = false): StrictusFloat { return new StrictusFloat($float, $nullable); } - /** - * @param mixed $float - * @return StrictusFloat - */ public static function nullableFloat(mixed $float): StrictusFloat { return new StrictusFloat($float, true); } - /** - * @param mixed $boolean - * @param bool $nullable - * @return StrictusBoolean - */ public static function bool(mixed $boolean, bool $nullable = false): StrictusBoolean { return new StrictusBoolean($boolean, $nullable); } - /** - * @param mixed $boolean - * @return StrictusBoolean - */ public static function nullableBool(mixed $boolean): StrictusBoolean { return new StrictusBoolean($boolean, true); } - /** - * @param mixed $array - * @param bool $nullable - * @return StrictusArray - */ public static function array(mixed $array, bool $nullable = false): StrictusArray { return new StrictusArray($array, $nullable); } - /** - * @param mixed $array - * @return StrictusArray - */ public static function nullableArray(mixed $array): StrictusArray { return new StrictusArray($array, true); } - /** - * @param mixed $object - * @param bool $nullable - * @return StrictusObject - */ public static function object(mixed $object, bool $nullable = false): StrictusObject { return new StrictusObject($object, $nullable); } - /** - * @param mixed $object - * @return StrictusObject - */ public static function nullableObject(mixed $object): StrictusObject { return new StrictusObject($object, true); } - /** - * @param string $instanceType - * @param mixed $instance - * @param bool $nullable - * @return StrictusInstance - */ public static function instance(string $instanceType, mixed $instance, bool $nullable = false): StrictusInstance { return new StrictusInstance($instanceType, $instance, $nullable); } - /** - * @param string $instanceType - * @param mixed $instance - * @return StrictusInstance - */ public static function nullableInstance(string $instanceType, mixed $instance): StrictusInstance { return new StrictusInstance($instanceType, $instance, true); } - /** - * @param string $enumType - * @param mixed $enum - * @param bool $nullable - * @return StrictusEnum - */ public static function enum(string $enumType, mixed $enum, bool $nullable = false): StrictusEnum { return new StrictusEnum($enumType, $enum, $nullable); } - /** - * @param string $enumType - * @param mixed $enum - * @return StrictusEnum - */ public static function nullableEnum(string $enumType, mixed $enum): StrictusEnum { return new StrictusEnum($enumType, $enum, true); diff --git a/src/Traits/StrictusTyping.php b/src/Traits/StrictusTyping.php index 25a6483..75ef28f 100644 --- a/src/Traits/StrictusTyping.php +++ b/src/Traits/StrictusTyping.php @@ -12,10 +12,6 @@ */ trait StrictusTyping { - /** - * @param mixed $value - * @param bool $nullable - */ public function __construct(private mixed $value, private bool $nullable) { if ($this->nullable) { @@ -25,10 +21,6 @@ public function __construct(private mixed $value, private bool $nullable) $this->validate($value); } - /** - * @param mixed $value - * @return mixed - */ public function __invoke(mixed $value = new StrictusUndefined()): mixed { if ($value instanceof StrictusUndefined) { @@ -42,20 +34,11 @@ public function __invoke(mixed $value = new StrictusUndefined()): mixed return $this; } - /** - * @param string $value - * @return mixed - */ public function __get(string $value): mixed { return $this->value; } - /** - * @param string $name - * @param mixed $value - * @return void - */ public function __set(string $name, mixed $value): void { if ($name !== 'value') { @@ -67,10 +50,6 @@ public function __set(string $name, mixed $value): void $this->value = $value; } - /** - * @param mixed $value - * @return void - */ private function validate(mixed $value): void { if ($value === null && ! $this->nullable) { diff --git a/src/Types/StrictusInstance.php b/src/Types/StrictusInstance.php index bd80ede..fc7b6fa 100644 --- a/src/Types/StrictusInstance.php +++ b/src/Types/StrictusInstance.php @@ -17,11 +17,6 @@ final class StrictusInstance implements StrictusTypeInterface private string $errorMessage; - /** - * @param string $instanceType - * @param mixed $value - * @param bool $nullable - */ public function __construct(private string $instanceType, private mixed $value, private bool $nullable) { $this->errorMessage = 'Expected Instance Of '.$this->instanceType; @@ -33,10 +28,6 @@ public function __construct(private string $instanceType, private mixed $value, $this->validate($value); } - /** - * @param mixed $value - * @return void - */ private function validate(mixed $value): void { if ($value === null && ! $this->nullable) { From 9f07c9f41b0cad613d130aefcfa7c0a3d8e88b95 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Wed, 7 Jun 2023 20:28:30 +0700 Subject: [PATCH 6/7] test: add more backed enum test cases --- tests/Unit/EnumTest.php | 126 ++++++++++++++++++++++++++++++++++------ 1 file changed, 107 insertions(+), 19 deletions(-) diff --git a/tests/Unit/EnumTest.php b/tests/Unit/EnumTest.php index 9fdbc9b..5ad2158 100644 --- a/tests/Unit/EnumTest.php +++ b/tests/Unit/EnumTest.php @@ -4,19 +4,22 @@ use Strictus\Strictus; use Strictus\Types\StrictusEnum; -it('instantiates variable') - ->expect(fn () => Strictus::enum(MyEnum::class, MyEnum::BAR)) - ->toBeInstanceOf(StrictusEnum::class); - -it('instantiates a nullable variable', function () { - $value = Strictus::enum(MyEnum::class, null, true); - expect($value) +it('instantiates variable', function () { + expect(Strictus::enum(MyEnum::class, MyEnum::BAR)) + ->toBeInstanceOf(StrictusEnum::class) + ->and(Strictus::enum(MyBackedEnum::class, MyBackedEnum::BAZ)) ->toBeInstanceOf(StrictusEnum::class); +}); - $value = Strictus::nullableEnum(MyEnum::class, null); - expect($value) +it('instantiates a nullable variable', function () { + expect(Strictus::enum(MyEnum::class, null, true)) + ->toBeInstanceOf(StrictusEnum::class) + ->and(Strictus::nullableEnum(MyEnum::class, null)) + ->toBeInstanceOf(StrictusEnum::class) + ->and(Strictus::enum(MyBackedEnum::class, null, true)) + ->toBeInstanceOf(StrictusEnum::class) + ->and(Strictus::nullableEnum(MyBackedEnum::class, null)) ->toBeInstanceOf(StrictusEnum::class); - }); it('throws exception when trying to instantiate variable with wrong enum type', function () { @@ -26,51 +29,100 @@ it('throws exception when trying to instantiate non-nullable variable with null', function () { expect(fn () => Strictus::enum(MyClass::class, null)) + ->toThrow(StrictusTypeException::class) + ->and(fn () => Strictus::enum(MyBackedEnum::class, null)) ->toThrow(StrictusTypeException::class); }); it('throws exception when trying to instantiate variable with wrong enum', function () { expect(fn () => Strictus::enum(MyEnum::class, 'foo')) + ->toThrow(StrictusTypeException::class) + ->and(fn () => Strictus::enum(MyBackedEnum::class, 'foo')) ->toThrow(StrictusTypeException::class); }); it('returns the value correctly', function () { $value = Strictus::enum(MyEnum::class, MyEnum::FOO); - expect($value->value) + expect($value) + ->toBeInstanceOf(StrictusEnum::class) + ->and($value->value) ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::FOO) + ->and($value->value->name) + ->toEqual(MyEnum::FOO->name) ->and($value()) - ->toBeInstanceOf(MyEnum::class); + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::FOO) + ->and($value()->name) + ->toEqual(MyEnum::FOO->name); + + $backedEnumValue = Strictus::enum(MyBackedEnum::class, MyBackedEnum::BAZ); + + expect($backedEnumValue) + ->toBeInstanceOf(StrictusEnum::class) + ->and($backedEnumValue->value) + ->toBeInstanceOf(MyBackedEnum::class) + ->toEqual(MyBackedEnum::BAZ) + ->and($backedEnumValue->value->name) + ->toEqual(MyBackedEnum::BAZ->name) + ->and($backedEnumValue->value->value) + ->toEqual(MyBackedEnum::BAZ->value) + ->and($backedEnumValue()) + ->toBeInstanceOf(MyBackedEnum::class) + ->toEqual(MyBackedEnum::BAZ) + ->and($backedEnumValue()->name) + ->toEqual(MyBackedEnum::BAZ->name) + ->and($backedEnumValue()->value) + ->toEqual(MyBackedEnum::BAZ->value); }); it('updates the value correctly', function () { $value = Strictus::enum(MyEnum::class, MyEnum::FOO); - expect($value->value) + expect($value) + ->toBeInstanceOf(StrictusEnum::class) + ->and($value->value) ->toBeInstanceOf(MyEnum::class) ->toEqual(MyEnum::FOO) + ->and($value->value->name) + ->toEqual(MyEnum::FOO->name) ->and($value()) ->toBeInstanceOf(MyEnum::class) - ->toEqual(MyEnum::FOO); + ->toEqual(MyEnum::FOO) + ->and($value()->name) + ->toEqual(MyEnum::FOO->name); $value->value = MyEnum::BAR; expect($value->value) - ->toBeInstanceOf(MyEnum::class); + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::BAR) + ->and($value->value->name) + ->toEqual(MyEnum::BAR->name); $value(MyEnum::BAR); expect($value()) - ->toBeInstanceOf(MyEnum::class); + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::BAR) + ->and($value()->name) + ->toEqual(MyEnum::BAR->name); $backedEnumValue = Strictus::enum(MyBackedEnum::class, MyBackedEnum::BAZ); - expect($backedEnumValue->value) + expect($backedEnumValue) + ->toBeInstanceOf(StrictusEnum::class) + ->and($backedEnumValue->value) ->toBeInstanceOf(MyBackedEnum::class) ->toEqual(MyBackedEnum::BAZ) + ->and($backedEnumValue->value->name) + ->toEqual(MyBackedEnum::BAZ->name) ->and($backedEnumValue->value->value) ->toEqual(MyBackedEnum::BAZ->value) ->and($backedEnumValue()) ->toBeInstanceOf(MyBackedEnum::class) ->toEqual(MyBackedEnum::BAZ) + ->and($backedEnumValue()->name) + ->toEqual(MyBackedEnum::BAZ->name) ->and($backedEnumValue()->value) ->toEqual(MyBackedEnum::BAZ->value); @@ -97,11 +149,30 @@ $value->value = MyEnum::BAR; expect($value->value) - ->toBeInstanceOf(MyEnum::class); + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::BAR); $value(MyEnum::BAR); expect($value()) - ->toBeInstanceOf(MyEnum::class); + ->toBeInstanceOf(MyEnum::class) + ->toEqual(MyEnum::BAR); + + $backedEnumValue = Strictus::nullableEnum(MyBackedEnum::class, null); + + expect($backedEnumValue->value) + ->toBeNull() + ->and($backedEnumValue()) + ->toBeNull(); + + $backedEnumValue->value = MyBackedEnum::BAZ; + expect($backedEnumValue->value) + ->toBeInstanceOf(MyBackedEnum::class) + ->toEqual(MyBackedEnum::BAZ); + + $backedEnumValue(MyBackedEnum::BAZ); + expect($backedEnumValue()) + ->toBeInstanceOf(MyBackedEnum::class) + ->toEqual(MyBackedEnum::BAZ); }); it('updates the enum value to nullable correctly', function () { @@ -121,6 +192,23 @@ $value(null); expect($value()) ->toBeNull(); + + $backedEnumValue = Strictus::enum(MyBackedEnum::class, MyBackedEnum::BAZZ, true); + + expect($backedEnumValue->value) + ->toBeInstanceOf(MyBackedEnum::class) + ->toEqual(MyBackedEnum::BAZZ) + ->and($backedEnumValue()) + ->toBeInstanceOf(MyBackedEnum::class) + ->toEqual(MyBackedEnum::BAZZ); + + $backedEnumValue->value = null; + expect($backedEnumValue->value) + ->toBeNull(); + + $backedEnumValue(null); + expect($backedEnumValue()) + ->toBeNull(); }); enum MyEnum From 2fc5ca2fccd38add7909f7bc8732017355673f63 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Thu, 8 Jun 2023 08:17:28 +0700 Subject: [PATCH 7/7] fix: lint --- src/Types/StrictusEnum.php | 2 +- tests/Unit/EnumTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Types/StrictusEnum.php b/src/Types/StrictusEnum.php index 892304d..fee8fef 100644 --- a/src/Types/StrictusEnum.php +++ b/src/Types/StrictusEnum.php @@ -19,7 +19,7 @@ final class StrictusEnum implements StrictusTypeInterface public function __construct(private string $enumType, private mixed $value, private bool $nullable) { - $this->errorMessage = 'Expected Enum Of '.$this->enumType; + $this->errorMessage = 'Expected Enum Of ' . $this->enumType; if ($this->nullable) { $this->errorMessage .= ' Or Null'; diff --git a/tests/Unit/EnumTest.php b/tests/Unit/EnumTest.php index 5ad2158..2aad2f9 100644 --- a/tests/Unit/EnumTest.php +++ b/tests/Unit/EnumTest.php @@ -1,5 +1,7 @@