op; } /** * Evaluates the condition against the controlling field's current values. * * @param string[] $values Selected/entered values (empty array = nothing). */ public function matches( array $values ): bool { $values = array_values( array_filter( array_map( 'strval', $values ), static fn( string $v ): bool => '' !== $v ) ); return match ( $this->op ) { 'is' => in_array( $this->value, $values, true ), 'not' => ! in_array( $this->value, $values, true ), 'filled' => array() !== $values, 'empty' => array() === $values, default => true, }; } /** * Data for the browser (data-tflexforms-if attribute). * * @return array{field:string,op:string,value:string} */ public function to_array(): array { return array( 'field' => $this->field, 'op' => $this->op, 'value' => $this->value, ); } }