PHP Classes

File: vendor/wp-phpunit/wp-phpunit/includes/plural-form-function.php

Recommend this page to a friend!
  Classes of Adeleye Ayodeji   Download Installed Plugin   vendor/wp-phpunit/wp-phpunit/includes/plural-form-function.php   Download  
File: vendor/wp-phpunit/wp-phpunit/includes/plural-form-function.php
Role: Auxiliary script
Content type: text/plain
Description: Configuration script
Class: Download Installed Plugin
Download a WordPress plugin as a ZIP archive
Author: By
Last change:
Date: 2 days ago
Size: 505 bytes
 

Contents

Class file image Download
<?php

/**
 * Legacy plural form function.
 *
 * @param int $nplurals
 * @param string $expression
 */
function tests_make_plural_form_function( $nplurals, $expression ) {
   
$closure = static function ( $n ) use ( $nplurals, $expression ) {
       
$expression = str_replace( 'n', $n, $expression );

       
// phpcs:ignore Squiz.PHP.Eval -- This is test code, not production.
       
$index = (int) eval( 'return ' . $expression . ';' );

        return (
$index < $nplurals ) ? $index : $nplurals - 1;
    };

    return
$closure;
}