$value ) { $bound_array_int_floor[ $i ] = array( 'floor' => (int) floor( $value ), 'fraction' => $value - floor( $value ), 'index' => $i, ); } return $bound_array_int_floor; } /** * Adjust the constrained array. * * @param array $bound_array_int - the array we're adjusting. * @param int $adjustment - how much we're adjusting the array. */ private static function adjust_constrained_array( &$bound_array_int, $adjustment ) { usort( $bound_array_int, array( self::class, 'cmp_desc_fraction' ) ); $start = 0; $end = $adjustment - 1; $length = count( $bound_array_int ); for ( $i = $start; $i <= $end; $i++ ) { ++$bound_array_int[ $i % $length ]['floor']; } usort( $bound_array_int, array( self::class, 'cmp_asc_index' ) ); } /** * Compare fraction values of two arrays. * * @param array $a - the first array we're comparing. * @param array $b - the second array we're comparing. * * @return int */ private static function cmp_desc_fraction( $a, $b ) { return $b['fraction'] <=> $a['fraction']; } /** * Compare index values of two arrays. * * @param array $a - the first array. * @param array $b - the second array. * * @return int */ private static function cmp_asc_index( $a, $b ) { return $a['index'] <=> $b['index']; } }