HEX
Server: Apache
System: Linux nc-ph-4101.simplemoneygoals.com 5.14.0-503.21.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 12 09:45:05 EST 2025 x86_64
User: dailygoldindex (1004)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/dailygoldindex/public_html/wp-content/plugins/jnews-essential/lib/vp/classes/util/unit.php
<?php

class VP_Util_Unit {


	/**
	 * Give default measurement unit
	 * @param  string $value the value
	 * @param  string $unit  default measurement unit
	 * @return string        the correct value
	 */
	public static function grant_default_unit($value, $unit) {
		if (is_numeric($value)) {
			return $value . $unit;
		}
		return $value;
	}

	/**
	 * Calculate Percentage from given Value and Range
	 * @param  float $min    minimal
	 * @param  float $max    maximum
	 * @param  float $value  value
	 * @param  integer $ndec number of decimal allowed
	 * @return string        the percentage
	 */
	public static function calculate_percentage($min, $max, $value, $ndec = 0) {
		return round(($value - $min) / ($max - $min) * 100, $ndec) . '%';
	}
}