function _math_captcha_repr_op in CAPTCHA Pack 8
Same name and namespace in other branches
- 5 math_captcha/math_captcha.module \_math_captcha_repr_op()
- 6 math_captcha/math_captcha.challenge.inc \_math_captcha_repr_op()
- 7 math_captcha/math_captcha.challenge.inc \_math_captcha_repr_op()
Helper function for transforming a operator to a textual representation.
1 call to _math_captcha_repr_op()
- _math_captcha_build_captcha in math_captcha/
math_captcha.challenge.inc - Helper function to build a math CAPTCHA form item.
File
- math_captcha/
math_captcha.challenge.inc, line 142 - Provides challenge functions for MATH CAPTCHA administration.
Code
function _math_captcha_repr_op($op) {
$config = Drupal::config('math_captcha.settings');
// Start with no textual representation.
$t = "{$op}";
// If enabled and available: do textual representation.
if ($config
->get('math_captcha_textual_operators')) {
$repr_map = [
'+' => t('plus'),
'-' => t('minus'),
'*' => t('times'),
'=' => t('equals'),
];
if (array_key_exists($op, $repr_map)) {
$t = $repr_map[$op];
}
}
return $t;
}