$value) { if ($value instanceof self) { $value = $value->toArray(); } if (is_array($value)) { $value = $this->filterFilledRecursive($value); } if ($value !== null && $value !== '' && $value !== []) { $filtered[$key] = $value; } } return $filtered; } protected static function requireFilled(mixed $value, string $field): void { if ($value === null || $value === '' || $value === []) { throw new \InvalidArgumentException("{$field} e obrigatorio."); } } protected static function requireIn(string $value, array $allowed, string $field): void { if (! in_array($value, $allowed, true)) { throw new \InvalidArgumentException("{$field} invalido."); } } protected static function requirePositiveInt(int $value, string $field): void { if ($value <= 0) { throw new \InvalidArgumentException("{$field} deve ser maior que zero."); } } }