19 private array $possibleValues;
21 private array $normalizedValues;
22 private bool $caseSensitive;
24 public function __construct( array $params ) {
25 $this->possibleValues = $params[
'values'] ?? [];
26 $this->caseSensitive = (bool)( $params[
'caseSensitive'] ??
true );
28 if ( $this->possibleValues === [] ) {
29 throw new InvalidArgumentException(
'No values provided for MatchSet validator.' );
32 if ( $this->caseSensitive ) {
33 $this->normalizedValues = $this->possibleValues;
35 $this->normalizedValues = array_map(
'strtolower', $this->possibleValues );
43 if ( $this->caseSensitive ) {
44 $translation = strtolower( $translation );
47 if ( !in_array( $translation, $this->normalizedValues,
true ) ) {
51 'translate-checks-value-not-present',
53 [
'PLAIN-PARAMS', $this->possibleValues ],
54 [
'COUNT', count( $this->possibleValues ) ]
58 $issues->add( $issue );