2017-10-04 15:26:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Legacy plural form function.
|
|
|
|
*
|
|
|
|
* @param int $nplurals
|
|
|
|
* @param string $expression
|
|
|
|
*/
|
|
|
|
function tests_make_plural_form_function( $nplurals, $expression ) {
|
|
|
|
$expression = str_replace( 'n', '$n', $expression );
|
2017-12-01 00:09:33 +01:00
|
|
|
$func_body = "
|
2017-10-04 15:26:15 +02:00
|
|
|
\$index = (int)($expression);
|
|
|
|
return (\$index < $nplurals)? \$index : $nplurals - 1;";
|
|
|
|
|
2019-01-11 04:44:20 +01:00
|
|
|
// phpcs:ignore WordPress.PHP.RestrictedPHPFunctions.create_function_create_function
|
2017-10-04 15:26:15 +02:00
|
|
|
return create_function( '$n', $func_body );
|
|
|
|
}
|