GRAYBYTE WORDPRESS FILE MANAGER7570

Server IP : 162.213.255.40 / Your IP : 216.73.216.42
System : Linux server146.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
PHP Version : 8.0.30
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF

HOME

/home/hellrfbn/public_html/wp-content/updraft/plugins-old/woocommerce/src/Utilities/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/hellrfbn/public_html/wp-content/updraft/plugins-old/woocommerce/src/Utilities//NumberUtil.php
<?php
/**
 * A class of utilities for dealing with numbers.
 */

namespace Automattic\WooCommerce\Utilities;

/**
 * A class of utilities for dealing with numbers.
 */
final class NumberUtil {
	/**
	 * Round a number using the built-in `round` function, but unless the value to round is numeric
	 * (a number or a string that can be parsed as a number), apply 'floatval' first to it
	 * (so it will convert it to 0 in most cases).
	 *
	 * This is needed because in PHP 7 applying `round` to a non-numeric value returns 0,
	 * but in PHP 8 it throws an error. Specifically, in WooCommerce we have a few places where
	 * round('') is often executed.
	 *
	 * @param mixed $val The value to round.
	 * @param int   $precision The optional number of decimal digits to round to.
	 * @param int   $mode A constant to specify the mode in which rounding occurs.
	 *
	 * @return float The value rounded to the given precision as a float, or the supplied default value.
	 */
	public static function round( $val, int $precision = 0, int $mode = PHP_ROUND_HALF_UP ) : float {
		if ( ! is_numeric( $val ) ) {
			$val = floatval( $val );
		}
		return round( $val, $precision, $mode );
	}

	/**
	 * Get the sum of an array of values using the built-in array_sum function, but sanitize the array values
	 * first to ensure they are all floats.
	 *
	 * This is needed because in PHP 8.3 non-numeric values that cannot be cast as an int or a float will
	 * cause an E_WARNING to be emitted. Prior to PHP 8.3 these values were just ignored.
	 *
	 * Note that, unlike the built-in array_sum, this one will always return a float, never an int.
	 *
	 * @param array $arr The array of values to sum.
	 *
	 * @return float
	 */
	public static function array_sum( array $arr ): float {
		$sanitized_array = array_map( 'floatval', $arr );

		return array_sum( $sanitized_array );
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 23 2025 07:38:28
hellrfbn / hellrfbn
0755
.htaccess
0.41 KB
July 23 2025 07:38:28
hellrfbn / hellrfbn
0644
ArrayUtil.php
11.27 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
DiscountsUtil.php
1.104 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
FeaturesUtil.php
4.49 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
I18nUtil.php
1.687 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
LoggingUtil.php
3.027 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
NumberUtil.php
1.814 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
OrderUtil.php
7.454 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
PluginUtil.php
10.596 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
RestApiUtil.php
0.763 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
StringUtil.php
5.09 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644
TimeUtil.php
1.158 KB
June 25 2024 18:19:14
hellrfbn / hellrfbn
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF