diff --git a/src/Domain/Models/ValueObjects/Employees/EmployeeFilter.php b/src/Domain/Models/ValueObjects/Employees/EmployeeFilter.php index d54ad14..acb4d18 100644 --- a/src/Domain/Models/ValueObjects/Employees/EmployeeFilter.php +++ b/src/Domain/Models/ValueObjects/Employees/EmployeeFilter.php @@ -20,7 +20,12 @@ final readonly class EmployeeFilter public ?ServiceId $service = null, public ?\DateTimeInterface $since = null, ) { - if ($establishment === null && empty($sites) && $service === null && $since === null) { + $hasCriterion = array_any( + [$establishment, $service, $since], + static fn (mixed $val): bool => $val !== null + ) || ! empty($sites); + + if (! $hasCriterion) { throw new \DomainException('EmployeeFilter requires at least one filtering criterion.'); } diff --git a/src/Domain/Models/ValueObjects/Inco/IncoSheetFilter.php b/src/Domain/Models/ValueObjects/Inco/IncoSheetFilter.php index 6cc2fc7..a46dadb 100644 --- a/src/Domain/Models/ValueObjects/Inco/IncoSheetFilter.php +++ b/src/Domain/Models/ValueObjects/Inco/IncoSheetFilter.php @@ -15,10 +15,8 @@ final readonly class IncoSheetFilter ) { $this->brands = $brands; - foreach ($this->brands as $brand) { - if (trim($brand) === '') { - throw new \InvalidArgumentException('Every item in brands array must be a non empty string.'); - } + if (array_any($this->brands, static fn (string $brand): bool => trim($brand) === '')) { + throw new \InvalidArgumentException('Every item in brands array must be a non empty string.'); } if (empty($this->brands) && $since === null) {