19 protected $possibleValues;
21 protected $normalizedValues;
23 protected $caseSensitive;
25 public function __construct( array $params ) {
26 $this->possibleValues = $params[
'values'] ?? [];
27 $this->caseSensitive = (bool)( $params[
'caseSensitive'] ??
true );
29 if ( $this->possibleValues === [] ) {
30 throw new InvalidArgumentException(
'No values provided for MatchSet validator.' );
33 if ( $this->caseSensitive ) {
34 $this->normalizedValues = $this->possibleValues;
36 $this->normalizedValues = array_map(
'strtolower', $this->possibleValues );
44 if ( $this->caseSensitive ) {
45 $translation = strtolower( $translation );
48 if ( !in_array( $translation, $this->normalizedValues,
true ) ) {
52 'translate-checks-value-not-present',
54 [
'PLAIN-PARAMS', $this->possibleValues ],
55 [
'COUNT', count( $this->possibleValues ) ]
59 $issues->add( $issue );