rules[] = compact('param', 'operator', 'value'); } public static function if(string $param, string $operator, ?string $value = null): self { if (func_num_args() === 2) { $value = $operator; $operator = '=='; } return new self($param, $operator, $value); } public function and(string $param, string $operator, ?string $value = null): self { if (func_num_args() === 2) { $value = $operator; $operator = '=='; } $this->rules[] = compact('param', 'operator', 'value'); return $this; } public function toArray(): array { return $this->rules; } }