Wordpress/tests/phpunit/includes/plural-form-function.php
Gary Pendergast 8f95800d52 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-30 23:09:33 +00:00

17 lines
382 B
PHP

<?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 );
$func_body = "
\$index = (int)($expression);
return (\$index < $nplurals)? \$index : $nplurals - 1;";
return create_function( '$n', $func_body );
}