Mass update
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
use Core\Database;
|
||||
//use Core\Database;
|
||||
use Exception;
|
||||
use http\Message;
|
||||
//use http\Message;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
|
||||
class Db
|
||||
class DbOld
|
||||
{
|
||||
/**
|
||||
* Íàñòðîéêè ïîäêëþ÷åíèÿ
|
||||
@@ -5,19 +5,30 @@ namespace Insallah;
|
||||
/** All raw mathematics in one place. */
|
||||
class Math
|
||||
{
|
||||
public static function getPercentage($total, $number)
|
||||
/**
|
||||
* @param float|int $total
|
||||
* @param int|null $number
|
||||
* @return float
|
||||
*/
|
||||
public static function getPercentage($total, ?int $number): float
|
||||
{
|
||||
if (is_null($number)) {
|
||||
return 0;
|
||||
}
|
||||
return $total > 0 ? round(($number * 100) / $total, 2) : 0;
|
||||
}
|
||||
|
||||
|
||||
public static function get100Percentage($total, $number)
|
||||
public static function get100Percentage($total, ?int $number)
|
||||
{
|
||||
if (is_null($number)) {
|
||||
return 0;
|
||||
}
|
||||
return min(self::getPercentage($total, $number), 100);
|
||||
}
|
||||
|
||||
/** Number-20% and Number+20% */
|
||||
public static function get20PercentRange($number)
|
||||
public static function get20PercentRange($number): array
|
||||
{
|
||||
return [
|
||||
'min' => $number * ((100 - 20) / 100),
|
||||
|
||||
Reference in New Issue
Block a user