From f3accdda6af5b76c8e9a93cbd0152513248b7195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Rub=C3=A9l?= Date: Wed, 4 Oct 2023 10:32:58 +0200 Subject: [PATCH] Swap `empty` with explicit string comparison. --- src/Artisan/stubs/value-object.stub | 2 +- src/Collection/Complex/ClassString.php | 2 +- src/Collection/Complex/FullName.php | 2 +- src/Collection/Complex/TaxNumber.php | 2 +- src/Collection/Primitive/Text.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Artisan/stubs/value-object.stub b/src/Artisan/stubs/value-object.stub index a5e2c51..19714e0 100644 --- a/src/Artisan/stubs/value-object.stub +++ b/src/Artisan/stubs/value-object.stub @@ -67,7 +67,7 @@ class {{ class }} extends ValueObject { // TODO: Implement validate() method. - if (empty($this->value())) { + if ($this->value() === '') { throw ValidationException::withMessages(['Value of {{ class }} cannot be empty.']); } } diff --git a/src/Collection/Complex/ClassString.php b/src/Collection/Complex/ClassString.php index 472eac7..c6b4844 100644 --- a/src/Collection/Complex/ClassString.php +++ b/src/Collection/Complex/ClassString.php @@ -114,7 +114,7 @@ public function value(): string */ protected function validate(): void { - if (empty($this->value())) { + if ($this->value() === '') { throw ValidationException::withMessages(['Class string cannot be empty.']); } } diff --git a/src/Collection/Complex/FullName.php b/src/Collection/Complex/FullName.php index d2212b0..5d4a762 100644 --- a/src/Collection/Complex/FullName.php +++ b/src/Collection/Complex/FullName.php @@ -102,7 +102,7 @@ public function toArray(): array */ protected function validate(): void { - if (empty($this->value())) { + if ($this->value() === '') { throw ValidationException::withMessages(['Full name cannot be empty.']); } diff --git a/src/Collection/Complex/TaxNumber.php b/src/Collection/Complex/TaxNumber.php index 9183f9c..1bc23f8 100644 --- a/src/Collection/Complex/TaxNumber.php +++ b/src/Collection/Complex/TaxNumber.php @@ -141,7 +141,7 @@ public function toArray(): array */ protected function validate(): void { - if (empty($this->value())) { + if ($this->value() === '') { throw ValidationException::withMessages(['Tax number cannot be empty.']); } } diff --git a/src/Collection/Primitive/Text.php b/src/Collection/Primitive/Text.php index 97eb336..05b4d3d 100644 --- a/src/Collection/Primitive/Text.php +++ b/src/Collection/Primitive/Text.php @@ -74,7 +74,7 @@ public function value(): string */ protected function validate(): void { - if (empty($this->value())) { + if ($this->value() === '') { throw new InvalidArgumentException('Text cannot be empty.'); } }