Skip to content

Commit

Permalink
Merge pull request #1684 from Daniel-KM/fix/insensitive_lang
Browse files Browse the repository at this point in the history
Search type and language case insensitively (fix #1672).
  • Loading branch information
zerocrates authored Jan 29, 2021
2 parents dfbab69 + 2c1cb43 commit f7a5cad
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,26 +344,26 @@ public function value($term, array $options = [])
if (empty($options['type'])) {
$types = false;
} elseif (is_array($options['type'])) {
$types = $options['type'];
$types = array_fill_keys(array_map('strtolower', $options['type']), true);
} else {
$types = [$options['type']];
$types = [strtolower($options['type']) => true];
}

if (empty($options['lang'])) {
$langs = false;
} elseif (is_array($options['lang'])) {
$langs = $options['lang'];
$langs = array_fill_keys(array_map('strtolower', $options['lang']), true);
} else {
$langs = [$options['lang']];
$langs = [strtolower($options['lang']) => true];
}

// Match only the representations that fit all the criteria.
$matchingValues = [];
foreach ($this->values()[$term]['values'] as $value) {
if ($types && !in_array($value->type(), $types)) {
if ($types && empty($types[strtolower($value->type())])) {
continue;
}
if ($langs && !in_array($value->lang(), $langs)) {
if ($langs && empty($langs[strtolower($value->lang())])) {
continue;
}
$matchingValues[] = $value;
Expand Down

0 comments on commit f7a5cad

Please sign in to comment.