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 ) {
|
2020-08-13 14:32:03 +02:00
|
|
|
$closure = function ( $n ) use ( $nplurals, $expression ) {
|
|
|
|
$expression = str_replace( 'n', $n, $expression );
|
2017-10-04 15:26:15 +02:00
|
|
|
|
2020-08-13 14:32:03 +02:00
|
|
|
// phpcs:ignore Squiz.PHP.Eval -- This is test code, not production.
|
|
|
|
$index = (int) eval( 'return ' . $expression . ';' );
|
|
|
|
|
|
|
|
return ( $index < $nplurals ) ? $index : $nplurals - 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
return $closure;
|
2017-10-04 15:26:15 +02:00
|
|
|
}
|